Initial import of libdpf.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
e4e666f459
4563 changed files with 1690372 additions and 0 deletions
24
thirdparty/json/docs/examples/update.cpp
vendored
Normal file
24
thirdparty/json/docs/examples/update.cpp
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using namespace nlohmann::literals;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create two JSON objects
|
||||
json o1 = R"( {"color": "red", "price": 17.99, "names": {"de": "Flugzeug"}} )"_json;
|
||||
json o2 = R"( {"color": "blue", "speed": 100, "names": {"en": "plane"}} )"_json;
|
||||
json o3 = o1;
|
||||
|
||||
// add all keys from o2 to o1 (updating "color", replacing "names")
|
||||
o1.update(o2);
|
||||
|
||||
// add all keys from o2 to o1 (updating "color", merging "names")
|
||||
o3.update(o2, true);
|
||||
|
||||
// output updated object o1 and o3
|
||||
std::cout << std::setw(2) << o1 << '\n';
|
||||
std::cout << std::setw(2) << o3 << '\n';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue