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
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
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"}