Reputation: 196
My json like this from the command like curl https://sm.ms/api/upload
:
{
"code": "error",
"msg": "No files were uploaded."
}
Now I want to get a text like this (all values of this json):
"error", "No files were uploaded."
I use the command curl https://sm.ms/api/upload | jq -r .
but I can only get the json content. The document seems like not to support this funtion.
I search for the web for a long time but there's nothing helpful, so I hope you can help me and thank you~
Upvotes: 2
Views: 5597
Reputation: 116640
You might like to consider a generic solution:
jq -r '[.[]] | @csv'
Upvotes: 2
Reputation: 10304
The output can be formatted as csv by using the --raw-output
option:
jq --raw-output '"\"\(.code)\", \"\(.msg)\""'
Upvotes: 4