Select Arrays
If you curl the GitHub Issues API, you will get back an array of issues:
To get a specific element in the array, give jq an index:
Side Note: Array Indexing in jq:
Array indexing has some helpful convenience syntax.
You can select ranges:
You can select one sided ranges:
Also, you can use negatives to select from the end:
You can use the array index with the object index:
And you can use [] to get all the elements in the array. For example, here is how I would get the titles of the issues returned by my API request:
What I Learned: Array-Index:
jq lets you select the whole array [], a specific element [3], or ranges [2:5] and combine these with the object index if needed.
It ends up looking something like this:
jq '.key[].subkey[2]'Side Note: Removing Quotes From JQ Output:
The -r option in jq gives you raw strings if you need that.
The -j option (for join) can combine together your output.