↳
In-reply-to
»
@lyse gron does something very similar with JSON. I used to use it more, but these days I just reach for jq instead.
⤋ Read More
@lyse@lyse.isobeef.org The thing that really unlocked jq for me was learning how to get a TSV output. That was a complete game changer, because it meant I could easily use it in a shell pipeline. I found it to be better than gron for that purpose. Just make an array for each item containing all the values you need and pipe it to the filter @tsv
.
$ # Search YouTube using the Invidious API for "never gonna give you up" and write the results to out.json
$ curl -sGL -A 'Mozilla/5.0 (Linux; x86_64) Ladybird/1.0' -o out.json --data-urlencode 'q=never gonna give you up' 'https://farside.link/invidious/api/v1/search'
$ jq -r '.[] | select(.type == "video") | [ .title, .author, .authorVerified, .videoId ] | @tsv' out.json
Rick Astley - Never Gonna Give You Up (Official Music Video) Rick Astley true dQw4w9WgXcQ
Rick Astley - Never Gonna Give You Up [Lyrics] GlyphoricVibes true QdezFxHfatw
InsurAAAnce & Rick Astley Never Gonna Give You Up CSAA Insurance Group, a AAA Insurer true GtL1huin9EE
[...]