2017-07-09 17:51:38 +08:00
|
|
|
#include <iostream>
|
2017-04-22 04:07:07 +08:00
|
|
|
#include "json.hpp"
|
2015-07-08 22:55:29 +08:00
|
|
|
|
2016-01-31 03:23:14 +08:00
|
|
|
using json = nlohmann::json;
|
2015-07-08 22:55:29 +08: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';
|
|
|
|
}
|