json - jq display nodes in one line -


so have this:

jq -r '.letters[0].secondary_letters[0] | "\(.name)"' letters.json 

which outputs:

a aa 

i'd them be: a, aa

the json looks like:

  "secondary_letters": [     {       "id": 1,       "name": "a"     },     {       "id": 2,       "name": "aa"     } 

there might more jq command should able extract many sub nodes needed.

can done?

assuming input has been corrected valid json,

jq -r '.secondary_letters | map(.name) | join(", ")' 

produces

a, aa 

the same filter satisfies generality requirement.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -