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

Function search_example

examples/src/jmespath_examples.cpp:16–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14namespace jmespath = jsoncons::jmespath;
15
16void 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
38void jmespath_expression_example()
39{

Callers 1

mainFunction · 0.85

Calls 3

parseFunction · 0.85
searchFunction · 0.85
pretty_printFunction · 0.85

Tested by

no test coverage detected