jq
Created: 2018-11-13 15:45:46 -0800 Modified: 2019-10-14 09:52:43 -0700
- You can install this for any OS via their GitHub link.
- JQ is a JSON parser. It’s like XPATH for JSON.
- You can quickly try sample inputs/outputs in their sandbox: https://jqplay.org/
- This is especially helpful because it gives you the command line as output at the bottom.
- To strip the resulting quotation marks from the string, use “—raw-output” or “-r” (reference).
Examples
Section titled ExamplesFetch a sibling value based on the value of a given key (reference)
Section titled Fetch a sibling value based on the value of a given key (reference)Goal: figure out the ListenerArn of the object whose port is 8079 (i.e. get “arn_bar”):
Final query: .Listeners[] | select(.Port == 8079) | .ListenerArn