1 #include <iostream>
2 #include <nlohmann/json.hpp>
3
4 using json = nlohmann::json;
5
main()6 int main()
7 {
8 // create JSON values
9 json j_empty_init_list = json({});
10 json j_object = { {"one", 1}, {"two", 2} };
11 json j_array = {1, 2, 3, 4};
12 json j_nested_object = { {"one", {1}}, {"two", {1, 2}} };
13 json j_nested_array = { {{1}, "one"}, {{1, 2}, "two"} };
14
15 // serialize the JSON value
16 std::cout << j_empty_init_list << '\n';
17 std::cout << j_object << '\n';
18 std::cout << j_array << '\n';
19 std::cout << j_nested_object << '\n';
20 std::cout << j_nested_array << '\n';
21 }
22