mirror of
https://github.com/nlohmann/json.git
synced 2024-12-13 12:39:02 +08:00
24 lines
454 B
C++
24 lines
454 B
C++
|
#include <json.hpp>
|
||
|
|
||
|
using namespace nlohmann;
|
||
|
|
||
|
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';
|
||
|
}
|