json/doc/examples/swap__object_t.cpp
Niels Lohmann 9b32f72584
📝 fixed examples for Wandbox
As I learned in https://github.com/melpon/wandbox/issues/209, this
library is already installed at Wandbox, so we need to adjust the
examples to use `#include "json.hpp"` insteas of `#include <json.hpp>`.
2017-04-21 22:07:07 +02:00

20 lines
465 B
C++

#include "json.hpp"
using json = nlohmann::json;
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';
}