json/doc/examples/swap__string_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
409 B
C++

#include "json.hpp"
using json = nlohmann::json;
int main()
{
// create a JSON value
json value = { "the good", "the bad", "the ugly" };
// create string_t
json::string_t string = "the fast";
// swap the object stored in the JSON value
value[1].swap(string);
// output the values
std::cout << "value = " << value << '\n';
std::cout << "string = " << string << '\n';
}