Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalized csv to json conversion #556

Open
danielaparker opened this issue Nov 21, 2024 · 0 comments
Open

Generalized csv to json conversion #556

danielaparker opened this issue Nov 21, 2024 · 0 comments

Comments

@danielaparker
Copy link
Owner

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant