JEEP is a small command line utility for processing JSON text.
It provides, filtering, sorting, plucking fields, etc. It was created to be
used when making API calls with curl
that return JSON.
Quick examples:
Update: Pull requests default to Open by default so this example is not the best, but you ge the idea. I'll update this soon hopefully, maybe, probably not.
# Get all tag names for rails repository
curl https://api.github.com/repos/rails/rails/tags | jeep -p "name"
# Get count of tag names for rails repository
curl https://api.github.com/repos/rails/rails/tags | jeep -c
# Get all open pull requests
curl https://api.github.com/repos/rails/rails/pulls | jeep -w '{state: "Open"}'
# Get count of all open pull requests
curl https://api.github.com/repos/rails/rails/pulls | jeep -w '{state: "Open"}' -c
npm install -g jeep-cli
Most arguments can be combined. For example you can filter, sort and return the first item remaining. Or filter the data and get the count of the remaining items.
echo '["John","Steve"]' | jeep -c # returns 2
echo '["John,"Steve"]' | jeep -f # returns "John"
# Returns ["id","name","email"]
echo '{"id": 1, "name": "John", email: "[email protected]"}' | jeep -k
echo '["John,"Steve"]' | jeep -l # returns "Steve"
Pluck can be be a single property or a comma separated list of properties
# returns ["john","steve"]
echo '[{"name":"john","id":1},{"name":"steve","id":2}]' | jeep -p "name"
# returns title and status of all pull requests
curl https://api.github.com/repos/rails/rails/pulls | jeep -p "title,status"
# Returns array sorted by id in ascending order
echo '[{id:5},{id:7},{id:3}]' | jeep -s "id"
# Returns array sorted by id in descending order
echo '[{id:5},{id:7},{id:3}]' | jeep -S "id"
# Filters records by 'Open' state
curl https://api.github.com/repos/rails/rails/pulls | jeep -w '{state:"Open"}'
jeep -h # View help (-h or --help)
jeep -v # View version (-V or --version)
Right now I just use the awesome pjson tool for this.
curl https://api.github.com/repos/rails/rails/pulls | jeep -s "title" | pjson
Json Eliminater, Editor and Processor...ok that's not really true. I just wanted a three or four letter name that started with J. And all the good ones are taken of course...
Copyright (c) Craig MacGregor 2015 under MIT LICENSE