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