You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
465 B

  1. #include <json.hpp>
  2. using json = nlohmann::json;
  3. int main()
  4. {
  5. // create a JSON value
  6. json value = { {"translation", {{"one", "eins"}, {"two", "zwei"}}} };
  7. // create an object_t
  8. json::object_t object = {{"cow", "Kuh"}, {"dog", "Hund"}};
  9. // swap the object stored in the JSON value
  10. value["translation"].swap(object);
  11. // output the values
  12. std::cout << "value = " << value << '\n';
  13. std::cout << "object = " << object << '\n';
  14. }