mirror of
https://github.com/nlohmann/json
synced 2024-12-02 08:20:11 +00:00
0258484626
- updated documentation wrt. new repository layout - temporarily switched off Homebrew --HEAD building (can only be switched on after release) - set copyright date to 2018
25 lines
486 B
C++
25 lines
486 B
C++
#include <iostream>
|
|
#include <nlohmann/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;
|
|
ss >> j;
|
|
|
|
// serialize JSON
|
|
std::cout << std::setw(2) << j << '\n';
|
|
}
|