75. Serializing data to JSON

As with XML, no standard support for JSON exists. However, there are a large number of cross-platform libraries for this purpose. At the time of writing, the nativejson-benchmark project, available at https://github.com/miloyip/nativejson-benchmark, lists more than 40 libraries. This project is a benchmark that evaluates the conformance and performance (speed, memory, and code size) of open source C/C++ libraries with JSON parsing/generation capabilities. This makes it perhaps a bit hard to choose the right library, although top contenders may include RapidJSON, NLohmann, taocpp/json, Configuru, json_spirit, jsoncpp. For solving this task we will use here the nlohmann/json library. It is a cross-platform, header ...

Get The Modern C++ Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.