| 95 | } |
| 96 | |
| 97 | void 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 | |
| 128 | void function_sum_example() |
| 129 | { |
no test coverage detected