1
0
mirror of https://github.com/nlohmann/json synced 2024-12-05 01:30:07 +00:00
nlohmannjson/doc/examples/operator_serialize.cpp
2016-01-30 20:23:14 +01:00

19 lines
426 B
C++

#include <json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json j_object = {{"one", 1}, {"two", 2}};
json j_array = {1, 2, 4, 8, 16};
// serialize without indentation
std::cout << j_object << "\n\n";
std::cout << j_array << "\n\n";
// serialize with indentation
std::cout << std::setw(4) << j_object << "\n\n";
std::cout << std::setw(2) << j_array << "\n\n";
}