I am trying to get jq to render a json object into tsv format. I came across a way to generate headers dynamically using the key name.
I am getting this error:
object ({"version":...) is not valid in a csv row
I am guessing this is due to some fields being arrays: Installed
and Latest
. How can I make this work with those fields? Also, why is my output including \t
?
Current Output:
"RELEASE\tINSTALLED\tLATEST\tOUTDATED\tDEPRECATED"
jq: error (at <stdin>:28): object ({"version":...) is not valid in a csv row
Desired output:
RELEASE INSTALLED LATEST OUTDATED DEPRACATED
test-app 1.0.0 2.0.0 true false
test-app2 3.0.0 3.5.0 true false
jq
cat test1.json | jq '[.[]| with_entries( .key |= ascii_upcase ) ] | (.[0] |keys_unsorted | @tsv), (.[]|.|map(.) |@tsv)'
json:
[
{
"release": "test-app",
"Installed": {
"version": "1.0.0",
"appVersion": ""
},
"Latest": {
"version": "2.0.0",
"appVersion": ""
},
"outdated": true,
"deprecated": false
},
{
"release": "test-app2",
"Installed": {
"version": "3.0.0",
"appVersion": ""
},
"Latest": {
"version": "3.5.0",
"appVersion": ""
},
"outdated": true,
"deprecated": false
}
]