Select Elements
I’m going to use jq to filter the data returned by the GitHub repository API. The data I get back by default looks like this:
jq lets us treat the JSON document as an object and select elements inside of it.
Here is how I filter the JSON document to select the value of the name key:
Similarly, for selecting the value of the owner key:
You can drill in as far as you want like this:
What I Learned: Object Identifier-Index:
jq lets you select elements in a JSON document like it’s a JavaScript object. Just start with . (for the whole document) and drill down to the value you want. It ends up looking something like this:
jq '.key.subkey.subsubkey'