Bash, unfortunately, doesn’t ship with a command that can work with JSON natively. In this lesson, we’ll learn how to read and do basic queries on JSON with jq
, an installable command line tool that makes working with JSON in bash really easy. We'll pipe the JSON output of the Github API to jq to extract values.
Note: jq has to be installed. On macOS, the easiest way to do this is to run brew install jq
. To view install instructions for all platforms, see https://stedolan.github.io/jq/download/.
Hrmm, fails in zsh
echo ['1,2,3'] | jq '.[]'
zsh: no matches found: [1,2,3]
Hrmm, fails in zsh
echo ['1,2,3'] | jq '.[]'
zsh: no matches found: [1,2,3]
It should be echo '[1,2,3]' | jq '.[]'
with the single quotes surrounding the [].
Hrmm, fails in zsh
echo ['1,2,3'] | jq '.[]'
zsh: no matches found: [1,2,3]
It should be echo '[1,2,3]' | jq '.[]'
with the single quotes surrounding the [].
Both work in iTerm2.
I had to wrap the url into the double quotes, I was getting curl -s https://api.github.com/search/repositories?q=service+worker
zsh: no matches found: https://api.github.com/search/repositories?q=service+worker
otherwise