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

Function encode_json_with_subfields

examples/src/csv_examples.cpp:497–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495}
496
497void encode_json_with_subfields()
498{
499 std::string jtext = R"(
500[
501 {
502 "calculationPeriodCenters": ["NY","LON"],
503 "paymentCenters": "TOR",
504 "resetCenters": "LON"
505 },
506 {
507 "calculationPeriodCenters": "NY",
508 "paymentCenters": "LON",
509 "resetCenters": ["TOR","LON"]
510 },
511 {
512 "calculationPeriodCenters": ["NY","LON"],
513 "paymentCenters": "TOR",
514 "resetCenters": "LON"
515 },
516 {
517 "calculationPeriodCenters": "NY",
518 "paymentCenters": "LON",
519 "resetCenters": ["TOR","LON"]
520 }
521]
522 )";
523
524 auto j = jsoncons::ojson::parse(jtext);
525
526 auto options = csv::csv_options{}
527 .subfield_delimiter(';');
528
529 std::string buf;
530 csv::encode_csv(j, buf, options);
531 std::cout << buf << "\n";
532}
533
534 const std::string data = R"(index_id,observation_date,rate
535EUR_LIBOR_06M,2015-10-23,0.0000214

Callers 1

mainFunction · 0.85

Calls 3

parseFunction · 0.85
encode_csvFunction · 0.85
subfield_delimiterMethod · 0.80

Tested by

no test coverage detected