mirror of
https://github.com/nlohmann/json.git
synced 2024-12-16 06:59:04 +08:00
504012a3db
As <iostream> is not included in json.hpp any more, all code examples need to include <iostream> now.
22 lines
448 B
C++
22 lines
448 B
C++
#include <iostream>
|
|
#include "json.hpp"
|
|
|
|
using json = nlohmann::json;
|
|
|
|
int main()
|
|
{
|
|
// create two JSON objects
|
|
json j1 = {{"one", "eins"}, {"two", "zwei"}};
|
|
json j2 = {{"eleven", "elf"}, {"seventeen", "siebzehn"}};
|
|
|
|
// output objects
|
|
std::cout << j1 << '\n';
|
|
std::cout << j2 << '\n';
|
|
|
|
// insert range from j2 to j1
|
|
j1.insert(j2.begin(), j2.end());
|
|
|
|
// output result of insert call
|
|
std::cout << j1 << '\n';
|
|
}
|