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

Function json_replace_example3

examples/src/jsonpath_examples.cpp:372–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372void json_replace_example3()
373{
374 std::ifstream is("./input/books.json");
375 auto data =jsoncons::json::parse(is);
376
377 auto f = [](const std::string& /*location*/, jsoncons::json& price)
378 {
379 price = std::round(price.as<double>() - 1.0);
380 };
381
382 // make a discount on all books
383 jsonpath::json_replace(data, "$.books[*].price", f);
384 std::cout << pretty_print(data) << "\n\n";
385}
386
387void json_replace_example4()
388{

Callers 1

mainFunction · 0.85

Calls 3

parseFunction · 0.85
json_replaceFunction · 0.85
pretty_printFunction · 0.85

Tested by

no test coverage detected