insert__range_object.cpp 457 B

123456789101112131415161718192021
  1. #include <iostream>
  2. #include <nlohmann/json.hpp>
  3. using json = nlohmann::json;
  4. int main()
  5. {
  6. // create two JSON objects
  7. json j1 = {{"one", "eins"}, {"two", "zwei"}};
  8. json j2 = {{"eleven", "elf"}, {"seventeen", "siebzehn"}};
  9. // output objects
  10. std::cout << j1 << '\n';
  11. std::cout << j2 << '\n';
  12. // insert range from j2 to j1
  13. j1.insert(j2.begin(), j2.end());
  14. // output result of insert call
  15. std::cout << j1 << '\n';
  16. }