You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On my second read of the manpage I realized that --keys is probably getting close to what I need. But still I cannot achieve my desired goal. I'm doing something wrong it seems:
$ json2csv example.json --keys people
people
"[{""firstname"":""Jon"",""lastname"":""Doe"",""birthday"":""1978-02-19"",""gender"":""m""},{""firstname"":""Jane"",""lastname"":""Doe"",""birthday"":""1982-04-21"",""gender"":""f""},{""firstname"":""Dave"",""lastname"":""Meyer"",""birthday"":""1964-12-03"",""gender"":""m""}]"
All in one line
On first glance seems not to be CSV but somehow "wrongly/strangely escaped JSON"
$ json2csv example.json --keys people --unwind-arrays
people
"{""firstname"":""Jon"",""lastname"":""Doe"",""birthday"":""1978-02-19"",""gender"":""m""}""{""firstname"":""Jane"",""lastname"":""Doe"",""birthday"":""1982-04-21"",""gender"":""f""}""{""firstname"":""Dave"",""lastname"":""Meyer"",""birthday"":""1964-12-03"",""gender"":""m""}"
Managed to get 1 record per row
But still this ain't CSV and there ain't the intended headers.
Possibly that flag is not intended for my desired goal, as the "people" on top indicates this indeed is a CSV but with only a single column, and per each column it has a JSON with all it's attributes escaped.
So yes, I'm out of wits. Looking forward to your reaction!
Foreword
User Story
From a large JSON file containing a lot of stuff I want the option to select only a particular object for export to CSV.
With a syntax like
--select "path.to.object"
Or another argument name you deem appropriate as the mnemonics
-s
and-S
are both already taken.Given example.json
To get
people.csv
I'd run…which results in:
To get
locations-asia.csv
I'd runwhich results in:
The text was updated successfully, but these errors were encountered: