Hacker News new | ask | show | jobs
by aquassaut 4073 days ago
Yes, kind of like so:

echo '[{"name":"john", "grades":[1,2,3]}, {"name":"jane", "grades":[4,5,6]}]'| jq '.[]| "\(.name), \(.grades|.[])"'

1 comments

Thanks! Now, it looks more interesting...
Based on @aquassaut's answer, I tweaked it a little, and this should do it.

echo '[{"name":"john", "grades":[1,2,3]}, {"name":"jane", "grades":[4,5,6]}]' | jq -r '.[] | "\(.name),\(.grades|.[])"' | paste -sd' ' -