| --version| Output the jq version and exit with zero. | |--sort-keys | Output the fields of each object with the keys in sorted order.|
| , | If two filters are separated by a comma, then the input will be fed into both and there will be multiple outputs | | ? | Ignores error if unexpected type | | [] | Arrya construction | | {} | Object construction | | + | concatenate or add | | - | difference of set or substract | | length | size of selected element |
| Keys | jq 'keys' | | Adds + 1 to all items | jq 'map_values(.+1)' | | Delete key| jq 'del(.foo)' |
|| Action || Command || | All | jq .[] | | First | jq '.[0]' | | Range | jq '.[2:4]' | | First 3 | jq '.[:3]' | | Last 2 | jq '.[-2:]' | | Before Last | jq '.[-2]'| | Add + 1 to all items | jq 'map(.+1)' | | Delete 2 items| jq 'del(.[1, 2])' | | Select array of objects | jq '.[] | select(.id == "second")' | | Select array of int | jq 'map(select(. >= 2))' | | Select by type | jq '.[]|numbers' or arrays, objects, iterables, booleans, numbers, normals, finites, strings, nulls, values, scalars | | Concatenate array | jq 'add' | | Flatten an array | jq 'flatten' | | Create a range of number | jq '[range(2;4)]' | | Display type of each item| jq 'map(type)' | | Sort an array of basic type| jq 'sort' | | Sorts an array of objects | jq 'sort_by(.foo)' | | Group by a key - opposite to flatten | jq 'group_by(.foo)' | | Minimun of an array| jq 'min' .See also min, max, min_by(path_exp), max_by(path_exp) | | Removes duplicates| jq 'unique' ; jq 'unique_by(.foo)'; jq 'unique_by(length)' | | Reverse an array | jq 'reverse' |