MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / json_replace_example2

Function json_replace_example2

examples/src/jsonpath_examples.cpp:341–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341void json_replace_example2()
342{
343 jsoncons::json j;
344 try
345 {
346 j = jsoncons::json::parse(R"(
347{"store":
348{"book": [
349{"category": "reference",
350"author": "Margaret Weis",
351"title": "Dragonlance Series",
352"price": 31.96},
353{"category": "reference",
354"author": "Brent Weeks",
355"title": "Night Angel Trilogy",
356"price": 14.70
357}]}}
358)");
359 }
360 catch (const std::exception& e)
361 {
362 std::cout << e.what() << "\n";
363 }
364
365 std::cout << ("1\n") << pretty_print(j) << "\n";
366
367 jsonpath::json_replace(j,"$..book[?(@.price==31.96)].price", 30.9);
368
369 std::cout << ("2\n") << pretty_print(j) << "\n\n";
370}
371
372void json_replace_example3()
373{

Callers 1

mainFunction · 0.85

Calls 4

parseFunction · 0.85
pretty_printFunction · 0.85
json_replaceFunction · 0.85
whatMethod · 0.45

Tested by

no test coverage detected