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 |
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.dRun 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.dOr piped-in data
package list --json | jq nameYou can do a basic search for keys in JSON wiht a dot-delimited list of key names.
{"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"}}You can even create a new object out of your filter results using the values from the matched keys.
foo.bar -> {"baz":"correct"}
.bar -> {"baz":"correct"}
jq {inner:{foo:'apples',bar:true}} inner.{newKey:foo,bar:bar}You can filter values. Here we take the arary inside "foo" and filter only the objects where the "age" is greater thgan 25
{ "newKey":"apples", "bar":true }
jq '{"foo":[{"age":20},{"age":25},{"age":30}]}' 'foo[?age > \`25\`]'Check the docs for tons more functionality including
[ { "age":30 } ]