• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <iostream>
2 #include <iomanip>
3 #include <nlohmann/json.hpp>
4 
5 using json = nlohmann::json;
6 
main()7 int main()
8 {
9     // create two JSON objects
10     json o1 = R"( {"color": "red", "price": 17.99} )"_json;
11     json o2 = R"( {"color": "blue", "speed": 100} )"_json;
12 
13     // add all keys from o2 to o1 (updating "color")
14     o1.update(o2.begin(), o2.end());
15 
16     // output updated object o1
17     std::cout << std::setw(2) << o1 << '\n';
18 }
19