evidens/json2csv

outside of collection array

chrism91 opened this issue · 3 comments

how would I add a single key locator for something that is outside of the specified array? (i.e. something outside of what I define as the "collection"?)

I want to pull something in a json object above the hierarchy of the collection "object" that I pointed at.

or, as another solution to the issue, how would I define "collection" as the root of the json document?

What happens if you omit the collection specifier? That should iterate over a root-level array. Essentially the iterator needs to point at an array (otherwise there are no repeating patterns to match)

It really depends on the data structure you're working with. There are a few scenarios this script can already handle:

  1. A single root-level array where each element is an object that is then converted to a CSV row
  2. A JSON object with a collection element you want to iterate over. Collection behaves as the array in 1.
  3. A number of JSON objects at the root (the format that Mongo outputs by default)

If you're looking to iterate over a collection while repeating some data outside the collection, that's not a feature anyone's implemented yet.

If you need further assistance it would help to have a sample of the data you're trying to transform.

No feedback received from the issue creator so I'm closing this ticket.