doc/presentations/bts2022/jq2
raw| 1 | # Pipeline using pipe operator "|" and identity function "." for current input |
| 2 | > "hello" | length | . * 2 |
| 3 | 10 |
| 4 | |
| 5 | # Multiple outputs using output operator "," |
| 6 | > 1, 2 | . * 2 |
| 7 | 2 |
| 8 | 4 |
| 9 | |
| 10 | # Index array or object using .[key/index] or just .key for objects |
| 11 | > [1,2,3][1] |
| 12 | 2 |
| 13 | |
| 14 | # Collect outputs into array using [...] |
| 15 | > [1,empty,2] |
| 16 | [1,2] |
| 17 | |
| 18 | # Iterate array or object using .[] |
| 19 | > [[1,2,3][]] |
| 20 | [1,2,3] |