I have JSON file called temp.json.
{
"users": [
{
"username": "jack",
"email": "jack@somewhere.com",
"total running apps": "1",
"api-mock-app": "0",
"flogo": "1",
"ipaas": "0",
"nodejs-app": "0"
},
{
"username": "jill",
"email": "jill@somewhere.com",
"total running apps": "1",
"api-mock-app": "0",
"flogo": "1",
"ipaas": "0",
"nodejs-app": "0"
}
]
}
i want to convert this JSON into CSV lilke this,
username email total running apps api-mock-app flogo ipaas nodejs-app
jack jack@somewhere.com 1 0 1 0 0
jill jill@somewhere.com 1 0 1 0 0
I tried this
jq -r '.users[] | keys[0] [.username, .email, ."total running apps", ."api-mock-app", .flogo, .ipaas, ."nodejs-app"] | join(", ") | @csv' temp.json`
But i am getting error
q: error (at temp.json:22): Cannot index string with string "jack"`
Can anyone explain where am i making mistake and please let me know the correct answer.