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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -