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

Function function_length_example

examples/src/jsonpath_examples.cpp:294–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294void function_length_example()
295{
296 std::string data = R"(
297{
298"books":
299[
300 {
301 "title" : "A Wild Sheep Chase",
302 "author" : "Haruki Murakami",
303 "price" : 22.72
304 },
305 {
306 "title" : "The Night Watch",
307 "author" : "Sergei Lukyanenko",
308 "price" : 23.58
309 },
310 {
311 "title" : "The Comedians",
312 "author" : "Graham Greene",
313 "price" : 21.99
314 },
315 {
316 "title" : "The Night Watch",
317 "author" : "Phillips, David Atlee"
318 }
319]
320}
321 )";
322
323 auto j = jsoncons::json::parse(data);
324
325 jsoncons::json result1 = jsonpath::json_query(j, "length($.books[*])");
326 std::cout << "(1) " << result1 << "\n\n";
327
328 jsoncons::json result2 = jsonpath::json_query(j, "length($.books[*].price)");
329 std::cout << "(2) " << result2 << "\n\n";
330}
331
332void json_replace_example1()
333{

Callers 1

mainFunction · 0.85

Calls 2

parseFunction · 0.85
json_queryFunction · 0.85

Tested by

no test coverage detected