| 725 | } |
| 726 | |
| 727 | void parent_operator_example() |
| 728 | { |
| 729 | std::string doc = R"( |
| 730 | [ |
| 731 | { |
| 732 | "author" : "Haruki Murakami", |
| 733 | "title": "A Wild Sheep Chase", |
| 734 | "reviews": [{"rating": 4, "reviewer": "Nan"}] |
| 735 | }, |
| 736 | { |
| 737 | "author" : "Sergei Lukyanenko", |
| 738 | "title": "The Night Watch", |
| 739 | "reviews": [{"rating": 5, "reviewer": "Alan"}, |
| 740 | {"rating": 3,"reviewer": "Anne"}] |
| 741 | }, |
| 742 | { |
| 743 | "author" : "Graham Greene", |
| 744 | "title": "The Comedians", |
| 745 | "reviews": [{"rating": 4, "reviewer": "Lisa"}, |
| 746 | {"rating": 5, "reviewer": "Robert"}] |
| 747 | } |
| 748 | ] |
| 749 | )"; |
| 750 | |
| 751 | jsoncons::json store = jsoncons::json::parse(doc); |
| 752 | |
| 753 | std::string path = "$[*].reviews[?(@.rating == 5)]^^"; |
| 754 | auto result = jsonpath::json_query(store, path); |
| 755 | std::cout << pretty_print(result) << "\n\n"; |
| 756 | } |
| 757 | |
| 758 | template <typename Json> |
| 759 | class my_custom_functions : public jsonpath::custom_functions<Json> |
no test coverage detected