JQ(1) JQ(1) (NAME) jq - JSON (SYNOPSIS) jq [...] [...] jq JSON JSON . jq 'map(.price) | add' JSON "price" . jq JSON ( ) stdin . 1 2 true false . jq . (options) [INVOKING JQ] . (filter) jq . (FILTERS) jq <<>> : . . - . . . jq . . "hello" 42 - . . add / length - add length . . :) : JQ (INVOKING JQ) jq JSON . jq JSON . () JSON . ( jq) . jq . jq JSON (pretty-print) . . jq . : . jq ( ) jq . jq "foo" jq foo foo is not defined . (cmd.exe) jq ( -f program-file) jq . (powershell.exe) (pwsh/pwsh.exe) jq (\") jq . o : jq '.["foo"]' o : jq '.[\"foo\"]' o : jq ".[\"foo\"]" : jq jq (top-level) . jq : --null-input / -n: . null . jq JSON . --raw-input / -R: JSON . . --slurp . --slurp / -s: JSON . --compact-output / -c: jq JSON . JSON . --raw-output / -r: JSON . jq JSON . --raw-output0: -r jq NUL . . NUL jq . --join-output / -j: -r jq . --ascii-output / -a: jq ASCII UTF-8 ( "\u03bc") . jq ASCII ASCII . --sort-keys / -S: . --color-output / -C and --monochrome-output / -M: jq JSON . -C -M . NO_COLOR jq -C . JQ_COLORS ( ). --tab: . --indent n: ( 7) . --unbuffered: JSON (flush) ( jq jq ). --stream: ( ) . "a" [[],"a"] [[],"a",["b"]] [[0],[]] [[1],"a"] [[2,0],"b"] . . reduce foreach . --stream-errors: --stream JSON . ["a",n] ["Invalid literal at line 1, column 7",[1]] . --stream . JSON --stream --stream-errors . --seq: application/json-seq JSON jq . (RS) (LF) . JSON ( ) RS . jq --seq . -f / --from-file: -f awk . . -L directory / --library-path directory: directory . . . --arg name value: jq . jq --arg foo bar $foo "bar" . value --arg foo 123 $foo "123" . $ARGS.named jq . . --argjson name JSON-text: JSON jq . jq --argjson foo 123 $foo 123 . --slurpfile variable-name filename: JSON JSON . jq --slurpfile foo bar $foo bar . --rawfile variable-name filename: . jq --rawfile foo bar $foo bar . --args: . $ARGS.positional[] jq . --jsonargs: JSON . $ARGS.positional[] jq . --exit-status / -e: jq 0 false null 1 false null 4 . jq 2 jq 3 jq 0 . halt_error . --binary / -b: WSL MSYS2 Cygwin jq.exe jq (LF) (CRLF) . --version / -V: jq . --build-configuration: jq . . --help / -h: jq . --: . . --run-tests [filename]: . . ( ) . %%FAIL . . (BASIC FILTERS) : . . . . jq . JSON curl . jq . jq : 1E1234567890 | . 1.7976931348623157e+308 . jq IEEE754 . jq JSON . jq . jq : (1) IEEE754 IEEE754 . (2) jq ( --disable-decnum ) 1E1234567890 . (3) . have_decnum --disable-decnum . jq '.' "Hello, world!" => "Hello, world!" jq '.' 0.12345678901234567890123456789 => 0.12345678901234567890123456789 jq '[., tojson] == if have_decnum then [12345678909876543212345,"12345678909876543212345"] else [12345678909876543000000,"12345678909876543000000"] end' 12345678909876543212345 => true jq '[1234567890987654321,-1234567890987654321 | tojson] == if have_decnum then ["1234567890987654321","-1234567890987654321"] else ["1234567890987654400","-1234567890987654400"] end' null => true jq '. < 0.12345678901234567890123456788' 0.12345678901234567890123456789 => false jq 'map([., . == 1]) | tojson == if have_decnum then "[[1,true],[1.000,true],[1.0,true],[1.00,true]]" else "[[1,true],[1,true],[1,true],[1,true]]" end' [1, 1.000, 1.0, 100e-2] => true jq '. as $big | [$big, $big + 1] | map(. > 10000000000000000000000000000000) | . == if have_decnum then [true, false] else [false, false] end' 10000000000000000000000000000001 => true - : .foo, .foo.bar .foo . JSON ( ) .foo "foo" null . .foo.bar .foo | .bar . .foo - . ."foo$" .["foo$"] . .["foo::bar"] .["foo.bar"] .foo::bar . jq '.foo' {"foo": 42, "bar": "less interesting data"} => 42 jq '.foo' {"notfoo": true, "alsonotfoo": false} => null jq '.["foo"]' {"foo": 42} => 42 / : .foo? .foo . . jq '.foo?' {"foo": 42, "bar": "less interesting data"} => 42 jq '.foo?' {"notfoo": true, "alsonotfoo": false} => null jq '.["foo"]?' {"foo": 42} => 42 jq '[.foo?]' [1,2] => [] : .[] .["foo"] (.foo ). : .[] .[] . .[2] . -1 -2 . jq '.[0]' [{"name":"JSON", "good":true}, {"name":"XML", "good":false}] => {"name":"JSON", "good":true} jq '.[2]' [{"name":"JSON", "good":true}, {"name":"XML", "good":false}] => null jq '.[-2]' [1,2,3] => 2 /: .[:] .[:] . .[10:15] ( ) ( ) . ( ) ( ). . jq '.[2:4]' ["a","b","c","d","e"] => ["c", "d"] jq '.[2:4]' "abcdefghi" => "cd" jq '.[:3]' ["a","b","c","d","e"] => ["a", "b", "c"] jq '.[-2:]' ["a","b","c","d","e"] => ["d", "e"] /: .[] .[index] . .[] [1,2,3] . .foo[] .foo | .[] . . . jq '.[]' [{"name":"JSON", "good":true}, {"name":"XML", "good":false}] => {"name":"JSON", "good":true}, {"name":"XML", "good":false} jq '.[]' [] => jq '.foo[]' {"foo":[1,2,3]} => 1, 2, 3 jq '.[]' {"a": 1, "b": 1} => 1, 1 .[]? .[] . . .foo[]? .foo | .[]? . : , : . .foo, .bar "foo" "bar" . , . jq '.foo, .bar' {"foo": 42, "bar": "something else", "baz": true} => 42, "something else" jq '.user, .projects[]' {"user":"stedolan", "projects": ["jq", "wikiflow"]} => "stedolan", "jq", "wikiflow" jq '.[4,2]' ["a","b","c","d","e"] => "e", "c" : | | () . (Pipe) . . .[] | .foo "foo" . . .a.b.c .a | .b | .c . . << >> : . . .a | . | .b .a.b . .a . jq '.[] | .name' [{"name":"JSON", "good":true}, {"name":"XML", "good":false}] => "JSON", "XML" (Parenthesis) . jq '(. + 2) * 5' 1 => 15 (TYPES AND VALUES) jq JSON - ( JSON ) "null". null JSON . jq - 42 jq 42 . jq IEEE754 . . jq . . : [] JSON [] [1,2,3]. jq . . ( [.foo, .bar, .baz]) <<>> ( [.items[].name]) . "," jq : [1,2,3] [] ( ) 1,2,3 ( ) . X [X] . jq '[.user, .projects[]]' {"user":"stedolan", "projects": ["jq", "wikiflow"]} => ["stedolan", "jq", "wikiflow"] jq '[ .[] | . * 2]' [1, 2, 3] => [2, 4, 6] : {} JSON {} ( ) : {"a": 42, "b": 17}. <<>> {a:42, b:17}. . : {("a"+"b"):59}. ( ) {} ( ). {foo: .bar} JSON {"bar":42, "baz":43} JSON {"foo": 42} . : "user" "title" "id" "content" "user" "title" {user: .user, title: .title} : {user, title}. . {"user":"stedolan","titles":["JQ Primer", "More JQ"]} {user, title: .titles[]} : {"user":"stedolan", "title": "JQ Primer"} {"user":"stedolan", "title": "More JQ"} . {(.user): .titles} {"stedolan": ["JQ Primer", "More JQ"]} . "f o o" as $foo | "b a r" as $bar | {$foo, $bar:$foo} : {"foo":"f o o","b a r":"f o o"} jq '{user, title: .titles[]}' {"user":"stedolan","titles":["JQ Primer", "More JQ"]} => {"user":"stedolan", "title": "JQ Primer"}, {"user":"stedolan", "title": "More JQ"} jq '{(.user): .titles}' {"user":"stedolan","titles":["JQ Primer", "More JQ"]} => {"stedolan": ["JQ Primer", "More JQ"]} : .. . . recurse ( ). // XPath . ..a .. | .a . .. | .a? "a" "" . . path(EXP) ( ) ? . jq '.. | .a?' [[{"a":1}]] => 1 (BUILTIN OPERATORS AND FUNCTIONS) jq ( +) ( ) . jq (implicit type conversion) . . IEEE754 . . . . . IEEE754 (truncate) . : + + . " " : o . o . o . o - . + . ( * .) null . jq '.a + 1' {"a": 7} => 8 jq '.a + .b' {"a": [1,2], "b": [3,4]} => [1,2,3,4] jq '.a + null' {"a": 1} => 1 jq '.a + 1' {} => 1 jq '{a: 1} + {b: 2} + {c: 3} + {a: 42}' null => {"a": 42, "b": 2, "c": 3} : - - . jq '4 - .a' {"a":3} => 1 jq '. - ["xml", "yaml"]' ["xml", "yaml", "json"] => ["json"] : *, /, % (infix) . . x % y x y . . "x" * 0 "" . . : . jq '10 / . * 3' 5 => 6 jq '. / ", "' "a, b,c,d, e" => ["a","b,c,d","e"] jq '{"k": {"a": 1, "b": 2}} * {"k": {"a": 0,"c": 3}}' null => {"k": {"a": 0, "b": 2, "c": 3}} jq '.[] | (1 / .)?' [1,0,-1] => 1, -1 abs abs : if . < 0 then - . else . end. ( ) . . fabs . jq 'map(abs)' [-10, -1.1, -1e-1] => [10,1.1,1e-1] length length : o (codepoints) ( ASCII JSON ). o ( ) . o . o - . o null . o length (boolean) . jq '.[] | length' [[1,2], "string", {"a":2}, null, -5] => 2, 6, 1, 0, 5 utf8bytelength utf8bytelength UTF-8 . jq 'utf8bytelength' "\u03bc" => 2 keys, keys_unsorted keys . "" . (locale) . keys : 0 length-1. keys_unsorted keys . jq 'keys' {"abc": 1, "abcd": 2, "Foo": 3} => ["Foo", "abc", "abcd"] jq 'keys' [42,3,35] => [0,1,2] has(key) has . has($key) $key keys has . jq 'map(has("foo"))' [{"foo": 42}, {}] => [true, false] jq 'map(has(2))' [[0,1], ["a","b","c"]] => [false, true] in in . has . jq '.[] | in({"foo": 42})' ["foo", "bar"] => true, false jq 'map(in([0,1]))' [2, 0] => [false, true] map(f), map_values(f) f map(f) map_values(f) f .[] . map(f) map_values(f) . map_values(f) f . map(f) map_values(f) ($x|f) $x map_values(f) first($x|f) . map_values(f) first(.[$k]|f) $k . $k . map map_values . [1] : map(.+1) #=> [2] map(., .) #=> [1,1] map(empty) #=> [] map_values(.+1) #=> [2] map_values(., .) #=> [1] map_values(empty) #=> [] map(f) [.[] | f] map_values(f) .[] |= f . . jq 'map(.+1)' [1,2,3] => [2,3,4] jq 'map_values(.+1)' {"a": 1, "b": 2, "c": 3} => {"a": 2, "b": 3, "c": 4} jq 'map(., .)' [1,2] => [1,1,2,2] jq 'map_values(. // empty)' {"a": null, "b": true, "c": false} => {"b":true} pick(pathexps) () p (. | p) (. | pick(pathexps) | p) . .[m:n] . jq 'pick(.a, .b.c, .x)' {"a": 1, "b": {"c": 2, "d": 3}, "e": 4} => {"a":1,"b":{"c":2},"x":null} jq 'pick(.[2], .[0], .[0])' [1,2,3,4] => [1,null,3] path(path_expression) . . ( ) / ( ) . jq .a .[] . : . .a.b.c .a[].b . path(exact_path_expression) . . null . path(pattern) . pattern . . path(..|select(type=="boolean")) . . jq 'path(.a[0].b)' null => ["a",0,"b"] jq '[path(..)]' {"a":[{"b":1}]} => [[],["a"],["a",0],["a",0,"b"]] del(path_expression) del . jq 'del(.foo)' {"foo": 42, "bar": 9001, "baz": 42} => {"bar": 9001, "baz": 42} jq 'del(.[1, 2])' ["foo", "bar", "baz"] => ["foo"] getpath(PATHS) getpath . PATHS . jq 'getpath(["a","b"])' null => null jq '[getpath(["a","b"], ["a","c"])]' {"a":{"b":0, "c":1}} => [0, 1] setpath(PATHS; VALUE) setpath PATHS . VALUE . jq 'setpath(["a","b"]; 1)' null => {"a": {"b": 1}} jq 'setpath(["a","b"]; 1)' {"a":{"b":0}} => {"a": {"b": 1}} jq 'setpath([0,"a"]; 1)' null => [{"a":1}] delpaths(PATHS) delpaths PATHS . . PATHS . jq 'delpaths([["a","b"]])' {"a":{"b":1},"x":{"y":2}} => {"a":{},"x":{"y":2}} to_entries, from_entries, with_entries(f) - . to_entries k: v {"key": k, "value": v} . from_entries with_entries(f) to_entries | map(f) | from_entries . from_entries "key" "Key" "name" "Name" "value" "Value" . jq 'to_entries' {"a": 1, "b": 2} => [{"key":"a", "value":1}, {"key":"b", "value":2}] jq 'from_entries' [{"key":"a", "value":1}, {"key":"b", "value":2}] => {"a": 1, "b": 2} jq 'with_entries(.key |= "KEY_" + .)' {"a": 1, "b": 2} => {"KEY_a": 1, "KEY_b": 2} select(boolean_expression) select(f) f true . : [1,2,3] | map(select(. >= 2)) [2,3] . jq 'map(select(. >= 2))' [1,5,3,0,7] => [5,3,7] jq '.[] | select(.id == "second")' [{"id": "first", "val": 1}, {"id": "second", "val": 2}] => {"id": "second", "val": 2} arrays, objects, iterables, booleans, numbers, normals, finites, strings, nulls, values, scalars ( ) (normal numbers) (finite numbers) null -null . jq '.[]|numbers' [[],{},1,"foo",null,true,false] => 1 empty empty . . null . . :) jq '1, empty, 2' null => 1, 2 jq '[1,2,empty,3]' null => [1,2,3] error, error(message) . try/catch . jq 'try error catch .' "error message" => "error message" jq 'try error("invalid value: \(.)") catch .' 42 => "invalid value: 42" halt jq . jq 0 . halt_error, halt_error(exit_code) jq . stderr ( ) . exit_code ( 5) jq . "Error: something went wrong\n"|halt_error(1). $__loc__ "file" "line" $__loc__ . jq 'try error("\($__loc__)") catch .' null => "{\"file\":\"\",\"line\":1}" paths, paths(node_filter) paths ( . ). paths(f) f true . paths(type == "number") . jq '[paths]' [1,[[],{"a":2}]] => [[0],[1],[1,0],[1,1],[1,1,"a"]] jq '[paths(type == "number")]' [1,[[],{"a":2}]] => [[0],[1,1,"a"]] add, add(generator) add . - + ( ) . add null . add(generator) (generator) . jq 'add' ["a","b","c"] => "abc" jq 'add' [1, 2, 3] => 6 jq 'add' [] => null jq 'add(.[].a)' [{"a":3}, {"a":5}, {"b":6}] => 8 any, any(condition), any(generator; condition) any true true . any false . any(condition) . any(generator; condition) . jq 'any' [true, false] => true jq 'any' [false, false] => false jq 'any' [] => false all, all(condition), all(generator; condition) all true true . all(condition) . all(generator; condition) generator . all true . jq 'all' [true, false] => false jq 'all' [true, true] => true jq 'all' [] => true flatten, flatten(depth) flatten . . flatten(2) flatten . jq 'flatten' [1, [2], [[3]]] => [1, 2, 3] jq 'flatten(1)' [1, [2], [[3]]] => [1, 2, [3]] jq 'flatten' [[]] => [] jq 'flatten' [{"foo": "bar"}, [{"foo": "baz"}]] => [{"foo": "bar"}, {"foo": "baz"}] range(upto), range(from; upto), range(from; upto; by) range . range(4; 10) ( ) ( ) . . [range(4; 10)] . 0 . from upto . from upto by . jq 'range(2; 4)' null => 2, 3 jq '[range(2; 4)]' null => [2,3] jq '[range(4)]' null => [0,1,2,3] jq '[range(0; 10; 3)]' null => [0,3,6,9] jq '[range(0; 10; -1)]' null => [] jq '[range(0; -5; -1)]' null => [0,-1,-2,-3,-4] floor floor (floor) . jq 'floor' 3.14159 => 3 sqrt sqrt () . jq 'sqrt' 9 => 3 tonumber tonumber . . jq '.[] | tonumber' [1, "1"] => 1, 1 toboolean toboolean . . jq '.[] | toboolean' ["true", "false", true, false] => true, false, true, false tostring tostring . JSON (JSON-encoded) . jq '.[] | tostring' [1, "1", [1]] => "1", "1", "[1]" type type null boolean number string array object . jq 'map(type)' [0, false, [], {}, null, "hello"] => ["number", "boolean", "array", "object", "null", "string"] infinite, nan, isinfinite, isnan, isfinite, isnormal "" (NaN) . isinfinite true . isnan NaN true . infinite . nan NaN . isnormal true . . NaN (sub-normals) . jq '.[] | (infinite * .) < 0' [-1, 1] => true, false jq 'infinite, nan | type' null => "number", "number" sort, sort_by(path_expression) sort . : o null o false o true o o ( ) o (lexical) o : ( ) . sort_by jq . sort_by(f) f . f . jq 'sort' [8,3,null,6] => [null,3,6,8] jq 'sort_by(.foo)' [{"foo":4, "bar":10}, {"foo":3, "bar":10}, {"foo":2, "bar":1}] => [{"foo":2, "bar":1}, {"foo":3, "bar":10}, {"foo":4, "bar":10}] jq 'sort_by(.foo, .bar)' [{"foo":4, "bar":10}, {"foo":3, "bar":20}, {"foo":2, "bar":1}, {"foo":3, "bar":10}] => [{"foo":2, "bar":1}, {"foo":3, "bar":10}, {"foo":3, "bar":20}, {"foo":4, "bar":10}] group_by(path_expression) group_by(.foo) .foo .foo . jq .foo . sort . jq 'group_by(.foo)' [{"foo":1, "bar":10}, {"foo":3, "bar":100}, {"foo":1, "bar":1}] => [[{"foo":1, "bar":10}, {"foo":1, "bar":1}], [{"foo":3, "bar":100}]] min, max, min_by(path_exp), max_by(path_exp) . min_by(path_exp) max_by(path_exp) min_by(.foo) foo . jq 'min' [5,4,2,7] => 2 jq 'max_by(.foo)' [{"foo":1, "bar":14}, {"foo":2, "bar":3}] => {"foo":2, "bar":3} unique, unique_by(path_exp) unique . unique_by(path_exp) . group . jq 'unique' [1,2,5,3,5,3,1,3] => [1,2,3,5] jq 'unique_by(.foo)' [{"foo": 1, "bar": 2}, {"foo": 1, "bar": 3}, {"foo": 4, "bar": 5}] => [{"foo": 1, "bar": 2}, {"foo": 4, "bar": 5}] jq 'unique_by(length)' ["chunky", "bacon", "kitten", "cicada", "asparagus"] => ["bacon", "chunky", "asparagus"] reverse . jq 'reverse' [1,2,3,4] => [4,3,2,1] contains(element) contains(b) true b . B A B A . B A B A . B A B A . . jq 'contains("bar")' "foobar" => true jq 'contains(["baz", "bar"])' ["foobar", "foobaz", "blarp"] => true jq 'contains(["bazzzzz", "bar"])' ["foobar", "foobaz", "blarp"] => false jq 'contains({foo: 12, bar: [{barp: 12}]})' {"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]} => true jq 'contains({foo: 12, bar: [{barp: 15}]})' {"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]} => false indices(s) . s . s . s . jq 'indices(", ")' "a,b, cd, efg, hijk" => [3,7,12] jq 'indices(1)' [0,1,2,1,3,1,4] => [1,3,5] jq 'indices([1,2])' [0,1,2,3,1,4,2,5,1,2,6,7] => [1,8] index(s), rindex(s) (index) (rindex) s . jq 'index(", ")' "a,b, cd, efg, hijk" => 3 jq 'index(1)' [0,1,2,1,3,1,4] => 1 jq 'index([1,2])' [0,1,2,3,1,4,2,5,1,2,6,7] => 1 jq 'rindex(", ")' "a,b, cd, efg, hijk" => 12 jq 'rindex(1)' [0,1,2,1,3,1,4] => 5 jq 'rindex([1,2])' [0,1,2,3,1,4,2,5,1,2,6,7] => 8 inside inside(b) b true . contains . jq 'inside("foobar")' "bar" => true jq 'inside(["foobar", "foobaz", "blarp"])' ["baz", "bar"] => true jq 'inside(["foobar", "foobaz", "blarp"])' ["bazzzzz", "bar"] => false jq 'inside({"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]})' {"foo": 12, "bar": [{"barp": 12}]} => true jq 'inside({"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]})' {"foo": 12, "bar": [{"barp": 15}]} => false startswith(str) . true . jq '[.[]|startswith("foo")]' ["fo", "foo", "barfoo", "foobar", "barfoob"] => [false, true, false, true, false] endswith(str) . true . jq '[.[]|endswith("foo")]' ["foobar", "barfoo"] => [false, true] combinations, combinations(n) . n n . jq 'combinations' [[1,2], [3, 4]] => [1, 3], [1, 4], [2, 3], [2, 4] jq 'combinations(2)' [0, 1] => [0, 0], [0, 1], [1, 0], [1, 1] ltrimstr(str) . jq '[.[]|ltrimstr("foo")]' ["fo", "foo", "barfoo", "foobar", "afoo"] => ["fo","","barfoo","bar","afoo"] rtrimstr(str) . jq '[.[]|rtrimstr("foo")]' ["fo", "foo", "barfoo", "foobar", "foob"] => ["fo","","bar","foobar","foob"] trimstr(str) . jq '[.[]|trimstr("foo")]' ["fo", "foo", "barfoo", "foobarfoo", "foob"] => ["fo","","bar","bar","b"] trim, ltrim, rtrim trim . ltrim ( ) . rtrim ( ) . " " "\n" "\t" "\r" (whitespace) . . jq 'trim, ltrim, rtrim' " abc " => "abc", "abc ", " abc" explode (codepoint) . jq 'explode' "foobar" => [102,111,111,98,97,114] implode explode . jq 'implode' [65, 66, 67] => "ABC" split(str) (split) . split (regex) ( ). jq 'split(", ")' "a, b,c,d, e, " => ["a","b,c,d","e",""] join(str) . split split("foo") | join("foo") . . null . . jq 'join(", ")' ["a","b,c,d","e"] => "a, b,c,d, e" jq 'join(" ")' ["a",1,2.3,true,null,false] => "a 1 2.3 true false" ascii_downcase, ascii_upcase (a-z A-Z) / . jq 'ascii_upcase' "useful but not for e" => "USEFUL BUT NOT FOR e" while(cond; update) while(cond; update) cond false . . while(cond; update) jq . while update . . jq '[while(.<100; .*2)]' 1 => [1,2,4,8,16,32,64] repeat(exp) repeat(exp) exp . . repeat(exp) jq . repeat exp . . jq '[repeat(.*2, error)?]' 1 => [2] until(cond; next) until(cond; next) next . cond (true) . ( ). until(cond; next) jq . next until() . . jq '[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]' 4 => 24 recurse(f), recurse, recurse(f; condition) recurse(f) . : {"name": "/", "children": [ {"name": "/bin", "children": [ {"name": "/bin/ls", "children": []}, {"name": "/bin/sh", "children": []}]}, {"name": "/home", "children": [ {"name": "/home/stephen", "children": [ {"name": "/home/stephen/jq", "children": []}]}]}]} . .name .children[].name .children[].children[].name . : recurse(.children[]) | .name recurse recurse(.[]?) . recurse(f) recurse(f; true) . recurse(f; condition) . .|f .|f|f .|f|f|f ... . recurse(.+1; true). recurse f . jq 'recurse(.foo[])' {"foo":[{"foo": []}, {"foo":[{"foo":[]}]}]} => {"foo":[{"foo":[]},{"foo":[{"foo":[]}]}]}, {"foo":[]}, {"foo":[{"foo":[]}]}, {"foo":[]} jq 'recurse' {"a":0,"b":[1]} => {"a":0,"b":[1]}, 0, [1], 1 jq 'recurse(. * .; . < 20)' 2 => 2, 4, 16 walk(f) walk(f) f . f (object) f . f . . . jq 'walk(if type == "array" then sort else . end)' [[4, 1, 7], [8, 5, 2], [3, 6, 9]] => [[1,4,7],[2,5,8],[3,6,9]] jq 'walk( if type == "object" then with_entries( .key |= sub( "^_+"; "") ) else . end )' [ { "_a": { "__b": 2 } } ] => [{"a":{"b":2}}] have_literal_numbers true jq . have_decnum true jq "decnum" jq . $JQ_BUILD_CONFIGURATION jq . ./configure . --arg (override) . $ENV, env $ENV jq . env jq . . jq '$ENV.PAGER' null => "less" jq 'env.PAGER' null => "less" transpose ( ) . null . jq 'transpose' [[1], [2,3]] => [[1,2],[null,3]] bsearch(x) bsearch(x) (binary search) x . x bsearch(x) (-1 - ix) ix x ix . bsearch(x) . jq 'bsearch(0)' [0,1] => 0 jq 'bsearch(0)' [1,2,3] => -1 jq 'bsearch(4) as $ix | if $ix < 0 then .[-(1+$ix)] = 4 else . end' [1,2,3] => [1,2,3,4] String interpolation: \(exp) . (interpolate) . jq '"The input was \(.), which is one less than \(.+1)"' 42 => "The input was 42, which is one less than 43" Convert to/from JSON tojson fromjson JSON JSON . tojson tostring tostring tojson JSON . jq '[.[]|tostring]' [1, "foo", ["foo"]] => ["1","foo","[\"foo\"]"] jq '[.[]|tojson]' [1, "foo", ["foo"]] => ["1","\"foo\"","[\"foo\"]"] jq '[.[]|tojson|fromjson]' [1, "foo", ["foo"]] => [1,"foo",["foo"]] Format strings and escaping @foo URL HTML XML . @foo : @text: tostring . @json: JSON . @html: HTML/XML <>&'" < > & ' " . @uri: (percent-encoding) URI %XX . @urid: @uri (percent-decoding) %XX URI . @csv: CSV . @tsv: TSV ( ) . . ( 0x09) . ( 0x0a) ( 0x0d) ( 0x09) ( 0x5c) \n \r \t \\ . @sh: POSIX . . @base64: RFC 4648 base64 . @base64d: @base64 RFC 4648 . \: UTF-8 . . @foo . . . @uri "https://www.google.com/search?q=\(.search)" {"search":"what is jq?"} : "https://www.google.com/search?q=what%20is%20jq%3F" URL . jq '@html' "This works if x < y" => "This works if x < y" jq '@sh "echo \(.)"' "O'Hara's Ale" => "echo 'O'\\''Hara'\\''s Ale'" jq '@base64' "This is a message" => "VGhpcyBpcyBhIG1lc3NhZ2U=" jq '@base64d' "VGhpcyBpcyBhIG1lc3NhZ2U=" => "This is a message" Dates jq . UTC . fromdateiso8601 ISO 8601 (1970-01-01T00:00:00Z) . todateiso8601 . fromdate . fromdate ISO 8601 . todate (alias) todateiso8601 . now . jq C : strptime strftime strflocaltime mktime gmtime localtime. strptime strftime . : jq (localization) . gmtime (Unix epoch) << >> (GMT) ( ) : ( ) ( ) -- . . localtime gmtime . mktime << >> gmtime strptime . strptime(fmt) fmt (parse) . << >> mktime gmtime . strftime(fmt) (GMT) . strflocaltime . strptime strftime C . ISO 8601 "%Y-%m-%dT%H:%M:%SZ" . jq . %u %j strptime(fmt) macOS . jq 'fromdate' "2015-03-05T23:51:47Z" => 1425599507 jq 'strptime("%Y-%m-%dT%H:%M:%SZ")' "2015-03-05T23:51:47Z" => [2015,2,5,23,51,47,4,63] jq 'strptime("%Y-%m-%dT%H:%M:%SZ")|mktime' "2015-03-05T23:51:47Z" => 1425599507 SQL (SQL-Style Operators) jq SQL . INDEX(stream; index_expression): . JOIN($idx; stream; idx_expr; join_expr): (join) . . . JOIN($idx; stream; idx_expr): JOIN($idx; stream; idx_expr; .) . JOIN($idx; idx_expr): . . . . IN(s): . true false . IN(source; s): true false . builtins name/arity . (arity) all/0 all/1 all/2 . (CONDITIONALS AND COMPARISONS) ==, != 'a == b' a b ( JSON ) 'true' 'false' . . JSON . == jq === . != <<>> 'a != b' 'a == b' . jq '. == false' null => false jq '. == {"b": {"d": (4 + 1e-20), "c": 3}, "a":1}' {"a":1, "b": {"c": 3, "d": 4}} => true jq '.[] == 1' [1, 1.0, "1", "banana"] => true, true, false, false if-then-else-end if A then B else C end A false null B C . if A then B end if A then B else . end . else . . elif else . false null <<>> (truthiness) . if .name then A else B end if .name == "" then A else B end . A B false null C false null . elif A then B if . jq 'if . == 0 then "zero" elif . == 1 then "one" else "many" end' 2 => "many" >, >=, <=, < > >= <= < ( ) . sort . jq '. < 5' 2 => true and, or, not jq and or not . if - false null << >> (false) << >> (true) . . not .foo and .bar | not. true false // "value_that_may_be_null or default". "or" // . jq '42 and "a string"' null => true jq '(true, false) or false' null => true, false jq '(true, true) and (true, false)' null => true, false, true, false jq '[true, false | not]' null => [false, true] : // (Alternative operator: //) // false null . false null // . a // b a false null . a false null a // b b . : .foo .foo // 1 1 . or ( or jq ). : some_generator // defaults_here some_generator | . // defaults_here . false null . . false, 1 // 2 // 1 false, 1 -- false, 1 // 2 false, (1 // 2) . (false, null, 1) | . // 42 // . (false, null, 1) // 42 false null 42 . jq 'empty // 42' null => 42 jq '.foo // 42' {"foo": 19} => 19 jq '.foo // 42' {} => 42 jq '(false, null, 1) // 42' null => 1 jq '(false, null, 1) | . // 42' null => 42, 42, 1 try-catch try EXP catch EXP . . (handler) . try EXP empty . jq 'try .a catch ". is not an object"' true => ". is not an object" jq '[.[]|try .a]' [{}, true, {"a":1}] => [null, 1] jq 'try error("some exception") catch .' true => "some exception" (Breaking out of control structures) try/catch reduce foreach while . : # Repeat an expression until it raises "break" as an # error, then stop repeating without re-raising the error. # But if the error caught is not "break" then re-raise it. try repeat(exp) catch if .=="break" then empty else error jq "break" "go (back) to" : label $out | ... break $out ... break $label_name label $label_name ( ) empty . break label (lexical) : break " " . reduce: label $out | reduce .[] as $item (null; if .==false then break $out else ... end) jq (syntax error) : break $out $out . / : ? (Error Suppression / Optional Operator: ?) ? EXP? try EXP . jq '[.[] | .a?]' [{}, true, {"a":1}] => [null, 1] jq '[.[] | tonumber?]' ["1", "invalid", "3", 4] => [1, 3, 4] (REGULAR EXPRESSIONS) jq PHP TextMate Sublime Text Oniguruma jq . Oniguruma (flavor) jq "Perl NG" ( Perl with named groups) . (regex) jq : STRING | FILTER(REGEX) STRING | FILTER(REGEX; FLAGS) STRING | FILTER([REGEX]) STRING | FILTER([REGEX, FLAGS]) : o STRING REGEX FLAGS jq (string interpolation) jq o REGEX o FILTER test match capture . REGEX JSON (escape) . \s "\\s" . FLAGS : o g - ( ) o i - o m - (. ) o n - o p - s m o s - (^ -> \A, $ -> \Z) o l - o x - ( ) x \s : jq -n '"a b" | test("a\\sb"; "x")' REGEX : jq -n '("test", "TEst", "teST", "TEST") | test("(?i)te(?-i)st")' : true, true, false, false. test(val), test(regex; flags) match true false . jq 'test("foo")' "foo" => true jq '.[] | test("a b c # spaces are ignored"; "ix")' ["xabcd", "ABC"] => true, true match(val), match(regex; flags) match . : o offset - UTF-8 o length - UTF-8 o string - o captures - (capturing groups) . : o offset - UTF-8 o length - UTF-8 o string - (capture) o name - ( null ) -1 jq 'match("(abc)+"; "g")' "abc abc" => {"offset": 0, "length": 3, "string": "abc", "captures": [{"offset": 0, "length": 3, "string": "abc", "name": null}]}, {"offset": 4, "length": 3, "string": "abc", "captures": [{"offset": 4, "length": 3, "string": "abc", "name": null}]} jq 'match("foo")' "foo bar foo" => {"offset": 0, "length": 3, "string": "foo", "captures": []} jq 'match(["foo", "ig"])' "foo bar FOO" => {"offset": 0, "length": 3, "string": "foo", "captures": []}, {"offset": 8, "length": 3, "string": "FOO", "captures": []} jq 'match("foo (?bar)? foo"; "ig")' "foo bar foo foo foo" => {"offset": 0, "length": 11, "string": "foo bar foo", "captures": [{"offset": 4, "length": 3, "string": "bar", "name": "bar123"}]}, {"offset": 12, "length": 8, "string": "foo foo", "captures": [{"offset": -1, "length": 0, "string": null, "name": "bar123"}]} jq '[ match("."; "g")] | length' "abc" => 3 capture(val), capture(regex; flags) (named captures) JSON . jq 'capture("(?[a-z]+)-(?[0-9]+)")' "xyzzy-14" => { "a": "xyzzy", "n": "14" } scan(regex), scan(regex; flags) ( ) . . [ expr ] [ scan(regex) ]. (capturing groups) . jq 'scan("c")' "abcdefabc" => "c", "c" jq 'scan("(a+)(b+)")' "abaabbaaabbb" => ["a","b"], ["aa","bb"], ["aaa","bbb"] split(regex; flags) (split) . split . jq 'split(", *"; null)' "ab,cd, ef" => ["ab","cd","ef"] splits(regex), splits(regex; flags) split (stream) . jq 'splits(", *")' "ab,cd, ef, gh" => "ab", "cd", "ef", "gh" jq 'splits(",? *"; "n")' "ab,cd ef, gh" => "ab", "cd", "ef", "gh" sub(regex; tostring), sub(regex; tostring; flags) tostring ( ) . tostring jq . JSON ( capture ) tostring "x" "\(.x)" . jq 'sub("[^a-z]*(?[a-z]+)"; "Z\(.x)"; "g")' "123abc456def" => "ZabcZdef" jq '[sub("(?.)"; "\(.a|ascii_upcase)", "\(.a|ascii_downcase)")]' "aB" => ["AB","aB"] gsub(regex; tostring), gsub(regex; tostring; flags) gsub sub tostring . jq gsub JSON . jq 'gsub("(?.)[^a]*"; "+\(.x)-")' "Abcabc" => "+A-+a-" jq '[gsub("p"; "a", "b")]' "p" => ["a","b"] (ADVANCED FEATURES) jq << >> . . . ( ) . jq jq ( jq map select jq ). jq (reduction operators) . jq . jq ( generators ) . . I/O (/ JSON JSON ) . / . / : ... as $identifier | ... jq . a + b ( a b ) . - . jq add / length - add length . jq . jq expression as $variable . $ . : length as $array_length | add / $array_length . "author" "title" . : {"posts": [{"title": "First post", "author": "anon"}, {"title": "A well-written article", "author": "person1"}], "realnames": {"anon": "Anonymous Coward", "person1": "Person McPherson"}} (author) : {"title": "First post", "author": "Anonymous Coward"} {"title": "A well-written article", "author": "Person McPherson"} $names realnames : .realnames as $names | .posts[] | {title, author: $names[.author]} exp as $x | ... : exp $x . as foreach . {foo} {foo: .foo} {$foo} {foo: $foo} . as ( <<>> destructuring ): . as {realnames: $names, posts: [$first, $second]} | ... ( . as [$first, $second]) (bind) . null . : .realnames as $names | (.posts[] | {title, author: $names[.author]}) : (.realnames as $names | .posts[]) | {title, author: $names[.author]} . jq (lexically-scoped bindings) . . jq '.bar as $x | .foo | . + $x' {"foo":10, "bar":200} => 210 jq '. as $i|[(.*2|. as $i| $i), $i]' 5 => [10,5] jq '. as [$a, $b, {c: $c}] | $a + $b + $c' [2, 3, {"c": 4, "d": 5}] => 9 jq '.[] as [$a, $b] | {a: $a, b: $b}' [[0], [0, 1], [2, 1, 0]] => {"a":0,"b":null}, {"a":0,"b":1}, {"a":2,"b":1} Destructuring Alternative Operator: ?// . API user_id (timestamp) . API ( XML ) : {"resources": [{"id": 1, "kind": "widget", "events": {"action": "create", "user_id": 1, "ts": 13}}, {"id": 2, "kind": "widget", "events": [{"action": "create", "user_id": 1, "ts": 14}, {"action": "destroy", "user_id": 1, "ts": 15}]}]} : .resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts} : .[] as [$id, $kind, $user_id, $ts] ?// {$id, $kind, $user_id, $ts} | ... . null : .resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$first_user_id, $first_ts}]} | {$user_id, $first_user_id, $kind, $id, $ts, $first_ts} . . [[3]] | .[] as [$a] ?// [$b] | if $a != null then error("err: \($a)") else {$a,$b} end jq '.[] as {$a, $b, c: {$d, $e}} ?// {$a, $b, c: [{$d, $e}]} | {$a, $b, $d, $e}' [{"a": 1, "b": 2, "c": {"d": 3, "e": 4}}, {"a": 1, "b": 2, "c": [{"d": 3, "e": 4}]}] => {"a":1,"b":2,"d":3,"e":4}, {"a":1,"b":2,"d":3,"e":4} jq '.[] as {$a, $b, c: {$d}} ?// {$a, $b, c: [{$e}]} | {$a, $b, $d, $e}' [{"a": 1, "b": 2, "c": {"d": 3, "e": 4}}, {"a": 1, "b": 2, "c": [{"d": 3, "e": 4}]}] => {"a":1,"b":2,"d":3,"e":null}, {"a":1,"b":2,"d":null,"e":4} jq '.[] as [$a] ?// [$b] | if $a != null then error("err: \($a)") else {$a,$b} end' [[3]] => {"a":null,"b":3} Defining Functions "def" : def increment: . + 1; increment ( ). : def map(f): [.[] | f]; ( ) . ( f ). (callbacks) . : def foo(f): f|f; 5|foo(.*2) 20 f .*2 f . 5 10 (5 * 2) 20 . . : def addvalue(f): f as $f | map(. + $f); : def addvalue($f): ...; addvalue(.foo) .foo . addvalue(.[]) map(. + $f) . . . ( ) . (scoping) . jq 'def addvalue(f): . + [f]; map(addvalue(.[0]))' [[1,2],[10,20]] => [[1,2,1], [10,20,10]] jq 'def addvalue(f): f as $x | map(. + $x); addvalue(.[0])' [[1,2],[10,20]] => [[1,2,1,2], [10,20,1,2]] Scoping jq : ( <<>>) . << >> . . << >> ... | .*3 as $times_three | [. + $times_three] | ... << >> . ... | (.*3 as $times_three | [. + $times_three]) | ...: $times_three . isempty(exp) exp true false . jq 'isempty(empty)' null => true jq 'isempty(.[])' [] => true jq 'isempty(.[])' [1,2,3] => false limit(n; expr) limit n expr . jq '[limit(3; .[])]' [0,1,2,3,4,5,6,7,8,9] => [0,1,2] skip(n; expr) skip n expr . jq '[skip(3; .[])]' [0,1,2,3,4,5,6,7,8,9] => [3,4,5,6,7,8,9] first(expr), last(expr), nth(n; expr) first(expr) last(expr) expr . nth(n; expr) n- expr . nth(n; expr) n . jq '[first(range(.)), last(range(.)), nth(5; range(.))]' 10 => [0,9,5] jq '[first(empty), last(empty), nth(5; empty)]' null => [] first, last, nth(n) first last . . nth(n) n- . . jq '[range(.)]|[first, last, nth(5)]' 10 => [0,9,5] reduce reduce . reduce EXP as $var (INIT; UPDATE) . [1,2,3] : reduce .[] as $item (0; . + $item) .[] . + $item 0 . .[] 1 2 3 : 0 | 1 as $item | . + $item | 2 as $item | . + $item | 3 as $item | . + $item jq 'reduce .[] as $item (0; . + $item)' [1,2,3,4,5] => 15 jq 'reduce .[] as [$i,$j] (0; . + $i * $j)' [[1,2],[3,4],[5,6]] => 44 jq 'reduce .[] as {$x,$y} (null; .x += $x | .y += [$y])' [{"x":"a","y":1},{"x":"b","y":2},{"x":"c","y":3}] => {"x":"abc","y":[1,2,3]} foreach foreach reduce limit (reducers) . foreach EXP as $var (INIT; UPDATE; EXTRACT) . [1,2,3] : foreach .[] as $item (0; . + $item; [$item, . * 2]) reduce . + $item .[] [$item, . * 2] . 1 3 6 foreach [1,2] [2,6] [3,12] . : 0 | 1 as $item | . + $item | [$item, . * 2], 2 as $item | . + $item | [$item, . * 2], 3 as $item | . + $item | [$item, . * 2] EXTRACT (identity) . . jq 'foreach .[] as $item (0; . + $item)' [1,2,3,4,5] => 1, 3, 6, 10, 15 jq 'foreach .[] as $item (0; . + $item; [$item, . * 2])' [1,2,3,4,5] => [1,2], [2,6], [3,12], [4,20], [5,30] jq 'foreach .[] as $item (0; . + 1; {index: ., $item})' ["foo", "bar", "baz"] => {"index":1,"item":"foo"}, {"index":2,"item":"bar"}, {"index":3,"item":"baz"} (Recursion) recurse jq . while . (Tail calls) . . : def recurse(f): def r: ., (f | select(. != null) | r); r; def while(cond; update): def _while: if cond then ., (update | _while) else empty end; _while; def repeat(exp): def _repeat: exp, _repeat; _repeat; (Generators and iterators) jq (generator) . .[] ( ) range(0; 10) 0 10 . . empty . empty (backtrack ). jq . . << >> (in tail position) . _range . : (tail recursion) (sub-functions). jq 'def range(init; upto; by): def _range: if (by > 0 and . < upto) or (by < 0 and . > upto) then ., ((.+by)|_range) else empty end; if init == upto then empty elif by == 0 then init else init|_range end; range(0; 10; 3)' null => 0, 3, 6, 9 jq 'def while(cond; update): def _while: if cond then ., (update | _while) else empty end; _while; [while(.<100; .*2)]' 1 => [1,2,4,8,16,32,64] (MATH) jq IEEE754 ( ) . + jq C . C ( sin()) jq . C ( pow()) jq . . C jq . . C . . C : acos acosh asin asinh atan atanh cbrt ceil cos cosh erf erfc exp exp10 exp2 expm1 fabs floor gamma j0 j1 lgamma log log10 log1p log2 logb nearbyint rint round significand sin sinh sqrt tan tanh tgamma trunc y0 y1. C : atan2 copysign drem fdim fmax fmin fmod frexp hypot jn ldexp modf nextafter nexttoward pow remainder scalb scalbln yn. C : fma. . / (I/O) jq / (I/O) . : input inputs jq ( stdin ). jq . -n . : debug stderr. ( jq JSON stdout .) debug C API libjq jq . stderr stderr . jq (referentially transparent) . I/O . input . input jq -n . echo 1 2 3 4 | jq '[., input]' # [1,2] [3,4] inputs . (reductions) . inputs jq -n . echo 1 2 3 | jq -n 'reduce inputs as $i (0; . + $i)' # 6 debug, debug(msgs) . stderr . debug : ["DEBUG:",] . . debug(msgs) (msgs | debug | empty), . . : 1 as $x | 2 | debug("Entering function foo with $x == \($x)", .) | (.+1) 3 stderr : ["DEBUG:","Entering function foo with $x == 1"] ["DEBUG:",2] stderr stderr . input_filename . jq UTF-8 . input_line_number . (STREAMING) --stream jq (streaming) jq JSON . JSON . jq [, ] ( ) . . ["a",["b"]] [[0],"a"],[[1,0],"b"],[[1,0]],[[1]] . [, ] ( ) [] ( ) . jq --stream --seq ["error message"] . truncate_stream(stream_expression) ( ). jq 'truncate_stream([[0],"a"],[[1,0],"b"],[[1,0]],[[1]])' 1 => [[0],"b"], [[0]] fromstream(stream_expression) (stream expression) . jq 'fromstream(1|truncate_stream([[0],"a"],[[1,0],"b"],[[1,0]],[[1]]))' null => ["b"] tostream tostream . jq '. as $dot|fromstream($dot|tostream)|.==$dot' [0,[1,{"a":1},{"b":2}]] => true (ASSIGNMENT) jq . jq - " " " ". .foo .bar .foo .bar .bar = .foo . Python Java Ruby JavaScript jq ( ). jq ( ). jq JSON . jq (LHS) . (RHS) . jq . . . . : {a:{b:{c:1}}} | (.a.b|=3), .. {"a":{"b":3}} {"a":{"b":{"c":1}}} . . = |= += . (LHS) . . $var.foo = 1 ($var.foo . ) $var | .foo = 1 . .a,.b=0 .a .b (.a,.b)=0 . Update-assignment: |= <<>> |= . . . (.foo, .bar) |= .+1 foo foo bar bar . path() . |= . . $var.foo |= . + 1 ($var.foo . ) $var | .foo |= . + 1 . ( empty ) del(path) . ( : jq 1.5 ). jq '(..|select(type=="boolean")) |= if . then 1 else 0 end' [true,false,[5,true,[true,[false]],false]] => [1,0,[5,1,[1,[0]],0]] Arithmetic update-assignment: +=, -=, *=, /=, %=, //= jq a op= b a |= . op b . += 1 |= . + 1 . jq '.foo += 1' {"foo": 42} => {"foo": 43} Plain assignment: = . (RHS) (LHS) ( ). = jq . . (.a,.b) = range(2) {"a":0,"b":0} {"a":1,"b":1} . <<>> ( ) . = |= : {"a": {"b": 10}, "b": 20} : .a = .b .a |= .b a b {"a": 20, "b": 20} . a b a {"a": 10, "b": 20} . jq '.a = .b' {"a": {"b": 10}, "b": 20} => {"a":20,"b":20} jq '.a |= .b' {"a": {"b": 10}, "b": 20} => {"a":10,"b":20} jq '(.a, .b) = range(3)' null => {"a":0,"b":0}, {"a":1,"b":1}, {"a":2,"b":2} jq '(.a, .b) |= range(3)' null => {"a":0,"b":0} Complex assignments jq . : .posts[0].title = "JQ Manual" : .posts[].comments |= . + ["this is great"] "this is great" "comments" ( "posts" ). jq 'a = b' a <<>> . . - . . "blog" . "stedolan" . "select" : .posts[] | select(.author == "stedolan") "stedolan" : (.posts[] | select(.author == "stedolan") | .comments) |= . + ["terrible."] / (COMMENTS) jq # () . # ( ) . # . . [1,3,4,7] : [ 1, # foo \ 2, # bar \\ 3, 4, # baz \\\ 5, \ 6, 7 # comment \ comment \ comment ] <<>> (shebang) jq : #!/bin/sh -- # total - Output the sum of the given arguments (or stdin) # usage: total [numbers...] # \ exec jq --args -MRnf -- "$0" "$@" $ARGS.positional | reduce ( if . == [] then inputs else .[] end | . as $dot | try tonumber catch false | if not or isnan then @json "total: Invalid number \($dot).\n" | halt_error(1) end ) as $n (0; . + $n) exec jq . sh sh . total 1 2 /bin/sh -- /path/to/total 1 2 sh exec jq --args -MRnf -- /path/to/total 1 2 jq (-M -R -n --args) ($0) ($@) sh . (MODULES) jq / . .jq . (imported) ( ). import include . . ~/ ~ . $ORIGIN/ jq $ORIGIN . ./ . (including file) . . . import . -L ["~/.jq", "$ORIGIN/../lib/jq", "$ORIGIN/../lib"] . Null . foo/bar foo/bar.jq foo/bar/bar.jq . README . ( foo/foo). -L$HOME/.jq foo $HOME/.jq/foo.jq $HOME/.jq/foo/foo.jq . .jq ( ) (source) . import RelativePathString as NAME []; . .jq . NAME:: . jq . homepage . jq / search . modulemeta . search ( ) . include RelativePathString []; . .jq . (namespace) . jq . homepage . jq / search . modulemeta . import RelativePathString as $NAME []; JSON . .json . $NAME::NAME . jq . homepage . jq / search . modulemeta . search ( ) . module ; . . modulemeta . jq . homepage . jq modulemeta . modulemeta ( ) deps defs . . (COLORS) JQ_COLORS ( "1;31") : o null o false o true o o o o o JQ_COLORS="0;90:0;39:0;39:0;39:0;32:1;39:1;39:1;34" . VT100/ANSI . - : o 1 () o 2 () o 4 () o 5 () o 7 () o 8 () : o 30 () o 31 () o 32 () o 33 () o 34 () o 35 () o 36 () o 37 () (BUGS) . : https://github.com/jqlang/jq/issues (AUTHOR) Stephen Dolan May 2025 JQ(1)