TOOL » LINUX » PACKAGE

Jq

Usage

Command-line JSON processor.

shell
jq OPTIONS FILTER FILE
OptionDescription
-r --raw-outputIf the filter´s result is a string then it will be written directly to standard output.

Filters

FilterDescription
.Identity operator. Takes its input and produces it unchanged as output.
.fooObject Identifier-Index. Takes the value at the key foo from a JSON object (dictionary).
.[2]Array index. Zero-based, negative indices are allowed.

Examples

Pretty-print a JSON.

shell
jq . < file.json

Get a value from a object inside an array.

shell
jq .[0].version < file.json