json/doc/examples/operator_deserialize.cpp

24 lines
457 B
C++
Raw Normal View History

2015-06-22 21:21:49 +00:00
#include <json.hpp>
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;
j << ss;
// serialize JSON
std::cout << std::setw(2) << j << '\n';
}