2017-07-09 17:51:38 +08:00
|
|
|
#include <iostream>
|
2017-04-14 23:37:28 +08:00
|
|
|
#include <iomanip> // for std::setw
|
2017-07-09 17:51:38 +08:00
|
|
|
#include "json.hpp"
|
2015-06-23 05:21:49 +08:00
|
|
|
|
2016-01-31 03:23:14 +08:00
|
|
|
using json = nlohmann::json;
|
2015-06-23 05:21:49 +08: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 16:18:18 +08:00
|
|
|
ss >> j;
|
2015-06-23 05:21:49 +08:00
|
|
|
|
|
|
|
// serialize JSON
|
|
|
|
std::cout << std::setw(2) << j << '\n';
|
|
|
|
}
|