| 66 | } |
| 67 | |
| 68 | void 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 | |
| 92 | void encode_m_columns() |
| 93 | { |
no test coverage detected