Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

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.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.