2017-07-09 09:51:38 +00:00
|
|
|
#include <iostream>
|
2018-02-01 21:20:26 +00:00
|
|
|
#include <nlohmann/json.hpp>
|
2015-06-21 07:44:12 +00:00
|
|
|
|
2016-01-30 19:23:14 +00:00
|
|
|
using json = nlohmann::json;
|
2015-06-21 07:44:12 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
// create JSON values
|
|
|
|
json j_empty_init_list = json({});
|
|
|
|
json j_object = { {"one", 1}, {"two", 2} };
|
|
|
|
json j_array = {1, 2, 3, 4};
|
|
|
|
json j_nested_object = { {"one", {1}}, {"two", {1, 2}} };
|
|
|
|
json j_nested_array = { {{1}, "one"}, {{1, 2}, "two"} };
|
|
|
|
|
|
|
|
// serialize the JSON value
|
|
|
|
std::cout << j_empty_init_list << '\n';
|
|
|
|
std::cout << j_object << '\n';
|
|
|
|
std::cout << j_array << '\n';
|
|
|
|
std::cout << j_nested_object << '\n';
|
|
|
|
std::cout << j_nested_array << '\n';
|
|
|
|
}
|