1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-29 23:01:16 +03:00

proposal for #428

This implementation forwards the iterators to std::map::insert.
This commit is contained in:
Niels Lohmann
2017-04-07 18:29:09 +02:00
parent 90273e930c
commit 97a25de938
5 changed files with 150 additions and 1 deletions

View File

@ -0,0 +1,20 @@
#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';
}

View File

@ -0,0 +1,3 @@
{"one":"eins","two":"zwei"}
{"eleven":"elf","seventeen":"siebzehn"}
{"eleven":"elf","one":"eins","seventeen":"siebzehn","two":"zwei"}