I am trying to use jq
to join the values inside a JSON array into a single line comma separated list. (Without trailing comma)
{
"hardware": [
"abc",
"def",
"ghi"
]
}
To create "abc, def, ghi"
I can join values together using
jq -jr '(.hardware[])' input.json
abcdefghi
I have tried to insert comma and space but cannot work
jq -jr '(.hardware[]|join(", ")'
jq: error: syntax error, unexpected $end (Unix shell quoting issues?) at <top-level>, line 1:
(.hardware[]|join(", ")
Could someone point me to the correct syntax to use?
Thanks
Densha