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

Function function_ceil_example

examples/src/jsonpath_examples.cpp:228–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228void function_ceil_example()
229{
230 std::string data = R"(
231 {
232 "books":
233 [
234 {
235 "title" : "A Wild Sheep Chase",
236 "author" : "Haruki Murakami",
237 "price" : 22.72
238 },
239 {
240 "title" : "The Night Watch",
241 "author" : "Sergei Lukyanenko",
242 "price" : 23.58
243 }
244 ]
245 }
246 )";
247
248 auto j = jsoncons::json::parse(data);
249
250 jsoncons::json result1 = jsonpath::json_query(j, "$.books[?(ceil(@.price) == 23.0)]");
251 std::cout << "(1) " << result1 << "\n\n";
252 jsoncons::json result2 = jsonpath::json_query(j, "$.books[?(ceil(@.price*100) == 2358.0)]");
253 std::cout << "(2) " << result2 << "\n\n";
254}
255
256void function_keys_example()
257{

Callers 1

mainFunction · 0.85

Calls 2

parseFunction · 0.85
json_queryFunction · 0.85

Tested by

no test coverage detected