| 254 | } |
| 255 | |
| 256 | void function_keys_example() |
| 257 | { |
| 258 | std::string data = R"( |
| 259 | { |
| 260 | "books": |
| 261 | [ |
| 262 | { |
| 263 | "title" : "A Wild Sheep Chase", |
| 264 | "author" : "Haruki Murakami", |
| 265 | "price" : 22.72 |
| 266 | }, |
| 267 | { |
| 268 | "title" : "The Night Watch", |
| 269 | "author" : "Sergei Lukyanenko", |
| 270 | "price" : 23.58 |
| 271 | }, |
| 272 | { |
| 273 | "title" : "The Comedians", |
| 274 | "author" : "Graham Greene", |
| 275 | "price" : 21.99 |
| 276 | }, |
| 277 | { |
| 278 | "title" : "The Night Watch", |
| 279 | "author" : "Phillips, David Atlee" |
| 280 | } |
| 281 | ] |
| 282 | } |
| 283 | )"; |
| 284 | |
| 285 | auto j = jsoncons::json::parse(data); |
| 286 | |
| 287 | // All books that don't have a price |
| 288 | std::string expr = "$.books[?(!contains(keys(@),'price'))]"; |
| 289 | |
| 290 | jsoncons::json result = jsonpath::json_query(j, expr); |
| 291 | std::cout << result << "\n\n"; |
| 292 | } |
| 293 | |
| 294 | void function_length_example() |
| 295 | { |
no test coverage detected