-
Notifications
You must be signed in to change notification settings - Fork 113
Closed
Description
Some systems won't accept json as an input. I've tried several json-to-csv tools and none of then handle nested json arrays in a meaningful manner, creating rows only for the first level instead of doing it bottom-to-top. Consider:
Input:
An array with an arbitrary number of elements that in turn can have and arbitrary number of arrays, recursively.
{
"trees": [
{
"id": 1,
"name": "tree1",
"branches": [
{
"id": 1,
"name": "branch1",
"leaves": [
{
"id": 1,
"name": "leave1"
},
{
"id": 2,
"name": "leave2"
}
]
},
{
"id": 2,
"name": "branch2",
"leaves": [
{
"id": 1,
"name": "leave1"
},
{
"id": 2,
"name": "leave2"
}
]
}
]
}
]
}
Output:
Each leave becomes a csv row with all it's ancestor's fields. The example above would result in four rows with the following fields:
- leaves.id
- leaves.name
- branchs.id
- branchs.name
- trees.id
- trees.name
Caveat:
It may be necessary to limit the allowed tree's depth to preserve resources.
Metadata
Metadata
Assignees
Labels
No labels