| 385 | } |
| 386 | |
| 387 | void json_replace_example4() |
| 388 | { |
| 389 | std::ifstream is("./input/books.json"); |
| 390 | auto data =jsoncons::json::parse(is); |
| 391 | |
| 392 | auto f = [](const std::string& /*location*/, jsoncons::json& book) |
| 393 | { |
| 394 | if (book.at("category") == "memoir" && !book.contains("price")) |
| 395 | { |
| 396 | book.try_emplace("price",140.0); |
| 397 | } |
| 398 | }; |
| 399 | |
| 400 | jsonpath::json_replace(data, "$.books[*]", f); |
| 401 | std::cout << pretty_print(data) << "\n\n"; |
| 402 | } |
| 403 | |
| 404 | void jsonpath_complex_examples() |
| 405 | { |
no test coverage detected