| 331 | } |
| 332 | |
| 333 | void last_two_columns_repeat() |
| 334 | { |
| 335 | const std::string holidays = R"(1,CAD,2,UK,3,EUR,4,US |
| 336 | 38719,2-Jan-2006,40179,1-Jan-2010,38719,2-Jan-2006,39448,1-Jan-2008 |
| 337 | 38733,16-Jan-2006,40270,2-Apr-2010,38733,16-Jan-2006,39468,21-Jan-2008 |
| 338 | )"; |
| 339 | |
| 340 | // array of arrays |
| 341 | jsoncons::json_decoder<jsoncons::ojson> decoder1; |
| 342 | auto options1 = csv::csv_options{} |
| 343 | .column_types("[integer,string]*"); |
| 344 | std::istringstream is1(holidays); |
| 345 | csv::csv_stream_reader reader1(is1, decoder1, options1); |
| 346 | reader1.read(); |
| 347 | auto val1 = decoder1.get_result(); |
| 348 | std::cout << "(1)\n" << pretty_print(val1) << "\n"; |
| 349 | |
| 350 | // array of objects |
| 351 | jsoncons::json_decoder<jsoncons::ojson> decoder2; |
| 352 | auto options2 = csv::csv_options{} |
| 353 | .header_lines(1) |
| 354 | .column_names("CAD,UK,EUR,US") |
| 355 | .column_types("[integer,string]*"); |
| 356 | std::istringstream is2(holidays); |
| 357 | csv::csv_stream_reader reader2(is2, decoder2, options2); |
| 358 | reader2.read(); |
| 359 | auto val2 = decoder2.get_result(); |
| 360 | std::cout << "(2)\n" << pretty_print(val2) << "\n"; |
| 361 | } |
| 362 | |
| 363 | void decode_csv_string() |
| 364 | { |
no test coverage detected