JAQ(1) General Commands Manual JAQ(1) (NAME) jaq - JSON (SYNOPSIS) jaq [OPTION] [FILTER] [FILE] (DESCRIPTION) jaq jq . jq ( jq C ) . jaq Rust . jaq jq : o JSON YAML CBOR TOML XML o UTF-8 o (Byte strings) o {0: 1, [2]: 3} o (In-place) : o . o jaq jaq jq jq . jq . o jq jaq . (issue) ( ) . jaq . ! NGI0 Commons Fund NLnet Next Generation Internet DG Communications Networks, Content and Technology 101135429 . (SERI) . <<>> jaq jq . <> C <> jq . (COMMAND-LINE INTERFACE) jaq [OPTION] [FILTER] [FILE] : o (parse) FILTER jq jq o FILE: o FILE o : o FILTER o jaq . jaq '.name?' persons.json .name? persons.json . .name? JSON . (INPUT) FILE jaq . jaq FILE : o --from FORMAT jaq . o FILE jaq .json .yaml .cbor .toml .xml .csv .tsv jaq . o jaq JSON . --from FORMAT FORMAT. : jaq --from yaml . myfile.yml myfile.yml YAML . FORMAT : raw raw0 json yaml cbor toml xml csv tsv. jaq : .json .yaml .yml .cbor .toml .xml .xhtml .csv .tsv. jaq --from cbor . myfile.cbor jaq . myfile.cbor. jq . -n, --null-input null . : $ yes | jaq -n null . inputs . : $ yes true | jaq -n 'first(inputs)' true reduce / foreach . -R, --raw-input . : $ printf "Hello\nWorld" | jaq -R "Hello" "World" --slurp . : $ printf "Hello\nWorld" | jaq -Rs "Hello\nWorld" --rawfile . --from raw . --raw-input0 --raw-input NUL (\0) . : $ printf "Hello\nWorld\0foo" | jaq --raw-input0 "Hello\nWorld" "foo" --slurp . : $ printf "Hello\nWorld\0foo" | jaq -sc --raw-input0 ["Hello\nWorld","foo"] --raw-output0 : $ printf '"some string\\nwith a newline" "another string"' | jaq --raw-output0 | jaq --raw-input0 "some string\nwith a newline" "another string" --from raw0 . jq . -s, --slurp ( ). : $ echo 1 2 3 | jaq 1 2 3 $ echo 1 2 3 | jaq -cs [1,2,3] --raw-input jaq . : $ echo 1 2 3 | jaq -Rs "1 2 3\n" --rawfile . slurp jq jaq . --in-place jaq jq . jq jaq jq -s . a b jaq -s . <(cat a b) . (OUTPUT) --to FORMAT FORMAT . --from . . TOML (object) TOML : $ echo [] | jaq --to toml 2>/dev/null; echo $? 2 jq . -c, --compact-output JSON . : $ echo [1, 2, 3] | jaq -c [1,2,3] -r, --raw-output ( ) (). : $ printf '"Hello\\nWorld"' | jaq -r Hello World $ printf '"Hello\\nWorld"' | jaq "Hello\nWorld" . : $ printf '["Hello\\nWorld"]' | jaq -rc ["Hello\nWorld"] --to raw . --raw-output0 --raw-output NUL (\0) LF (\n). $ printf '"some string\\nwith a newline" true' | jaq --raw-output0 | jaq -s --raw-input tobytes b"some string\nwith a newline\x00true\x00" NUL . . $ printf '"string with NUL \\u0000"' | jaq --raw-output0 2>/dev/null; echo $? 2 --to raw0 . -j, --join-output . : $ echo true false | jaq -j && echo " (no new line at end)" truefalse (no new line at end) --raw-output (-r) : $ printf '"Hello" " " "World" "\\n"' | jaq -jr Hello World -i, --in-place (in-place). : $ echo 1 > tmp.json && jaq -i '.+1' tmp.json && cat tmp.json && rm tmp.json 2 tmp.json .+1 . . jq . -S, --sort-keys . : $ echo '{"b": {"d": 3, "c": 2}, "a": 1}' | jaq -cS {"a":1,"b":{"c":2,"d":3}} $ echo '{"b": {"d": 3, "c": 2}, "a": 1}' | jaq -c {"b":{"d":3,"c":2},"a":1} -C, --color-output jaq . : $ echo {} | jaq -C | jaq --from raw tobytes b"\x1b[1;39m{\x1b[0m\x1b[1;39m}\x1b[0m" $ echo {} | jaq | jaq --from raw tobytes b"{}" ( jaq --from raw tobytes -C ANSI .) -M, --monochrome-output ( ). --tab (tab) (spaces). : $ echo [1, [2]] | jaq --tab | jaq -Rs "[\n\t1,\n\t[\n\t\t2\n\t]\n]\n" $ echo [1, [2]] | jaq | jaq -Rs "[\n 1,\n [\n 2\n ]\n]\n" --indent N N (: 2). NO_COLOR NO_COLOR jaq -C . JQ_COLORS JQ_COLORS (colon) . JQ_COLORS : o null o false o true o (numbers) o (strings) o (arrays) o (objects) o (object keys) JQ_COLORS 90:39:39:39:32:1;39:1;39:1;34 . : o null 90 ( ). o false/true/ 39 ( ). o 32 ( ). o / 1;39 ( ). o 1;34 ( ). JQ_COLORS 90 1;39 <