Skip to content

Commit

Permalink
csv flat mapping multivalued
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Jan 14, 2025
1 parent 1395d12 commit 6c3c2dc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions include/jsoncons_ext/csv/csv_encoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ class basic_csv_encoder final : public basic_json_visitor<CharT>
sink_.append(options_.line_delimiter().data(),
options_.line_delimiter().length());
}
std::cout << "num column_names_: " << column_names_.size() << "\n";
for (std::size_t i = 0; i < column_names_.size(); ++i)
{
if (i > 0)
Expand Down Expand Up @@ -363,11 +364,14 @@ class basic_csv_encoder final : public basic_json_visitor<CharT>
}
else
{
if (options_.column_names().empty())
if (stack_[0].count_ == 0)
{
column_names_.emplace_back(stack_.back().pathname_);
if (options_.column_names().empty())
{
column_names_.emplace_back(stack_.back().pathname_);
}
cname_value_map_[stack_.back().pathname_] = std::basic_string<CharT>();
}
cname_value_map_[stack_.back().pathname_] = std::basic_string<CharT>();
value_buffer_.clear();
stack_.emplace_back(stack_item_kind::multivalued_field);
}
Expand Down Expand Up @@ -640,6 +644,7 @@ class basic_csv_encoder final : public basic_json_visitor<CharT>
if (options_.column_names().empty())
{
column_names_.emplace_back(stack_.back().pathname_);
std::cout << "Number of columns: " << column_names_.size() << "\n";
}
cname_value_map_[stack_.back().pathname_] = std::basic_string<CharT>();
}
Expand Down

0 comments on commit 6c3c2dc

Please sign in to comment.