json/doc/examples/operator_deserialize.cpp
Niels Lohmann 9b32f72584
📝 fixed examples for Wandbox
As I learned in https://github.com/melpon/wandbox/issues/209, this
library is already installed at Wandbox, so we need to adjust the
examples to use `#include "json.hpp"` insteas of `#include <json.hpp>`.
2017-04-21 22:07:07 +02:00

25 lines
493 B
C++

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