1#include <iostream> 2#include <iomanip> 3#include <sstream> 4#include <nlohmann/json.hpp> 5 6using json = nlohmann::json; 7 8int main() 9{ 10 // create stream with serialized JSON 11 std::stringstream ss; 12 ss << R"({ 13 "number": 23, 14 "string": "Hello, world!", 15 "array": [1, 2, 3, 4, 5], 16 "boolean": false, 17 "null": null 18 })"; 19 20 // create JSON value and read the serialization from the stream 21 json j; 22 ss >> j; 23 24 // serialize JSON 25 std::cout << std::setw(2) << j << '\n'; 26} 27