| 477 | } |
| 478 | |
| 479 | void 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 | |
| 507 | void get_and_create_if_missing() |
| 508 | { |
no test coverage detected