jq
CLI>=1.6Lightweight and flexible command-line JSON processor.
8 views
Installation
Homebrew
brew install jqapt
sudo apt install jqLinks
License
MITAI Agent Notes
Query and transform JSON on the command line
When to use
Parsing API responses, transforming JSON data, extracting fields
Examples
echo '{}' | jq '.key'cat data.json | jq '.[] | .name'
Proven Recipes
Extract a field from JSON🟢 98% success
cat data.json | jq '.fieldName'Filter array by condition🟢 95% success
cat data.json | jq '.[] | select(.age > 30)'⚠ Common failures (1)
- null output → Check that input is an array with .[] not just .
Extract nested field🟢 97% success
cat data.json | jq '.user.address.city'⚠ Common failures (1)
- null → Use jq -e to exit non-zero on null, verify key names with jq 'keys'
Pretty-print JSON from API response🟢 99% success
curl -s https://api.example.com/data | jq '.'