2017-07-09 09:51:38 +00:00
|
|
|
#include <iostream>
|
2018-02-01 21:20:26 +00:00
|
|
|
#include <nlohmann/json.hpp>
|
2015-07-08 14:55:29 +00:00
|
|
|
|
2016-01-30 19:23:14 +00:00
|
|
|
using json = nlohmann::json;
|
2015-07-08 14:55:29 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
// create a JSON value
|
|
|
|
json value = { {"translation", {{"one", "eins"}, {"two", "zwei"}}} };
|
|
|
|
|
|
|
|
// create an object_t
|
|
|
|
json::object_t object = {{"cow", "Kuh"}, {"dog", "Hund"}};
|
|
|
|
|
|
|
|
// swap the object stored in the JSON value
|
|
|
|
value["translation"].swap(object);
|
|
|
|
|
|
|
|
// output the values
|
|
|
|
std::cout << "value = " << value << '\n';
|
|
|
|
std::cout << "object = " << object << '\n';
|
|
|
|
}
|