Cheatsheet Pages / jq Cheatsheet
How to index into and stream JSON arrays with jq
You need the first element, the last one — or every element, one by one.
Every filter was executed against the cheatsheet's sample config.json with jq 1.7 before publishing; the sample file sits at the bottom of the cheatsheet so you can reproduce every output.
jq '.users[0].name' config.json # first user's name -> "ana"
jq '.users[-1].name' config.json # last user's name -> "carla"
jq -r '.users[].name' config.json
# output: ana
# bruno
# carla
