| 679 | } |
| 680 | |
| 681 | void encode_nested_json_to_csv() // (since 1.2.0) |
| 682 | { |
| 683 | std::string jtext = R"( |
| 684 | [ |
| 685 | { |
| 686 | "text": "Chicago Reader", |
| 687 | "float": 1.0, |
| 688 | "datetime": "1971-01-01T04:14:00", |
| 689 | "boolean": true, |
| 690 | "nested": { |
| 691 | "time": "04:14:00", |
| 692 | "nested": { |
| 693 | "date": "1971-01-01", |
| 694 | "integer": 40 |
| 695 | } |
| 696 | } |
| 697 | }, |
| 698 | { |
| 699 | "text": "Chicago Sun-Times", |
| 700 | "float": 1.27, |
| 701 | "datetime": "1948-01-01T14:57:13", |
| 702 | "boolean": true, |
| 703 | "nested": { |
| 704 | "time": "14:57:13", |
| 705 | "nested": { |
| 706 | "date": "1948-01-01", |
| 707 | "integer": 63 |
| 708 | } |
| 709 | } |
| 710 | } |
| 711 | ] |
| 712 | )"; |
| 713 | |
| 714 | auto j = jsoncons::ojson::parse(jtext); |
| 715 | |
| 716 | auto options = csv::csv_options{} |
| 717 | .flat(false); |
| 718 | |
| 719 | std::string buf; |
| 720 | csv::encode_csv(j, buf, options); |
| 721 | std::cout << buf << "\n"; |
| 722 | } |
| 723 | |
| 724 | void encode_nested_json_to_csv_with_column_mapping() // (since 1.2.0) |
| 725 | { |
no test coverage detected