Skip to content

Nested json to csv. #555

Answered by danielaparker
wiluite asked this question in General
Discussion options

You must be logged in to vote

I've added support for nested json to csv on master. This includes two additional csv options,

  • A boolean, flat, which indicates whether the encoder should process JSON as "flat" (without navigating through nested structures). The default is true, for backwards compatibility.
  • A vector of JSONPointer/column name pairs, column_mapping, for controlling the selection and order of columns and column naming (when flat is false, column names default to the JSONPointers identifying their location within each item.)

Your example becomes:

#include <jsoncons/json.hpp>
#include <jsoncons_ext/csv/csv.hpp>

namespace csv = jsoncons::csv;

int main()
{
    std::string jtext = R"(
[
    {
        "text"…

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by wiluite
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants