| 165 | } |
| 166 | |
| 167 | void function_avg_example() |
| 168 | { |
| 169 | std::string data = R"( |
| 170 | { |
| 171 | "books": |
| 172 | [ |
| 173 | { |
| 174 | "title" : "A Wild Sheep Chase", |
| 175 | "author" : "Haruki Murakami", |
| 176 | "price" : 22.72 |
| 177 | }, |
| 178 | { |
| 179 | "title" : "The Night Watch", |
| 180 | "author" : "Sergei Lukyanenko", |
| 181 | "price" : 23.58 |
| 182 | }, |
| 183 | { |
| 184 | "title" : "The Comedians", |
| 185 | "author" : "Graham Greene", |
| 186 | "price" : 21.99 |
| 187 | }, |
| 188 | { |
| 189 | "title" : "The Night Watch", |
| 190 | "author" : "Phillips, David Atlee" |
| 191 | } |
| 192 | ] |
| 193 | } |
| 194 | )"; |
| 195 | |
| 196 | auto j = jsoncons::json::parse(data); |
| 197 | |
| 198 | // All titles whose price is greater than the average price |
| 199 | std::string expr = R"($.books[?(@.price > avg($.books[*].price))].title)"; |
| 200 | |
| 201 | jsoncons::json result = jsonpath::json_query(j, expr); |
| 202 | std::cout << result << "\n\n"; |
| 203 | } |
| 204 | |
| 205 | void function_floor_example() |
| 206 | { |
no test coverage detected