-
Notifications
You must be signed in to change notification settings - Fork 362
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
Fields are missing in csv output #104
Comments
how many fields are there? and do all objects have those fields? |
Yeah, I just realized it's only the fields of the first object. Is there no flag to include all available fields in all objects and not just those of the first one? |
It should work just fine as long as your JSON is an array. See this test: https://github.com/zemirco/json2csv/blob/master/test/index.js#L45 |
I am also facing same issue. |
What does you data look like? |
Ping |
There is also a |
I'm experiencing the same problem. |
I need some example data to debug this issue. |
@knownasilya Here's an example of the behavior @adius explains as "it's only the fields of the first object". Note how the third object in the array has a different schema than the first two and the output only expresses schema of the first object and then behaves strangely for the output of the third object (I'm guessing it's something like /Users/rj λ json2csv --version
3.6.0
/Users/rj λ echo '[{"a":1,"b":2}, {"a":3,"b":4},{"c":5}]' | json2csv
"a","b"
1,2
3,4
, |
Looks like expected behavior to me, since you didn't set default values. |
If this is the default behavior, we have entirely different views on how this is supposed to work 😂🙈 |
I seems like everybody else things it should work like this:
|
Ah, I see your point. I think this hasn't been addressed due to an assumption that all of the objects are of the same schema. I'd take a PR to address this if you want to contribute. |
@adius Your example is what I would have expected. Might be worth looking at how the |
So this issue only exists for the auto-fields feature, so it should be easy enough to fix. I'll look into it. |
Can you give master a try before I publish this? |
Published as 3.6.1 |
It works! Old...
New!
|
Unless I am missing something, this is broken again:
, Expected behavior should be: |
I have several hundred objects and serialize them with json2csv.
There are, however, some fields missing in the output.
Must fields have a minimum number of occurrences, or why is that?
The text was updated successfully, but these errors were encountered: