| 14 | namespace jmespath = jsoncons::jmespath; |
| 15 | |
| 16 | void search_example() |
| 17 | { |
| 18 | std::string jtext = R"( |
| 19 | { |
| 20 | "locations": [ |
| 21 | {"name": "Seattle", "state": "WA"}, |
| 22 | {"name": "New York", "state": "NY"}, |
| 23 | {"name": "Bellevue", "state": "WA"}, |
| 24 | {"name": "Olympia", "state": "WA"} |
| 25 | ] |
| 26 | } |
| 27 | )"; |
| 28 | |
| 29 | std::string expr = "locations[?state == 'WA'].name | sort(@) | {WashingtonCities: join(', ', @)}"; |
| 30 | |
| 31 | json doc = json::parse(jtext); |
| 32 | |
| 33 | json result = jmespath::search(doc, expr); |
| 34 | |
| 35 | std::cout << pretty_print(result) << "\n\n"; |
| 36 | } |
| 37 | |
| 38 | void jmespath_expression_example() |
| 39 | { |
no test coverage detected