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

Function function_tokenize_example

examples/src/jsonpath_examples.cpp:97–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97void function_tokenize_example()
98{
99 std::string data = R"(
100{
101"books":
102[
103 {
104 "title" : "A Wild Sheep Chase",
105 "author" : "Haruki Murakami"
106 },
107 {
108 "title" : "Almost Transparent Blue",
109 "author" : "Ryu Murakami"
110 },
111 {
112 "title" : "The Quiet American",
113 "author" : "Graham Greene"
114 }
115]
116}
117 )";
118
119 auto j = jsoncons::json::parse(data);
120
121 // All titles whose author's last name is 'Murakami'
122 std::string expr = R"($.books[?(tokenize(@.author,'\\s+')[-1] == 'Murakami')].title)";
123
124 jsoncons::json result = jsonpath::json_query(j, expr);
125 std::cout << pretty_print(result) << "\n\n";
126}
127
128void function_sum_example()
129{

Callers 1

mainFunction · 0.85

Calls 3

parseFunction · 0.85
json_queryFunction · 0.85
pretty_printFunction · 0.85

Tested by

no test coverage detected