2017-07-09 11:51:38 +02:00
|
|
|
#include <iostream>
|
2018-02-01 22:20:26 +01:00
|
|
|
#include <nlohmann/json.hpp>
|
2015-07-08 16:55:29 +02:00
|
|
|
|
2016-01-30 20:23:14 +01:00
|
|
|
using json = nlohmann::json;
|
2015-07-08 16:55:29 +02: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';
|
|
|
|
}
|