jq

Parameters:
Name Type Required Default Hint
inputOrFile string true The text to process, or a file name
query string false The command to perform on the input text. Ex: a.b

Command Usage

JSON Query command for filtering data out of a JSON Object, file, or URL. jq is a query language
built specifically for interacting with JSON type data. More information can be found
at https://jmespath.org/ as well as an online version to test your query
Pass or pipe the text to process or a filename

Run query against file

jq myjsonfile.json a.b.c.d
Run query against URL
jq "https://official-joke-api.appspot.com/jokes/ten" [].join('.....',[setup,punchline])
Or against JSON literal
jq '{"a": {"b": {"c": {"d": "value"}}}}' a.b.c.d
Or piped-in data
package list --json | jq name
You can do a basic search for keys in JSON wiht a dot-delimited list of key names.
Consider this sample JSON:
{"foo":{"bar":{"baz":"correct"}}}
The following search filters return the noted results. Note that ".bar" searches in nested structs for a match.
foo -> {"bar":{"baz":"correct"}}

foo.bar -> {"baz":"correct"}
.bar -> {"baz":"correct"}
You can even create a new object out of your filter results using the values from the matched keys.
jq {inner:{foo:'apples',bar:true}} inner.{newKey:foo,bar:bar}

{ "newKey":"apples", "bar":true }
You can filter values. Here we take the arary inside "foo" and filter only the objects where the "age" is greater thgan 25
Note backticks are used for a litearl value, but we need to escape them in our string so the shell doesn't try to evaluate them.
jq '{"foo":[{"age":20},{"age":25},{"age":30}]}' 'foo[?age > \`25\`]'

[ { "age":30 } ]
Check the docs for tons more functionality including
- Filter boolean functions
- Math functions
- Sort function:
- Conversion functions