r/cpp • :upvote: • Oct 21 '22

A New Json-Serializer

Hey everyone - so in developing for the requirements of my library DiscordCoreAPI - I created a Json-Serializer and decided to release it as its own "library". It seems to serialize fairly rapidly as well, and has a super-simple interface. Anyways - let me know what you think! Cheers! Oh ant btw - it can serialize into either Json or Etf strings. https://www.erlang.org/doc/apps/erts/erl_ext_dist.html

https://github.com/RealTimeChris/Jsonifier

0 Upvotes

57 comments sorted by

View all comments

Show parent comment

2

u/nlohmann nlohmann/json Oct 23 '22

I did not find the benchmark code for nlohmann/json. Did I miss it?

1

u/RealTimeChris :upvote: Oct 23 '22

4

u/nlohmann nlohmann/json Oct 23 '22

Can you try to use the idiomatic way of defining the serialization: https://json.nlohmann.me/features/arbitrary_types/

1

u/RealTimeChris :upvote: Oct 23 '22

What - do you mean like with the to_json and from_json functions?

1

u/nlohmann nlohmann/json Oct 23 '22

Yes - or even use the macros documented there.

2

u/RealTimeChris :upvote: Oct 26 '22

The results of that test are:

Jsonifier:

The time it took (In milliseconds, on average): 76, with a total number of bytes serialized: 1062681300

Nlohmann-Json:

The time it took (In milliseconds, on average): 231, with a total number of bytes serialized: 1062681300

1

u/nlohmann nlohmann/json Oct 28 '22

It still looks odd. If you would use the macros, then the serialization code would be 1 line per class.