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

Function encode_nested_json_to_csv

examples/src/csv_examples.cpp:681–722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

679}
680
681void 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
724void encode_nested_json_to_csv_with_column_mapping() // (since 1.2.0)
725{

Callers 1

mainFunction · 0.85

Calls 3

parseFunction · 0.85
encode_csvFunction · 0.85
flatMethod · 0.80

Tested by

no test coverage detected