]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/nlohmann-json/doc/examples/parse__string__parser_callback_t.cpp
3 #include <nlohmann/json.hpp>
5 using json
= nlohmann::json
;
15 "Title
": "View from
15th Floor
",
17 "Url
": "http
://www.example.com/image/481989943",
22 "IDs": [116, 943, 234, 38793]
27 // parse and serialize JSON
28 json j_complete = json::parse(text);
29 std::cout << std::setw(4) << j_complete << "\n\n";
32 // define parser callback
33 json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
35 // skip object elements with key "Thumbnail
"
36 if (event == json::parse_event_t::key and parsed == json("Thumbnail
"))
46 // parse (with callback) and serialize JSON
47 json j_filtered = json::parse(text, cb);
48 std::cout << std::setw(4) << j_filtered << '\n';