3 ms·
One small but really convenient tip missing from the article is object shortcuts - these two commands are the same: curl -s https://api.github.com/repos/st
by raziel2p 5y ago
One small but really convenient tip missing from the article is object shortcuts - these two commands are the same:
curl -s https://api.github.com/repos/stedolan/jq/issues?per_page=2 | jq '[ .[] | { title: .title, number: .number } ]'
curl -s https://api.github.com/repos/stedolan/jq/issues?per_page=2 | jq '[ .[] | { title, number } ]'
- hk1337 5y agoThe first is nice because it highlights being able to remap the value to different key.
- bewuethr 5y agoNot to distract from your point, but in this specific instance I'd probably use map({title, number}) instead [ .[] | <something> ]
- paulddraper 5y agoSide note, but one of the hardest things about jq is to realize all the operators operate on streams of values. For example, map() operates on a stream of arrays. That kind of doubling of iteration can be confusing at first.