| 538 | )"; |
| 539 | |
| 540 | void as_a_variant_like_structure() |
| 541 | { |
| 542 | auto options = csv::csv_options{} |
| 543 | .assume_header(true); |
| 544 | |
| 545 | // Parse the CSV data into an ojson value |
| 546 | auto j = csv::decode_csv<jsoncons::ojson>(data, options); |
| 547 | |
| 548 | // Pretty print |
| 549 | auto print_options = jsoncons::json_options{} |
| 550 | .float_format(jsoncons::float_chars_format::fixed); |
| 551 | std::cout << "(1)\n" << pretty_print(j, print_options) << "\n\n"; |
| 552 | |
| 553 | // Iterate over the rows |
| 554 | std::cout << std::fixed << std::setprecision(7); |
| 555 | std::cout << "(2)\n"; |
| 556 | for (const auto& row : j.array_range()) |
| 557 | { |
| 558 | // Access rated as string and rating as double |
| 559 | std::cout << row["index_id"].as<std::string>() << ", " |
| 560 | << row["observation_date"].as<std::string>() << ", " |
| 561 | << row["rate"].as<double>() << "\n"; |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | void as_a_strongly_typed_cpp_structure() |
| 566 | { |
no test coverage detected