6

I am using jsoncpp, is there a way to put a map in Json::Value ?

I understand I can extract keys one by one and put them in the Json::Value. but is there a more graceful way ? for example in the C# counter part NewtonSoft json api

I would do

      String json = JsonConvert.SerializeObject(cmdDict);   
Ahmed
  • 14,503
  • 22
  • 92
  • 150
  • [ThorsSerializer](https://github.com/Loki-Astari/ThorsSerializer) supports converting standard C++ types to/from JSON automatically. Any user defined types can also be streamed simply by adding a single declaration for that type. – Martin York Feb 06 '23 at 20:54

1 Answers1

0

jsoncpp doesn't support that.

Two C++ libraries that do support conversion between JSON and C++ types are nlohmann and jsoncons (see this answer). Note that C++ does not have introspection, so the mappings between your custom C++ types and JSON need to be set up explicitly, according to the specifications of the library.

Daniel
  • 728
  • 7
  • 11