json/doc/examples/operator_deserialize.cpp
Niels Lohmann 504012a3db
📝 cleanup after #650
As <iostream> is not included in json.hpp any more, all code examples need to include <iostream> now.
2017-07-09 11:51:38 +02:00

26 lines
513 B
C++

#include <iostream>
#include <iomanip> // for std::setw
#include "json.hpp"
using json = nlohmann::json;
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';
}