• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 object = {{"one", 1}, {"two", 2}};
10     json null;
11 
12     // print values
13     std::cout << object << '\n';
14     std::cout << null << '\n';
15 
16     // add values
17     object.push_back(json::object_t::value_type("three", 3));
18     object += json::object_t::value_type("four", 4);
19     null += json::object_t::value_type("A", "a");
20     null += json::object_t::value_type("B", "b");
21 
22     // print values
23     std::cout << object << '\n';
24     std::cout << null << '\n';
25 }
26