I have a json file, which is stored in an environment variable temp.
{
"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"
}
]
}
When i am converting this JSON into CSV using this command
jq -r '.users[] | [.username, .email, .total running apps, .api-mock-app, .flogo, .ipaas, .nodejs-app] | @csv' <<< $temp
I am getting following error.
jq: error: syntax error, unexpected IDENT (Unix shell quoting issues?) at , line 1:
.users[] | [.username, .email, .total running apps, .api-mock-app, .flogo, .ipaas, .nodejs-app] | @csv
jq: 1 compile error
Any help Please?
You need to quote your column names, especially since they contain spaces and dashes. However you need to escape the quotes for bash:
i got this working code click here
check out this link