mirror of
https://github.com/nlohmann/json.git
synced 2024-08-21 12:32:27 +02:00
- updated documentation wrt. new repository layout - temporarily switched off Homebrew --HEAD building (can only be switched on after release) - set copyright date to 2018
18 lines
396 B
C++
18 lines
396 B
C++
#include <iostream>
|
|
#include <nlohmann/json.hpp>
|
|
|
|
using json = nlohmann::json;
|
|
|
|
int main()
|
|
{
|
|
// create two JSON objects
|
|
json o1 = R"( {"color": "red", "price": 17.99} )"_json;
|
|
json o2 = R"( {"color": "blue", "speed": 100} )"_json;
|
|
|
|
// add all keys from o2 to o1 (updating "color")
|
|
o1.update(o2);
|
|
|
|
// output updated object o1
|
|
std::cout << std::setw(2) << o1 << '\n';
|
|
}
|