Skip to content

Support nested json to csv. #556

@danielaparker

Description

@danielaparker

Suppose, we have this source (testjson_nested.json):

[
    {
        "text": "Chicago Reader", 
        "float": 1.0, 
        "datetime": "1971-01-01T04:14:00", 
        "boolean": true,
        "nested": {
          "time": "04:14:00",
          "nested": {
            "date": "1971-01-01",
            "integer": 40
          }
        }
    }, 
    {
        "text": "Chicago Sun-Times", 
        "float": 1.27, 
        "datetime": "1948-01-01T14:57:13", 
        "boolean": true,
        "nested": {
          "time": "14:57:13",
          "nested": {
            "date": "1948-01-01",
            "integer": 63
          }
        }
    }
]

And here is how Python csvkit's utility in2csv does this conversion:

(base) C:\Users\Wiluite50>in2csv testjson_nested.json
text,float,datetime,boolean,nested/time,nested/nested/date,nested/nested/integer
Chicago Reader,1.0,1971-01-01T04:14:00,True,4:14:00,1971-01-01,40
Chicago Sun-Times,1.27,1948-01-01T14:57:13,True,14:57:13,1948-01-01,63

I've even seen a C++ code that did it as well (except for saving field ordering, what is very important to be).
But, the jsoncons seems to be perfectly designed and quick, and it would be nice to have the same thing within it.

Originally posted by @wiluite in #555 (comment)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions