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

Function jsonpointer_error_example

examples/src/jsonpointer_examples.cpp:312–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310}
311
312void jsonpointer_error_example()
313{
314 auto j = json::parse(R"(
315 [
316 { "category": "reference",
317 "author": "Nigel Rees",
318 "title": "Sayings of the Century",
319 "price": 8.95
320 },
321 { "category": "fiction",
322 "author": "Evelyn Waugh",
323 "title": "Sword of Honour",
324 "price": 12.99
325 }
326 ]
327 )");
328
329 try
330 {
331 json result = jsonpointer::get(j, "/1/isbn");
332 std::cout << "succeeded?" << '\n';
333 std::cout << result << '\n';
334 }
335 catch (const jsonpointer::jsonpointer_error& e)
336 {
337 std::cout << "Caught jsonpointer_error with category " << e.code().category().name()
338 << ", code " << e.code().value()
339 << " and message \"" << e.what() << "\"" << '\n';
340 }
341}
342
343void jsonpointer_get_examples()
344{

Callers 1

mainFunction · 0.85

Calls 7

parseFunction · 0.85
getFunction · 0.50
nameMethod · 0.45
categoryMethod · 0.45
codeMethod · 0.45
valueMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected