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

Function flatten_and_unflatten2

examples/src/jsonpointer_examples.cpp:479–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

477}
478
479void flatten_and_unflatten2()
480{
481 json input = json::parse(R"(
482 {
483 "discards": {
484 "1000": "Record does not exist",
485 "1004": "Queue limit exceeded",
486 "1010": "Discarding timed-out partial msg"
487 },
488 "warnings": {
489 "0": "Phone number missing country code",
490 "1": "State code missing",
491 "2": "Zip code missing"
492 }
493 }
494 )");
495
496 json flattened = jsonpointer::flatten(input);
497 std::cout << "(1)\n" << pretty_print(flattened) << "\n";
498
499 json unflattened1 = jsonpointer::unflatten(flattened);
500 std::cout << "(2)\n" << pretty_print(unflattened1) << "\n";
501
502 json unflattened2 = jsonpointer::unflatten(flattened,
503 jsonpointer::unflatten_options::assume_object);
504 std::cout << "(3)\n" << pretty_print(unflattened2) << "\n";
505}
506
507void get_and_create_if_missing()
508{

Callers 1

mainFunction · 0.85

Calls 4

parseFunction · 0.85
pretty_printFunction · 0.85
flattenFunction · 0.50
unflattenFunction · 0.50

Tested by

no test coverage detected