select
The function select(foo) produces its input unchanged if foo returns true for that input, and produces no output otherwise.
It’s useful for filtering lists: [1,2,3] | select(. >= 2) will give you [3].
| jq 'select(. >= 2)' | |
| Input | [1,5,3,0,7] |
| Output | + +[5,3,7] | +
empty
empty returns no results. None at all. Not even null.
It’s useful on occasion. You’ll know if you need it :)
+ + +| jq '1, empty, 2' | |
| Input | null |
| Output | + +12 | +
| jq '[1,2,empty,3]' | |
| Input | null |
| Output | + +[1,2,3] | +
map(x)