1
0
mirror of https://github.com/nlohmann/json synced 2024-11-15 00:31:05 +00:00
nlohmannjson/doc/examples/swap__reference.cpp
Niels Lohmann 504012a3db
📝 cleanup after #650
As <iostream> is not included in json.hpp any more, all code examples need to include <iostream> now.
2017-07-09 11:51:38 +02:00

19 lines
363 B
C++

#include <iostream>
#include "json.hpp"
using json = nlohmann::json;
int main()
{
// create two JSON values
json j1 = {1, 2, 3, 4, 5};
json j2 = {{"pi", 3.141592653589793}, {"e", 2.718281828459045}};
// swap the values
j1.swap(j2);
// output the values
std::cout << "j1 = " << j1 << '\n';
std::cout << "j2 = " << j2 << '\n';
}