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

Function encode_n_rows

examples/src/csv_examples.cpp:68–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68void encode_n_rows()
69{
70 const std::string jtext = R"(
71[
72 ["customer_name","has_coupon","phone_number","zip_code","sales_tax_rate","total_amount"],
73 ["John Roe",true,"0272561313","01001",0.05,431.65],
74 ["Jane Doe",false,"416-272-2561","55416",0.15,480.7],
75 ["Joe Bloggs",false,"4162722561","55416",0.15,300.7],
76 ["John Smith",false,null,"22313-1450",0.15,300.7]
77]
78 )";
79
80 auto j = jsoncons::json::parse(jtext);
81
82 std::string output;
83 auto ioptions = csv::csv_options{}
84 .quote_style(csv::quote_style_kind::nonnumeric);
85 csv::encode_csv(j, output, ioptions);
86 std::cout << output << "\n\n";
87
88 auto other = csv::decode_csv<jsoncons::json>(output);
89 assert(other == j);
90}
91
92void encode_m_columns()
93{

Callers 1

mainFunction · 0.85

Calls 3

parseFunction · 0.85
encode_csvFunction · 0.85
quote_styleMethod · 0.80

Tested by

no test coverage detected