Closed kanibs closed 2 years ago
hey @juanjoDiaz can you please help me out here?
Hi,
Sorry for the late response. I'm quite busy at the moment and won't be able to spend time on this for at least a couple of weeks.
A couple of things at glance:
You are missing a space in front of the -o
:
json2csv -i unsupported_json.json --unwind visits.23andme.com,visits.23andme.com.visits -f visits.23andme.com.source_type,visits.23andme.com.visits.date,visits.23andme.com.visits.organic,visits.23andme.com.visits.paid -o traffic.csv
Having a field named 23andme.com
is problematic.
When you unwind on visits.23andme.com
, json2csv tries to unwind a field named com
in the field named 23andme
in the object named visits
. This is:
{
"visits": {
"23andme": {
"com": [/* object to unwind */]
}
}
}
You can solved this using the programatic API:
const opts = {
transforms: [unwind({ paths: [["visits", "23andme.com"], ["visits", "23andme.com", "visits"]] })]
};
but you won't be able to work around this using the CLI.
The same thing applies to the fields and the -f
option of the CLI.
Hope this helps! 🙂
Thanks @juanjoDiaz for finding some time to respond.
This was helpful to get the confirmation and also a workaround which is via programmatic API.
Hi, I am trying to parse a JSON(given below) using the command line but I do not get the result and indeed the same JSON getting printed. Need some help here if this is possible to parse the given JSON using json2csv and if so, what would be the correct command to do so?
The command I am trying to do this is:
I am mostly interested in the
visits
element of the JSON and need to unwind thevisits.23andme.com.visits
for eachsource_type
, i.e there should be two rows in this example for eachsource_type
Thanks.