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

Function jmespath_expression_example

examples/src/jmespath_examples.cpp:38–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38void jmespath_expression_example()
39{
40 std::string jtext = R"(
41 {
42 "people": [
43 {
44 "age": 20,
45 "other": "foo",
46 "name": "Bob"
47 },
48 {
49 "age": 25,
50 "other": "bar",
51 "name": "Fred"
52 },
53 {
54 "age": 30,
55 "other": "baz",
56 "name": "George"
57 }
58 ]
59 }
60 )";
61
62 auto expr = jmespath::make_expression<json>("people[?age > `20`].[name, age]");
63
64 json doc = json::parse(jtext);
65
66 json result = expr.evaluate(doc);
67
68 std::cout << pretty_print(result) << "\n\n";
69}
70
71void let_example()
72{

Callers 1

mainFunction · 0.85

Calls 3

parseFunction · 0.85
pretty_printFunction · 0.85
evaluateMethod · 0.45

Tested by

no test coverage detected