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
Would like to use dasel to convert from JSON to CSV, when the JSON file has nested arrays, and without specifying field names in the dasel expression, so that it will work on any JSON file with the same nested array format.
... I end up with something like this (converted using jq):
"array1.0.Key","array1.0.Value","array1.1.Key","array1.1.Value","string1","string2"
"a",1,"b",2,"abc","123"
"c",3,"d",4,"def","456"
The above 2 elements have the same keys, but ideally dasel would collect the unique keys across all elements of the array when generating the CSV header row. Either lexically sorting the unique keys, as in the example above, or building the header in found order of unique keys is fine, whichever is easier.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Would like to use dasel to convert from JSON to CSV, when the JSON file has nested arrays, and without specifying field names in the dasel expression, so that it will work on any JSON file with the same nested array format.
for example, starting with this array:
[
{
"string1": "abc",
"string2": "123",
"array1": [
{
"Key": "a",
"Value": 1
},
{
"Key": "b",
"Value": 2
}
]
},
{
"string1": "def",
"string2": "456",
"array1": [
{
"Key": "c",
"Value": 3
},
{
"Key": "d",
"Value": 4
}
]
}
]
... I end up with something like this (converted using jq):
"array1.0.Key","array1.0.Value","array1.1.Key","array1.1.Value","string1","string2"
"a",1,"b",2,"abc","123"
"c",3,"d",4,"def","456"
The above 2 elements have the same keys, but ideally dasel would collect the unique keys across all elements of the array when generating the CSV header row. Either lexically sorting the unique keys, as in the example above, or building the header in found order of unique keys is fine, whichever is easier.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions