mirror of
https://github.com/nlohmann/json.git
synced 2024-11-30 18:59:02 +08:00
b21c345179
* 🚚 move files * 🚚 rename doc folder to docs * 🚚 rename test folder to tests
27 lines
524 B
C++
27 lines
524 B
C++
#include <iostream>
|
|
#include <iomanip>
|
|
#include <sstream>
|
|
#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';
|
|
}
|