2017-07-09 09:51:38 +00:00
|
|
|
#include <iostream>
|
2018-08-16 19:53:47 +00:00
|
|
|
#include <iomanip>
|
|
|
|
#include <sstream>
|
2018-02-01 21:20:26 +00:00
|
|
|
#include <nlohmann/json.hpp>
|
2015-06-22 21:21:49 +00:00
|
|
|
|
2016-01-30 19:23:14 +00:00
|
|
|
using json = nlohmann::json;
|
2015-06-22 21:21:49 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
// create stream with serialized JSON
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << R"({
|
|
|
|
"number": 23,
|
|
|
|
"string": "Hello, world!",
|
|
|
|
"array": [1, 2, 3, 4, 5],
|
|
|
|
"boolean": false,
|
|
|
|
"null": null
|
|
|
|
})";
|
|
|
|
|
|
|
|
// create JSON value and read the serialization from the stream
|
|
|
|
json j;
|
2017-09-30 08:18:18 +00:00
|
|
|
ss >> j;
|
2015-06-22 21:21:49 +00:00
|
|
|
|
|
|
|
// serialize JSON
|
|
|
|
std::cout << std::setw(2) << j << '\n';
|
|
|
|
}
|