Fill these in once
- Install jq
brew install jq - Get one field
jq '.name' data.json - Get that field from every item in a list
jq '.[].name' data.jsonUse this when the file starts with [ rather than {.
- Print it without quotes
jq -r '.[].name' data.json-r gives plain text, handy for passing on to other commands.
- Count the items in a list
jq 'length' data.json - Use it on an API reply
curl -s https://api.github.com/repos/jqlang/jq | jq '.stargazers_count'
Undo it
- Uninstall jq
brew uninstall jq
- Install jqNeeds sudo
sudo apt install -y jq - Get one field
jq '.name' data.json - Get that field from every item in a list
jq '.[].name' data.jsonUse this when the file starts with [ rather than {.
- Print it without quotes
jq -r '.[].name' data.json-r gives plain text, handy for passing on to other commands.
- Count the items in a list
jq 'length' data.json - Use it on an API reply
curl -s https://api.github.com/repos/jqlang/jq | jq '.stargazers_count'
Undo it
- Uninstall jqNeeds sudo
sudo apt remove -y jq
- Install jq
winget install jqlang.jqClose and reopen PowerShell afterwards.
- Get one field
jq '.name' data.json - Get that field from every item in a list
jq '.[].name' data.jsonUse this when the file starts with [ rather than {.
- Print it without quotes
jq -r '.[].name' data.json - Count the items in a list
jq 'length' data.json - Use it on an API reply
curl.exe -s https://api.github.com/repos/jqlang/jq | jq '.stargazers_count'
Undo it
- Uninstall jq
winget uninstall jqlang.jq

New to JSON? I explain it in plain English on Layman Terms.