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

Function make_expression_examples

examples/src/jsonpath_examples.cpp:583–601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

581}
582
583void make_expression_examples()
584{
585 auto expr = jsonpath::make_expression<jsoncons::json>("$.books[1,1,3].title");
586
587 std::ifstream is("./input/books.json");
588 auto data =jsoncons::json::parse(is);
589
590 jsoncons::json result1 = expr.evaluate(data);
591 std::cout << "(1) " << pretty_print(result1) << "\n\n";
592
593 jsoncons::json result2 = expr.evaluate(data, jsonpath::result_options::path);
594 std::cout << "(2) " << pretty_print(result2) << "\n\n";
595
596 jsoncons::json result3 = expr.evaluate(data, jsonpath::result_options::nodups);
597 std::cout << "(3) " << pretty_print(result3) << "\n\n";
598
599 jsoncons::json result4 = expr.evaluate(data, jsonpath::result_options::path | jsonpath::result_options::nodups);
600 std::cout << "(4) " << pretty_print(result4) << "\n\n";
601}
602
603void more_make_expression_example()
604{

Callers 1

mainFunction · 0.85

Calls 3

parseFunction · 0.85
pretty_printFunction · 0.85
evaluateMethod · 0.45

Tested by

no test coverage detected