@port-labs/jq-node-bindings 0.0.14 → 0.0.15-dev2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/binding.gyp +42 -20
- package/configure +1 -1
- package/deps/jq/.gitattributes +12 -0
- package/deps/jq/AUTHORS +149 -43
- package/deps/jq/COPYING +75 -1
- package/deps/jq/ChangeLog +2 -2
- package/deps/jq/Makefile.am +106 -65
- package/deps/jq/NEWS.md +391 -0
- package/deps/jq/README.md +54 -52
- package/deps/jq/SECURITY.md +7 -0
- package/deps/jq/compile-ios.sh +106 -102
- package/deps/jq/configure.ac +72 -59
- package/deps/jq/docs/Pipfile +14 -0
- package/deps/jq/docs/Pipfile.lock +415 -0
- package/deps/jq/docs/README.md +15 -14
- package/deps/jq/docs/build_manpage.py +251 -0
- package/deps/jq/docs/build_mantests.py +21 -0
- package/deps/jq/docs/build_website.py +95 -0
- package/deps/jq/docs/content/download/default.yml +249 -0
- package/deps/jq/docs/content/index.yml +83 -0
- package/deps/jq/docs/content/{3.manual/v1.6 → manual/dev}/manual.yml +992 -452
- package/deps/jq/docs/content/{3.manual → manual}/v1.3/manual.yml +105 -116
- package/deps/jq/docs/content/{3.manual → manual}/v1.4/manual.yml +122 -129
- package/deps/jq/docs/content/{3.manual → manual}/v1.5/manual.yml +313 -262
- package/deps/jq/docs/content/{3.manual → manual/v1.6}/manual.yml +407 -332
- package/deps/jq/docs/content/manual/v1.7/manual.yml +3697 -0
- package/deps/jq/docs/content/tutorial/default.yml +337 -0
- package/deps/jq/docs/manual_schema.yml +60 -0
- package/deps/jq/docs/public/css/style.css +99 -0
- package/deps/jq/docs/public/icon.png +0 -0
- package/deps/jq/docs/public/icon.svg +1 -0
- package/deps/jq/docs/public/jq.svg +1 -0
- package/deps/jq/docs/public/js/manual-search.js +31 -49
- package/deps/jq/docs/templates/default.html.j2 +31 -0
- package/deps/jq/docs/templates/index.html.j2 +58 -0
- package/deps/jq/docs/templates/manual.html.j2 +120 -0
- package/deps/jq/docs/templates/shared/_footer.html.j2 +14 -0
- package/deps/jq/docs/templates/shared/_head.html.j2 +23 -0
- package/deps/jq/docs/templates/shared/_navbar.html.j2 +40 -0
- package/deps/jq/docs/validate_manual_schema.py +19 -0
- package/deps/jq/jq.1.prebuilt +1102 -294
- package/deps/jq/jq.spec +2 -3
- package/deps/jq/libjq.pc.in +11 -0
- package/deps/jq/m4/ax_pthread.m4 +522 -0
- package/deps/jq/modules/oniguruma/.travis.yml +17 -0
- package/deps/jq/modules/oniguruma/CMakeLists.txt +206 -41
- package/deps/jq/modules/oniguruma/COPYING +23 -25
- package/deps/jq/modules/oniguruma/HISTORY +368 -23
- package/deps/jq/modules/oniguruma/Makefile.am +61 -7
- package/deps/jq/modules/oniguruma/README +34 -20
- package/deps/jq/modules/oniguruma/README.md +106 -33
- package/deps/jq/modules/oniguruma/README_japanese +183 -0
- package/deps/jq/modules/oniguruma/autogen.sh +9 -0
- package/deps/jq/modules/oniguruma/cmake/Config.cmake.in +4 -0
- package/deps/jq/modules/oniguruma/configure.ac +66 -55
- package/deps/jq/modules/oniguruma/doc/API +485 -42
- package/deps/jq/modules/oniguruma/doc/API.ja +732 -293
- package/deps/jq/modules/oniguruma/doc/CALLOUTS.API +397 -0
- package/deps/jq/modules/oniguruma/doc/CALLOUTS.API.ja +393 -0
- package/deps/jq/modules/oniguruma/doc/CALLOUTS.BUILTIN +95 -0
- package/deps/jq/modules/oniguruma/doc/CALLOUTS.BUILTIN.ja +93 -0
- package/deps/jq/modules/oniguruma/doc/FAQ +3 -3
- package/deps/jq/modules/oniguruma/doc/FAQ.ja +8 -8
- package/deps/jq/modules/oniguruma/doc/RE +223 -63
- package/deps/jq/modules/oniguruma/doc/RE.ja +420 -265
- package/deps/jq/modules/oniguruma/doc/SYNTAX.md +1091 -0
- package/deps/jq/modules/oniguruma/doc/UNICODE_PROPERTIES +840 -697
- package/deps/jq/modules/oniguruma/harnesses/ascii_compatible.dict +113 -0
- package/deps/jq/modules/oniguruma/harnesses/base.c +749 -0
- package/deps/jq/modules/oniguruma/harnesses/deluxe.c +206 -0
- package/deps/jq/modules/oniguruma/harnesses/dict_conv.py +72 -0
- package/deps/jq/modules/oniguruma/harnesses/fuzzer.options +2 -0
- package/deps/jq/modules/oniguruma/harnesses/libfuzzer-onig.cpp +45 -0
- package/deps/jq/modules/oniguruma/harnesses/regset.c +392 -0
- package/deps/jq/modules/oniguruma/index.html +16 -5
- package/deps/jq/modules/oniguruma/index_ja.html +16 -5
- package/deps/jq/modules/oniguruma/make_win.bat +5 -0
- package/deps/jq/modules/oniguruma/make_win32.bat +5 -3
- package/deps/jq/modules/oniguruma/make_win64.bat +5 -3
- package/deps/jq/modules/oniguruma/onig-config.cmake.in +80 -0
- package/deps/jq/modules/oniguruma/onig-config.in +1 -1
- package/deps/jq/modules/oniguruma/oniguruma.pc.cmake.in +1 -1
- package/deps/jq/modules/oniguruma/oniguruma.pc.in +0 -1
- package/deps/jq/modules/oniguruma/sample/CMakeLists.txt +9 -2
- package/deps/jq/modules/oniguruma/sample/Makefile.am +24 -5
- package/deps/jq/modules/oniguruma/sample/bug_fix.c +13 -51
- package/deps/jq/modules/oniguruma/sample/callback_each_match.c +168 -0
- package/deps/jq/modules/oniguruma/sample/callout.c +268 -0
- package/deps/jq/modules/oniguruma/sample/count.c +125 -0
- package/deps/jq/modules/oniguruma/sample/crnl.c +6 -4
- package/deps/jq/modules/oniguruma/sample/echo.c +136 -0
- package/deps/jq/modules/oniguruma/sample/encode.c +53 -146
- package/deps/jq/modules/oniguruma/sample/listcap.c +18 -10
- package/deps/jq/modules/oniguruma/sample/names.c +10 -6
- package/deps/jq/modules/oniguruma/sample/posix.c +13 -2
- package/deps/jq/modules/oniguruma/sample/regset.c +95 -0
- package/deps/jq/modules/oniguruma/sample/scan.c +20 -6
- package/deps/jq/modules/oniguruma/sample/simple.c +8 -4
- package/deps/jq/modules/oniguruma/sample/sql.c +13 -8
- package/deps/jq/modules/oniguruma/sample/syntax.c +11 -10
- package/deps/jq/modules/oniguruma/sample/user_property.c +12 -7
- package/deps/jq/modules/oniguruma/src/Makefile.am +41 -15
- package/deps/jq/modules/oniguruma/src/Makefile.windows +196 -183
- package/deps/jq/modules/oniguruma/src/ascii.c +64 -7
- package/deps/jq/modules/oniguruma/src/big5.c +25 -15
- package/deps/jq/modules/oniguruma/src/config.h.cmake.in +7 -22
- package/deps/jq/modules/oniguruma/src/config.h.win32 +56 -84
- package/deps/jq/modules/oniguruma/src/config.h.win64 +56 -84
- package/deps/jq/modules/oniguruma/src/config.h.windows.in +62 -0
- package/deps/jq/modules/oniguruma/src/cp1251.c +14 -8
- package/deps/jq/modules/oniguruma/src/euc_jp.c +28 -30
- package/deps/jq/modules/oniguruma/src/euc_jp_prop.c +25 -32
- package/deps/jq/modules/oniguruma/src/euc_jp_prop.gperf +1 -2
- package/deps/jq/modules/oniguruma/src/euc_kr.c +27 -15
- package/deps/jq/modules/oniguruma/src/euc_tw.c +40 -17
- package/deps/jq/modules/oniguruma/src/gb18030.c +177 -119
- package/deps/jq/modules/oniguruma/src/gperf_fold_key_conv.py +12 -8
- package/deps/jq/modules/oniguruma/src/gperf_unfold_key_conv.py +8 -6
- package/deps/jq/modules/oniguruma/src/iso8859_1.c +92 -91
- package/deps/jq/modules/oniguruma/src/iso8859_10.c +13 -29
- package/deps/jq/modules/oniguruma/src/iso8859_11.c +4 -2
- package/deps/jq/modules/oniguruma/src/iso8859_13.c +13 -33
- package/deps/jq/modules/oniguruma/src/iso8859_14.c +13 -30
- package/deps/jq/modules/oniguruma/src/iso8859_15.c +13 -34
- package/deps/jq/modules/oniguruma/src/iso8859_16.c +13 -29
- package/deps/jq/modules/oniguruma/src/iso8859_2.c +13 -29
- package/deps/jq/modules/oniguruma/src/iso8859_3.c +13 -33
- package/deps/jq/modules/oniguruma/src/iso8859_4.c +13 -32
- package/deps/jq/modules/oniguruma/src/iso8859_5.c +16 -23
- package/deps/jq/modules/oniguruma/src/iso8859_6.c +4 -2
- package/deps/jq/modules/oniguruma/src/iso8859_7.c +14 -29
- package/deps/jq/modules/oniguruma/src/iso8859_8.c +4 -2
- package/deps/jq/modules/oniguruma/src/iso8859_9.c +13 -33
- package/deps/jq/modules/oniguruma/src/koi8.c +14 -27
- package/deps/jq/modules/oniguruma/src/koi8_r.c +12 -19
- package/deps/jq/modules/oniguruma/src/make_property.sh +21 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_egcb.sh +7 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_egcb_data.py +267 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_fold.sh +25 -11
- package/deps/jq/modules/oniguruma/src/make_unicode_fold_data.py +206 -26
- package/deps/jq/modules/oniguruma/src/make_unicode_property.sh +19 -10
- package/deps/jq/modules/oniguruma/src/make_unicode_property_data.py +474 -375
- package/deps/jq/modules/oniguruma/src/make_unicode_wb.sh +7 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_wb_data.py +267 -0
- package/deps/jq/modules/oniguruma/src/mktable.c +28 -24
- package/deps/jq/modules/oniguruma/src/onig_init.c +2 -2
- package/deps/jq/modules/oniguruma/src/oniggnu.h +7 -5
- package/deps/jq/modules/oniguruma/src/onigposix.h +40 -16
- package/deps/jq/modules/oniguruma/src/oniguruma.h +357 -107
- package/deps/jq/modules/oniguruma/src/regcomp.c +6214 -3933
- package/deps/jq/modules/oniguruma/src/regenc.c +197 -120
- package/deps/jq/modules/oniguruma/src/regenc.h +106 -63
- package/deps/jq/modules/oniguruma/src/regerror.c +112 -91
- package/deps/jq/modules/oniguruma/src/regexec.c +4876 -2010
- package/deps/jq/modules/oniguruma/src/regext.c +8 -8
- package/deps/jq/modules/oniguruma/src/reggnu.c +13 -17
- package/deps/jq/modules/oniguruma/src/regint.h +757 -491
- package/deps/jq/modules/oniguruma/src/regparse.c +7204 -3240
- package/deps/jq/modules/oniguruma/src/regparse.h +361 -218
- package/deps/jq/modules/oniguruma/src/regposerr.c +49 -9
- package/deps/jq/modules/oniguruma/src/regposix.c +106 -24
- package/deps/jq/modules/oniguruma/src/regsyntax.c +66 -13
- package/deps/jq/modules/oniguruma/src/regtrav.c +1 -1
- package/deps/jq/modules/oniguruma/src/regversion.c +6 -4
- package/deps/jq/modules/oniguruma/src/sjis.c +23 -52
- package/deps/jq/modules/oniguruma/src/sjis_prop.c +25 -32
- package/deps/jq/modules/oniguruma/src/sjis_prop.gperf +1 -2
- package/deps/jq/modules/oniguruma/src/st.c +248 -249
- package/deps/jq/modules/oniguruma/src/st.h +4 -5
- package/deps/jq/modules/oniguruma/src/unicode.c +869 -294
- package/deps/jq/modules/oniguruma/src/unicode_egcb_data.c +1419 -0
- package/deps/jq/modules/oniguruma/src/unicode_fold1_key.c +1829 -1300
- package/deps/jq/modules/oniguruma/src/unicode_fold2_key.c +32 -9
- package/deps/jq/modules/oniguruma/src/unicode_fold3_key.c +32 -9
- package/deps/jq/modules/oniguruma/src/unicode_fold_data.c +1210 -984
- package/deps/jq/modules/oniguruma/src/unicode_property_data.c +22480 -15198
- package/deps/jq/modules/oniguruma/src/unicode_property_data_posix.c +1463 -591
- package/deps/jq/modules/oniguruma/src/unicode_unfold_key.c +1958 -1418
- package/deps/jq/modules/oniguruma/src/unicode_wb_data.c +1106 -0
- package/deps/jq/modules/oniguruma/src/utf16_be.c +90 -49
- package/deps/jq/modules/oniguruma/src/utf16_le.c +80 -49
- package/deps/jq/modules/oniguruma/src/utf32_be.c +14 -42
- package/deps/jq/modules/oniguruma/src/utf32_le.c +13 -40
- package/deps/jq/modules/oniguruma/src/utf8.c +33 -78
- package/deps/jq/modules/oniguruma/test/CMakeLists.txt +55 -0
- package/deps/jq/modules/oniguruma/test/Makefile.am +65 -10
- package/deps/jq/modules/oniguruma/test/test.sh +17 -0
- package/deps/jq/modules/oniguruma/test/test_back.c +1450 -0
- package/deps/jq/modules/oniguruma/test/test_options.c +228 -0
- package/deps/jq/modules/oniguruma/test/test_regset.c +466 -0
- package/deps/jq/modules/oniguruma/test/test_syntax.c +365 -0
- package/deps/jq/modules/oniguruma/test/test_utf8.c +1761 -0
- package/deps/jq/modules/oniguruma/test/testc.c +128 -88
- package/deps/jq/modules/oniguruma/test/testp.c +613 -0
- package/deps/jq/modules/oniguruma/test/testu.c +75 -28
- package/deps/jq/modules/oniguruma/tis-ci/stub.c +3 -0
- package/deps/jq/modules/oniguruma/tis-ci/test_back.config +26 -0
- package/deps/jq/modules/oniguruma/tis-ci/test_regset.config +20 -0
- package/deps/jq/modules/oniguruma/tis-ci/test_syntax.config +26 -0
- package/deps/jq/modules/oniguruma/tis-ci/test_utf8.config +25 -0
- package/deps/jq/modules/oniguruma/tis-ci/testc.config +26 -0
- package/deps/jq/modules/oniguruma/tis-ci/testu.config +24 -0
- package/deps/jq/modules/oniguruma/tis.config +1336 -0
- package/deps/jq/modules/oniguruma/windows/CMakeLists.txt +8 -0
- package/deps/jq/modules/oniguruma/windows/testc.c +865 -869
- package/deps/jq/scripts/update-website +6 -5
- package/deps/jq/scripts/version +10 -7
- package/deps/jq/sig/jq-release-new.key +29 -0
- package/deps/jq/sig/v1.4/sha256sum.txt +1 -0
- package/deps/jq/sig/v1.5/sha256sum.txt +2 -0
- package/deps/jq/sig/v1.5rc1/sha256sum.txt +1 -0
- package/deps/jq/sig/v1.5rc2/sha256sum.txt +2 -0
- package/deps/jq/sig/v1.6/sha256sum.txt +2 -0
- package/deps/jq/sig/v1.7/jq-1.7.tar.gz.asc +16 -0
- package/deps/jq/sig/v1.7/jq-1.7.zip.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-amd64.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-arm64.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-armel.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-armhf.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-i386.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mips.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mips64.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mips64el.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mips64r6.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mips64r6el.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mipsel.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mipsr6.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mipsr6el.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-powerpc.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-ppc64el.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-riscv64.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-s390x.asc +16 -0
- package/deps/jq/sig/v1.7/jq-macos-amd64.asc +16 -0
- package/deps/jq/sig/v1.7/jq-macos-arm64.asc +16 -0
- package/deps/jq/sig/v1.7/jq-windows-amd64.exe.asc +16 -0
- package/deps/jq/sig/v1.7/jq-windows-i386.exe.asc +16 -0
- package/deps/jq/sig/v1.7/sha256sum.txt +23 -0
- package/deps/jq/sig/v1.7.1/jq-1.7.1.tar.gz.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-1.7.1.zip.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-amd64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-arm64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-armel.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-armhf.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-i386.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips64el.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips64r6.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips64r6el.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mipsel.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mipsr6.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mipsr6el.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-powerpc.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-ppc64el.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-riscv64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-s390x.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-macos-amd64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-macos-arm64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-osx-amd64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-win64.exe.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-windows-amd64.exe.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-windows-i386.exe.asc +16 -0
- package/deps/jq/sig/v1.7.1/sha256sum.txt +26 -0
- package/deps/jq/sig/v1.7rc1/jq-1.7rc1.tar.gz.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-1.7rc1.zip.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-amd64.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-arm64.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-armel.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-armhf.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-i386.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mips.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mips64.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mips64el.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mips64r6.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mips64r6el.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mipsel.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mipsr6.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mipsr6el.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-powerpc.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-ppc64el.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-riscv64.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-s390x.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-macos-amd64.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-macos-arm64.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-windows-amd64.exe.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-windows-i386.exe.asc +16 -0
- package/deps/jq/sig/v1.7rc1/sha256sum.txt +23 -0
- package/deps/jq/sig/v1.7rc2/jq-1.7rc2.tar.gz.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-1.7rc2.zip.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-amd64.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-arm64.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-armel.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-armhf.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-i386.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mips.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mips64.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mips64el.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mips64r6.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mips64r6el.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mipsel.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mipsr6.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mipsr6el.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-powerpc.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-ppc64el.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-riscv64.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-s390x.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-macos-amd64.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-macos-arm64.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-windows-amd64.exe.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-windows-i386.exe.asc +16 -0
- package/deps/jq/sig/v1.7rc2/sha256sum.txt +23 -0
- package/deps/jq/src/builtin.c +537 -343
- package/deps/jq/src/builtin.h +18 -0
- package/deps/jq/src/builtin.jq +116 -143
- package/deps/jq/src/bytecode.h +8 -4
- package/deps/jq/src/compile.c +157 -143
- package/deps/jq/src/compile.h +3 -4
- package/deps/jq/src/decNumber/ICU-license.html +45 -0
- package/deps/jq/src/decNumber/decBasic.c +3908 -0
- package/deps/jq/src/decNumber/decCommon.c +1835 -0
- package/deps/jq/src/decNumber/decContext.c +437 -0
- package/deps/jq/src/decNumber/decContext.h +254 -0
- package/deps/jq/src/decNumber/decDPD.h +1185 -0
- package/deps/jq/src/decNumber/decDouble.c +140 -0
- package/deps/jq/src/decNumber/decDouble.h +155 -0
- package/deps/jq/src/decNumber/decNumber.c +8143 -0
- package/deps/jq/src/decNumber/decNumber.h +182 -0
- package/deps/jq/src/decNumber/decNumberLocal.h +757 -0
- package/deps/jq/src/decNumber/decPacked.c +220 -0
- package/deps/jq/src/decNumber/decPacked.h +52 -0
- package/deps/jq/src/decNumber/decQuad.c +135 -0
- package/deps/jq/src/decNumber/decQuad.h +177 -0
- package/deps/jq/src/decNumber/decSingle.c +71 -0
- package/deps/jq/src/decNumber/decSingle.h +86 -0
- package/deps/jq/src/decNumber/decimal128.c +553 -0
- package/deps/jq/src/decNumber/decimal128.h +81 -0
- package/deps/jq/src/decNumber/decimal32.c +476 -0
- package/deps/jq/src/decNumber/decimal32.h +81 -0
- package/deps/jq/src/decNumber/decimal64.c +839 -0
- package/deps/jq/src/decNumber/decimal64.h +83 -0
- package/deps/jq/src/decNumber/decnumber.pdf +0 -0
- package/deps/jq/src/decNumber/example1.c +38 -0
- package/deps/jq/src/decNumber/example2.c +52 -0
- package/deps/jq/src/decNumber/example3.c +64 -0
- package/deps/jq/src/decNumber/example4.c +61 -0
- package/deps/jq/src/decNumber/example5.c +36 -0
- package/deps/jq/src/decNumber/example6.c +61 -0
- package/deps/jq/src/decNumber/example7.c +35 -0
- package/deps/jq/src/decNumber/example8.c +39 -0
- package/deps/jq/src/decNumber/readme.txt +81 -0
- package/deps/jq/src/exec_stack.h +5 -3
- package/deps/jq/src/execute.c +126 -44
- package/deps/jq/src/inject_errors.c +0 -2
- package/deps/jq/src/jq.h +10 -1
- package/deps/jq/src/jq_test.c +222 -11
- package/deps/jq/src/jv.c +807 -176
- package/deps/jq/src/jv.h +22 -1
- package/deps/jq/src/jv_alloc.c +33 -26
- package/deps/jq/src/jv_alloc.h +0 -11
- package/deps/jq/src/jv_aux.c +153 -67
- package/deps/jq/src/jv_dtoa.c +12 -2
- package/deps/jq/src/jv_dtoa_tsd.c +51 -0
- package/deps/jq/src/jv_dtoa_tsd.h +4 -0
- package/deps/jq/src/jv_parse.c +70 -15
- package/deps/jq/src/jv_print.c +56 -60
- package/deps/jq/src/jv_private.h +7 -0
- package/deps/jq/src/jv_thread.h +76 -0
- package/deps/jq/src/jv_unicode.c +18 -0
- package/deps/jq/src/jv_unicode.h +2 -0
- package/deps/jq/src/lexer.c +782 -543
- package/deps/jq/src/lexer.h +438 -64
- package/deps/jq/src/lexer.l +10 -3
- package/deps/jq/src/libm.h +16 -6
- package/deps/jq/src/linker.c +97 -40
- package/deps/jq/src/locfile.c +2 -1
- package/deps/jq/src/main.c +384 -336
- package/deps/jq/src/opcode_list.h +5 -2
- package/deps/jq/src/parser.c +2260 -1898
- package/deps/jq/src/parser.h +115 -98
- package/deps/jq/src/parser.y +124 -89
- package/deps/jq/src/util.c +854 -55
- package/deps/jq/src/util.h +6 -4
- package/deps/jq/tests/jq.test +762 -26
- package/deps/jq/tests/jq_fuzz_compile.c +27 -0
- package/deps/jq/tests/jq_fuzz_execute.cpp +42 -0
- package/deps/jq/tests/jq_fuzz_fixed.cpp +297 -0
- package/deps/jq/tests/jq_fuzz_load_file.c +28 -0
- package/deps/jq/tests/jq_fuzz_parse.c +21 -0
- package/deps/jq/tests/jq_fuzz_parse_extended.c +36 -0
- package/deps/jq/tests/jq_fuzz_parse_stream.c +21 -0
- package/deps/jq/tests/local.supp +14 -0
- package/deps/jq/tests/man.test +979 -0
- package/deps/jq/tests/manonig.test +76 -0
- package/deps/jq/tests/manonigtest +5 -0
- package/deps/jq/tests/mantest +1 -2
- package/deps/jq/tests/modules/home2/.jq/g.jq +1 -0
- package/deps/jq/tests/modules/shadow1.jq +2 -0
- package/deps/jq/tests/modules/shadow2.jq +1 -0
- package/deps/jq/tests/modules/test_bind_order0.jq +1 -0
- package/deps/jq/tests/modules/test_bind_order1.jq +1 -1
- package/deps/jq/tests/modules/test_bind_order2.jq +0 -1
- package/deps/jq/tests/no-main-program.jq +1 -0
- package/deps/jq/tests/onig.test +77 -2
- package/deps/jq/tests/setup +7 -2
- package/deps/jq/tests/shtest +478 -59
- package/deps/jq/tests/uri.test +38 -0
- package/deps/jq/tests/uritest +5 -0
- package/deps/jq/tests/yes-main-program.jq +2 -0
- package/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/jq.js +15 -1
- package/lib/templateAsync.js +137 -0
- package/package.json +3 -3
- package/src/binding.cc +623 -146
- package/src/binding.h +3 -4
- package/test/santiy-async.test.js +171 -0
- package/test/santiy.test.js +2 -2
- package/test/template-async.test.js +182 -0
- package/test/template.test.js +3 -3
- package/deps/jq/.travis.yml +0 -202
- package/deps/jq/NEWS +0 -89
- package/deps/jq/appveyor.yml +0 -53
- package/deps/jq/docs/Gemfile +0 -7
- package/deps/jq/docs/Gemfile.lock +0 -63
- package/deps/jq/docs/Rakefile +0 -24
- package/deps/jq/docs/Rakefile.manual +0 -49
- package/deps/jq/docs/Rakefile.website +0 -76
- package/deps/jq/docs/content/1.tutorial/default.yml +0 -327
- package/deps/jq/docs/content/2.download/default.yml +0 -193
- package/deps/jq/docs/content/index/index.yml +0 -73
- package/deps/jq/docs/public/css/base.scss +0 -181
- package/deps/jq/docs/public/jq.png +0 -0
- package/deps/jq/docs/site.yml +0 -9
- package/deps/jq/docs/templates/default.liquid +0 -34
- package/deps/jq/docs/templates/index.liquid +0 -73
- package/deps/jq/docs/templates/manual.liquid +0 -99
- package/deps/jq/docs/templates/shared/_footer.liquid +0 -10
- package/deps/jq/docs/templates/shared/_head.liquid +0 -17
- package/deps/jq/docs/templates/shared/_navbar.liquid +0 -27
- package/deps/jq/modules/oniguruma/README.ja +0 -195
- package/deps/jq/modules/oniguruma/cmake/dist.cmake +0 -321
- package/deps/jq/modules/oniguruma/contributed/libfuzzer-onig.cpp +0 -31
- package/deps/jq/modules/oniguruma/dist.info +0 -10
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold1_key.c +0 -2250
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold2_key.c +0 -203
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold3_key.c +0 -113
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold_data.c +0 -1225
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data.c +0 -24742
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data_posix.c +0 -4846
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_unfold_key.c +0 -2571
- /package/deps/jq/sig/{jq-release.key → jq-release-old.key} +0 -0
- /package/deps/jq/tests/modules/{.jq → home1/.jq} +0 -0
package/deps/jq/jq.1.prebuilt
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
.\" generated with Ronn/v0.7.3
|
|
2
|
-
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
|
3
1
|
.
|
|
4
|
-
.TH "JQ" "1" "
|
|
2
|
+
.TH "JQ" "1" "November 2024" "" ""
|
|
5
3
|
.
|
|
6
4
|
.SH "NAME"
|
|
7
5
|
\fBjq\fR \- Command\-line JSON processor
|
|
@@ -16,7 +14,7 @@
|
|
|
16
14
|
\fBjq\fR can accept text input as well, but by default, \fBjq\fR reads a stream of JSON entities (including numbers and other literals) from \fBstdin\fR\. Whitespace is only needed to separate entities such as 1 and 2, and true and false\. One or more \fIfiles\fR may be specified, in which case \fBjq\fR will read input from those instead\.
|
|
17
15
|
.
|
|
18
16
|
.P
|
|
19
|
-
The \fIoptions\fR are described in the
|
|
17
|
+
The \fIoptions\fR are described in the [INVOKING JQ] section; they mostly concern input and output formatting\. The \fIfilter\fR is written in the jq language and specifies how to transform the input file or document\.
|
|
20
18
|
.
|
|
21
19
|
.SH "FILTERS"
|
|
22
20
|
A jq program is a "filter": it takes an input, and produces an output\. There are a lot of builtin filters for extracting a particular field of an object, or converting a number to a string, or various other standard tasks\.
|
|
@@ -34,191 +32,279 @@ It\'s important to remember that every filter has an input and an output\. Even
|
|
|
34
32
|
But that\'s getting ahead of ourselves\. :) Let\'s start with something simpler:
|
|
35
33
|
.
|
|
36
34
|
.SH "INVOKING JQ"
|
|
37
|
-
jq filters run on a stream of JSON data\. The input to jq is parsed as a sequence of whitespace\-separated JSON values which are passed through the provided filter one at a time\. The output(s) of the filter are written to standard
|
|
35
|
+
jq filters run on a stream of JSON data\. The input to jq is parsed as a sequence of whitespace\-separated JSON values which are passed through the provided filter one at a time\. The output(s) of the filter are written to standard output, as a sequence of newline\-separated JSON data\.
|
|
38
36
|
.
|
|
39
37
|
.P
|
|
40
|
-
|
|
38
|
+
The simplest and most common filter (or jq program) is \fB\.\fR, which is the identity operator, copying the inputs of the jq processor to the output stream\. Because the default behavior of the jq processor is to read JSON texts from the input stream, and to pretty\-print outputs, the \fB\.\fR program\'s main use is to validate and pretty\-print the inputs\. The jq programming language is quite rich and allows for much more than just validation and pretty\-printing\.
|
|
41
39
|
.
|
|
42
40
|
.P
|
|
43
|
-
|
|
41
|
+
Note: it is important to mind the shell\'s quoting rules\. As a general rule it\'s best to always quote (with single\-quote characters on Unix shells) the jq program, as too many characters with special meaning to jq are also shell meta\-characters\. For example, \fBjq "foo"\fR will fail on most Unix shells because that will be the same as \fBjq foo\fR, which will generally fail because \fBfoo is not defined\fR\. When using the Windows command shell (cmd\.exe) it\'s best to use double quotes around your jq program when given on the command\-line (instead of the \fB\-f program\-file\fR option), but then double\-quotes in the jq program need backslash escaping\. When using the Powershell (\fBpowershell\.exe\fR) or the Powershell Core (\fBpwsh\fR/\fBpwsh\.exe\fR), use single\-quote characters around the jq program and backslash\-escaped double\-quotes (\fB\e"\fR) inside the jq program\.
|
|
44
42
|
.
|
|
45
43
|
.IP "\(bu" 4
|
|
46
|
-
\
|
|
44
|
+
Unix shells: \fBjq \'\.["foo"]\'\fR
|
|
47
45
|
.
|
|
48
|
-
.IP
|
|
49
|
-
|
|
46
|
+
.IP "\(bu" 4
|
|
47
|
+
Powershell: \fBjq \'\.[\e"foo\e"]\'\fR
|
|
50
48
|
.
|
|
51
49
|
.IP "\(bu" 4
|
|
52
|
-
\
|
|
50
|
+
Windows command shell: \fBjq "\.[\e"foo\e"]"\fR
|
|
53
51
|
.
|
|
54
|
-
.IP
|
|
55
|
-
Use the \fBapplication/json\-seq\fR MIME type scheme for separating JSON texts in jq\'s input and output\. This means that an ASCII RS (record separator) character is printed before each value on output and an ASCII LF (line feed) is printed after every output\. Input JSON texts that fail to parse are ignored (but warned about), discarding all subsequent input until the next RS\. This mode also parses the output of jq without the \fB\-\-seq\fR option\.
|
|
52
|
+
.IP "" 0
|
|
56
53
|
.
|
|
57
|
-
.
|
|
58
|
-
|
|
54
|
+
.P
|
|
55
|
+
Note: jq allows user\-defined functions, but every jq program must have a top\-level expression\.
|
|
56
|
+
.
|
|
57
|
+
.P
|
|
58
|
+
You can affect how jq reads and writes its input and output using some command\-line options:
|
|
59
|
+
.
|
|
60
|
+
.TP
|
|
61
|
+
\fB\-\-null\-input\fR / \fB\-n\fR:
|
|
59
62
|
.
|
|
60
63
|
.IP
|
|
61
|
-
|
|
64
|
+
Don\'t read any input at all\. Instead, the filter is run once using \fBnull\fR as the input\. This is useful when using jq as a simple calculator or to construct JSON data from scratch\.
|
|
65
|
+
.
|
|
66
|
+
.TP
|
|
67
|
+
\fB\-\-raw\-input\fR / \fB\-R\fR:
|
|
62
68
|
.
|
|
63
69
|
.IP
|
|
64
|
-
|
|
70
|
+
Don\'t parse the input as JSON\. Instead, each line of text is passed to the filter as a string\. If combined with \fB\-\-slurp\fR, then the entire input is passed to the filter as a single long string\.
|
|
65
71
|
.
|
|
66
|
-
.
|
|
67
|
-
\fB\-\-slurp\fR
|
|
72
|
+
.TP
|
|
73
|
+
\fB\-\-slurp\fR / \fB\-s\fR:
|
|
68
74
|
.
|
|
69
75
|
.IP
|
|
70
76
|
Instead of running the filter for each JSON object in the input, read the entire input stream into a large array and run the filter just once\.
|
|
71
77
|
.
|
|
72
|
-
.
|
|
73
|
-
\fB\-\-
|
|
78
|
+
.TP
|
|
79
|
+
\fB\-\-compact\-output\fR / \fB\-c\fR:
|
|
74
80
|
.
|
|
75
81
|
.IP
|
|
76
|
-
|
|
82
|
+
By default, jq pretty\-prints JSON output\. Using this option will result in more compact output by instead putting each JSON object on a single line\.
|
|
77
83
|
.
|
|
78
|
-
.
|
|
79
|
-
\fB\-\-
|
|
84
|
+
.TP
|
|
85
|
+
\fB\-\-raw\-output\fR / \fB\-r\fR:
|
|
80
86
|
.
|
|
81
87
|
.IP
|
|
82
|
-
|
|
88
|
+
With this option, if the filter\'s result is a string then it will be written directly to standard output rather than being formatted as a JSON string with quotes\. This can be useful for making jq filters talk to non\-JSON\-based systems\.
|
|
83
89
|
.
|
|
84
|
-
.
|
|
85
|
-
\fB\-\-
|
|
90
|
+
.TP
|
|
91
|
+
\fB\-\-raw\-output0\fR:
|
|
86
92
|
.
|
|
87
93
|
.IP
|
|
88
|
-
|
|
94
|
+
Like \fB\-r\fR but jq will print NUL instead of newline after each output\. This can be useful when the values being output can contain newlines\. When the output value contains NUL, jq exits with non\-zero code\.
|
|
89
95
|
.
|
|
90
|
-
.
|
|
91
|
-
\fB\-\-
|
|
96
|
+
.TP
|
|
97
|
+
\fB\-\-join\-output\fR / \fB\-j\fR:
|
|
92
98
|
.
|
|
93
99
|
.IP
|
|
94
|
-
|
|
100
|
+
Like \fB\-r\fR but jq won\'t print a newline after each output\.
|
|
95
101
|
.
|
|
96
|
-
.
|
|
97
|
-
\fB\-\-
|
|
102
|
+
.TP
|
|
103
|
+
\fB\-\-ascii\-output\fR / \fB\-a\fR:
|
|
98
104
|
.
|
|
99
105
|
.IP
|
|
100
|
-
|
|
106
|
+
jq usually outputs non\-ASCII Unicode codepoints as UTF\-8, even if the input specified them as escape sequences (like "\eu03bc")\. Using this option, you can force jq to produce pure ASCII output with every non\-ASCII character replaced with the equivalent escape sequence\.
|
|
101
107
|
.
|
|
102
|
-
.
|
|
108
|
+
.TP
|
|
109
|
+
\fB\-\-sort\-keys\fR / \fB\-S\fR:
|
|
110
|
+
.
|
|
111
|
+
.IP
|
|
112
|
+
Output the fields of each object with the keys in sorted order\.
|
|
113
|
+
.
|
|
114
|
+
.TP
|
|
103
115
|
\fB\-\-color\-output\fR / \fB\-C\fR and \fB\-\-monochrome\-output\fR / \fB\-M\fR:
|
|
104
116
|
.
|
|
105
117
|
.IP
|
|
106
|
-
By default, jq outputs colored JSON if writing to a terminal\. You can force it to produce color even if writing to a pipe or a file using \fB\-C\fR, and disable color with \fB\-M\fR\.
|
|
118
|
+
By default, jq outputs colored JSON if writing to a terminal\. You can force it to produce color even if writing to a pipe or a file using \fB\-C\fR, and disable color with \fB\-M\fR\. When the \fBNO_COLOR\fR environment variable is not empty, jq disables colored output by default, but you can enable it by \fB\-C\fR\.
|
|
107
119
|
.
|
|
108
120
|
.IP
|
|
109
121
|
Colors can be configured with the \fBJQ_COLORS\fR environment variable (see below)\.
|
|
110
122
|
.
|
|
111
|
-
.
|
|
112
|
-
\fB\-\-
|
|
123
|
+
.TP
|
|
124
|
+
\fB\-\-tab\fR:
|
|
113
125
|
.
|
|
114
126
|
.IP
|
|
115
|
-
|
|
127
|
+
Use a tab for each indentation level instead of two spaces\.
|
|
116
128
|
.
|
|
117
|
-
.
|
|
118
|
-
\fB\-\-
|
|
129
|
+
.TP
|
|
130
|
+
\fB\-\-indent n\fR:
|
|
119
131
|
.
|
|
120
132
|
.IP
|
|
121
|
-
|
|
133
|
+
Use the given number of spaces (no more than 7) for indentation\.
|
|
122
134
|
.
|
|
123
|
-
.
|
|
124
|
-
\fB\-\-
|
|
135
|
+
.TP
|
|
136
|
+
\fB\-\-unbuffered\fR:
|
|
125
137
|
.
|
|
126
138
|
.IP
|
|
127
|
-
|
|
139
|
+
Flush the output after each JSON object is printed (useful if you\'re piping a slow data source into jq and piping jq\'s output elsewhere)\.
|
|
128
140
|
.
|
|
129
|
-
.
|
|
130
|
-
\fB\-\-
|
|
141
|
+
.TP
|
|
142
|
+
\fB\-\-stream\fR:
|
|
131
143
|
.
|
|
132
144
|
.IP
|
|
133
|
-
|
|
134
|
-
.
|
|
135
|
-
.IP "\(bu" 4
|
|
136
|
-
\fB\-\-join\-output\fR / \fB\-j\fR:
|
|
145
|
+
Parse the input in streaming fashion, outputting arrays of path and leaf values (scalars and empty arrays or empty objects)\. For example, \fB"a"\fR becomes \fB[[],"a"]\fR, and \fB[[],"a",["b"]]\fR becomes \fB[[0],[]]\fR, \fB[[1],"a"]\fR, and \fB[[2,0],"b"]\fR\.
|
|
137
146
|
.
|
|
138
147
|
.IP
|
|
139
|
-
|
|
148
|
+
This is useful for processing very large inputs\. Use this in conjunction with filtering and the \fBreduce\fR and \fBforeach\fR syntax to reduce large inputs incrementally\.
|
|
140
149
|
.
|
|
141
|
-
.
|
|
142
|
-
\fB
|
|
150
|
+
.TP
|
|
151
|
+
\fB\-\-stream\-errors\fR:
|
|
143
152
|
.
|
|
144
153
|
.IP
|
|
145
|
-
|
|
154
|
+
Like \fB\-\-stream\fR, but invalid JSON inputs yield array values where the first element is the error and the second is a path\. For example, \fB["a",n]\fR produces \fB["Invalid literal at line 1, column 7",[1]]\fR\.
|
|
146
155
|
.
|
|
147
|
-
.IP
|
|
148
|
-
\fB
|
|
156
|
+
.IP
|
|
157
|
+
Implies \fB\-\-stream\fR\. Invalid JSON inputs produce no error values when \fB\-\-stream\fR without \fB\-\-stream\-errors\fR\.
|
|
158
|
+
.
|
|
159
|
+
.TP
|
|
160
|
+
\fB\-\-seq\fR:
|
|
149
161
|
.
|
|
150
162
|
.IP
|
|
151
|
-
|
|
163
|
+
Use the \fBapplication/json\-seq\fR MIME type scheme for separating JSON texts in jq\'s input and output\. This means that an ASCII RS (record separator) character is printed before each value on output and an ASCII LF (line feed) is printed after every output\. Input JSON texts that fail to parse are ignored (but warned about), discarding all subsequent input until the next RS\. This mode also parses the output of jq without the \fB\-\-seq\fR option\.
|
|
152
164
|
.
|
|
153
|
-
.
|
|
154
|
-
\fB\-
|
|
165
|
+
.TP
|
|
166
|
+
\fB\-f\fR / \fB\-\-from\-file\fR:
|
|
155
167
|
.
|
|
156
168
|
.IP
|
|
157
|
-
|
|
169
|
+
Read the filter from a file rather than from a command line, like awk\'s \-f option\. This changes the filter argument to be interpreted as a filename, instead of the source of a program\.
|
|
170
|
+
.
|
|
171
|
+
.TP
|
|
172
|
+
\fB\-L directory\fR / \fB\-\-library\-path directory\fR:
|
|
158
173
|
.
|
|
159
174
|
.IP
|
|
160
|
-
|
|
175
|
+
Prepend \fBdirectory\fR to the search list for modules\. If this option is used then no builtin search list is used\. See the section on modules below\.
|
|
161
176
|
.
|
|
162
|
-
.
|
|
177
|
+
.TP
|
|
163
178
|
\fB\-\-arg name value\fR:
|
|
164
179
|
.
|
|
165
180
|
.IP
|
|
166
181
|
This option passes a value to the jq program as a predefined variable\. If you run jq with \fB\-\-arg foo bar\fR, then \fB$foo\fR is available in the program and has the value \fB"bar"\fR\. Note that \fBvalue\fR will be treated as a string, so \fB\-\-arg foo 123\fR will bind \fB$foo\fR to \fB"123"\fR\.
|
|
167
182
|
.
|
|
168
183
|
.IP
|
|
169
|
-
Named arguments are also available to the jq program as \fB$ARGS\.named\fR\.
|
|
184
|
+
Named arguments are also available to the jq program as \fB$ARGS\.named\fR\. When the name is not a valid identifier, this is the only way to access it\.
|
|
170
185
|
.
|
|
171
|
-
.
|
|
186
|
+
.TP
|
|
172
187
|
\fB\-\-argjson name JSON\-text\fR:
|
|
173
188
|
.
|
|
174
189
|
.IP
|
|
175
190
|
This option passes a JSON\-encoded value to the jq program as a predefined variable\. If you run jq with \fB\-\-argjson foo 123\fR, then \fB$foo\fR is available in the program and has the value \fB123\fR\.
|
|
176
191
|
.
|
|
177
|
-
.
|
|
192
|
+
.TP
|
|
178
193
|
\fB\-\-slurpfile variable\-name filename\fR:
|
|
179
194
|
.
|
|
180
195
|
.IP
|
|
181
|
-
This option reads all the JSON texts in the named file and binds an array of the parsed JSON values to the given global variable\. If you run jq with \fB\-\-
|
|
196
|
+
This option reads all the JSON texts in the named file and binds an array of the parsed JSON values to the given global variable\. If you run jq with \fB\-\-slurpfile foo bar\fR, then \fB$foo\fR is available in the program and has an array whose elements correspond to the texts in the file named \fBbar\fR\.
|
|
182
197
|
.
|
|
183
|
-
.
|
|
184
|
-
\fB\-\-
|
|
185
|
-
.
|
|
186
|
-
.IP
|
|
187
|
-
Do not use\. Use \fB\-\-slurpfile\fR instead\.
|
|
198
|
+
.TP
|
|
199
|
+
\fB\-\-rawfile variable\-name filename\fR:
|
|
188
200
|
.
|
|
189
201
|
.IP
|
|
190
|
-
|
|
202
|
+
This option reads in the named file and binds its contents to the given global variable\. If you run jq with \fB\-\-rawfile foo bar\fR, then \fB$foo\fR is available in the program and has a string whose contents are to the texts in the file named \fBbar\fR\.
|
|
191
203
|
.
|
|
192
|
-
.
|
|
204
|
+
.TP
|
|
193
205
|
\fB\-\-args\fR:
|
|
194
206
|
.
|
|
195
207
|
.IP
|
|
196
208
|
Remaining arguments are positional string arguments\. These are available to the jq program as \fB$ARGS\.positional[]\fR\.
|
|
197
209
|
.
|
|
198
|
-
.
|
|
210
|
+
.TP
|
|
199
211
|
\fB\-\-jsonargs\fR:
|
|
200
212
|
.
|
|
201
213
|
.IP
|
|
202
214
|
Remaining arguments are positional JSON text arguments\. These are available to the jq program as \fB$ARGS\.positional[]\fR\.
|
|
203
215
|
.
|
|
204
|
-
.
|
|
216
|
+
.TP
|
|
217
|
+
\fB\-\-exit\-status\fR / \fB\-e\fR:
|
|
218
|
+
.
|
|
219
|
+
.IP
|
|
220
|
+
Sets the exit status of jq to 0 if the last output value was neither \fBfalse\fR nor \fBnull\fR, 1 if the last output value was either \fBfalse\fR or \fBnull\fR, or 4 if no valid result was ever produced\. Normally jq exits with 2 if there was any usage problem or system error, 3 if there was a jq program compile error, or 0 if the jq program ran\.
|
|
221
|
+
.
|
|
222
|
+
.IP
|
|
223
|
+
Another way to set the exit status is with the \fBhalt_error\fR builtin function\.
|
|
224
|
+
.
|
|
225
|
+
.TP
|
|
226
|
+
\fB\-\-binary\fR / \fB\-b\fR:
|
|
227
|
+
.
|
|
228
|
+
.IP
|
|
229
|
+
Windows users using WSL, MSYS2, or Cygwin, should use this option when using a native jq\.exe, otherwise jq will turn newlines (LFs) into carriage\-return\-then\-newline (CRLF)\.
|
|
230
|
+
.
|
|
231
|
+
.TP
|
|
232
|
+
\fB\-\-version\fR / \fB\-V\fR:
|
|
233
|
+
.
|
|
234
|
+
.IP
|
|
235
|
+
Output the jq version and exit with zero\.
|
|
236
|
+
.
|
|
237
|
+
.TP
|
|
238
|
+
\fB\-\-build\-configuration\fR:
|
|
239
|
+
.
|
|
240
|
+
.IP
|
|
241
|
+
Output the build configuration of jq and exit with zero\. This output has no supported format or structure and may change without notice in future releases\.
|
|
242
|
+
.
|
|
243
|
+
.TP
|
|
244
|
+
\fB\-\-help\fR / \fB\-h\fR:
|
|
245
|
+
.
|
|
246
|
+
.IP
|
|
247
|
+
Output the jq help and exit with zero\.
|
|
248
|
+
.
|
|
249
|
+
.TP
|
|
250
|
+
\fB\-\-\fR:
|
|
251
|
+
.
|
|
252
|
+
.IP
|
|
253
|
+
Terminates argument processing\. Remaining arguments are not interpreted as options\.
|
|
254
|
+
.
|
|
255
|
+
.TP
|
|
205
256
|
\fB\-\-run\-tests [filename]\fR:
|
|
206
257
|
.
|
|
207
258
|
.IP
|
|
208
|
-
Runs the tests in the given file or standard input\. This must be the last option given and does not honor all preceding options\. The input consists of comment lines, empty lines, and program lines followed by one input line, as many lines of output as are expected (one per output), and a terminating empty line\. Compilation failure tests start with a line containing only
|
|
259
|
+
Runs the tests in the given file or standard input\. This must be the last option given and does not honor all preceding options\. The input consists of comment lines, empty lines, and program lines followed by one input line, as many lines of output as are expected (one per output), and a terminating empty line\. Compilation failure tests start with a line containing only \fB%%FAIL\fR, then a line containing the program to compile, then a line containing an error message to compare to the actual\.
|
|
209
260
|
.
|
|
210
261
|
.IP
|
|
211
262
|
Be warned that this option can change backwards\-incompatibly\.
|
|
212
263
|
.
|
|
213
|
-
.IP "" 0
|
|
214
|
-
.
|
|
215
264
|
.SH "BASIC FILTERS"
|
|
216
265
|
.
|
|
217
266
|
.SS "Identity: \."
|
|
218
|
-
The absolute simplest filter is \fB\.\fR \. This
|
|
267
|
+
The absolute simplest filter is \fB\.\fR \. This filter takes its input and produces the same value as output\. That is, this is the identity operator\.
|
|
268
|
+
.
|
|
269
|
+
.P
|
|
270
|
+
Since jq by default pretty\-prints all output, a trivial program consisting of nothing but \fB\.\fR can be used to format JSON output from, say, \fBcurl\fR\.
|
|
271
|
+
.
|
|
272
|
+
.P
|
|
273
|
+
Although the identity filter never modifies the value of its input, jq processing can sometimes make it appear as though it does\. For example, using the current implementation of jq, we would see that the expression:
|
|
274
|
+
.
|
|
275
|
+
.IP "" 4
|
|
276
|
+
.
|
|
277
|
+
.nf
|
|
278
|
+
|
|
279
|
+
1E1234567890 | \.
|
|
280
|
+
.
|
|
281
|
+
.fi
|
|
282
|
+
.
|
|
283
|
+
.IP "" 0
|
|
284
|
+
.
|
|
285
|
+
.P
|
|
286
|
+
produces \fB1\.7976931348623157e+308\fR on at least one platform\. This is because, in the process of parsing the number, this particular version of jq has converted it to an IEEE754 double\-precision representation, losing precision\.
|
|
287
|
+
.
|
|
288
|
+
.P
|
|
289
|
+
The way in which jq handles numbers has changed over time and further changes are likely within the parameters set by the relevant JSON standards\. Moreover, build configuration options can alter how jq processes numbers\.
|
|
290
|
+
.
|
|
291
|
+
.P
|
|
292
|
+
The following remarks are therefore offered with the understanding that they are intended to be descriptive of the current version of jq and should not be interpreted as being prescriptive:
|
|
293
|
+
.
|
|
294
|
+
.P
|
|
295
|
+
(1) Any arithmetic operation on a number that has not already been converted to an IEEE754 double precision representation will trigger a conversion to the IEEE754 representation\.
|
|
296
|
+
.
|
|
297
|
+
.P
|
|
298
|
+
(2) jq will attempt to maintain the original decimal precision of number literals (if the \fB\-\-disable\-decnum\fR build configuration option was not used), but in expressions such \fB1E1234567890\fR, precision will be lost if the exponent is too large\.
|
|
299
|
+
.
|
|
300
|
+
.P
|
|
301
|
+
(3) In jq programs, a leading minus sign will trigger the conversion of the number to an IEEE754 representation\.
|
|
302
|
+
.
|
|
303
|
+
.P
|
|
304
|
+
(4) Comparisons are carried out using the untruncated big decimal representation of numbers if available, as illustrated in one of the following examples\.
|
|
219
305
|
.
|
|
220
306
|
.P
|
|
221
|
-
|
|
307
|
+
The examples below use the builtin function \fBhave_decnum\fR in order to demonstrate the expected effects of using / not using the \fB\-\-disable\-decnum\fR build configuration option, and also to allow automated tests derived from these examples to pass regardless of whether that option is used\.
|
|
222
308
|
.
|
|
223
309
|
.IP "" 4
|
|
224
310
|
.
|
|
@@ -227,25 +313,45 @@ Since jq by default pretty\-prints all output, this trivial program can be a use
|
|
|
227
313
|
jq \'\.\'
|
|
228
314
|
"Hello, world!"
|
|
229
315
|
=> "Hello, world!"
|
|
316
|
+
|
|
317
|
+
jq \'\.\'
|
|
318
|
+
0\.12345678901234567890123456789
|
|
319
|
+
=> 0\.12345678901234567890123456789
|
|
320
|
+
|
|
321
|
+
jq \'[\., tojson] | \. == if have_decnum then [12345678909876543212345,"12345678909876543212345"] else [12345678909876543000000,"12345678909876543000000"] end\'
|
|
322
|
+
12345678909876543212345
|
|
323
|
+
=> true
|
|
324
|
+
|
|
325
|
+
jq \'\. < 0\.12345678901234567890123456788\'
|
|
326
|
+
0\.12345678901234567890123456789
|
|
327
|
+
=> false
|
|
328
|
+
|
|
329
|
+
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\'
|
|
330
|
+
[1, 1\.000, 1\.0, 100e\-2]
|
|
331
|
+
=> true
|
|
332
|
+
|
|
333
|
+
jq \'\. as $big | [$big, $big + 1] | map(\. > 10000000000000000000000000000000) | \. == if have_decnum then [true, false] else [false, false] end\'
|
|
334
|
+
10000000000000000000000000000001
|
|
335
|
+
=> true
|
|
230
336
|
.
|
|
231
337
|
.fi
|
|
232
338
|
.
|
|
233
339
|
.IP "" 0
|
|
234
340
|
.
|
|
235
341
|
.SS "Object Identifier\-Index: \.foo, \.foo\.bar"
|
|
236
|
-
The simplest \fIuseful\fR filter
|
|
342
|
+
The simplest \fIuseful\fR filter has the form \fB\.foo\fR\. When given a JSON object (aka dictionary or hash) as input, \fB\.foo\fR produces the value at the key "foo" if the key is present, or null otherwise\.
|
|
237
343
|
.
|
|
238
344
|
.P
|
|
239
|
-
A filter of the form \fB\.foo\.bar\fR is equivalent to \fB\.foo
|
|
345
|
+
A filter of the form \fB\.foo\.bar\fR is equivalent to \fB\.foo | \.bar\fR\.
|
|
240
346
|
.
|
|
241
347
|
.P
|
|
242
|
-
|
|
348
|
+
The \fB\.foo\fR syntax only works for simple, identifier\-like keys, that is, keys that are all made of alphanumeric characters and underscore, and which do not start with a digit\.
|
|
243
349
|
.
|
|
244
350
|
.P
|
|
245
|
-
If the key contains special characters, you need to surround it with double quotes like this: \fB\."foo$"\fR, or else \fB\.["foo$"]\fR\.
|
|
351
|
+
If the key contains special characters or starts with a digit, you need to surround it with double quotes like this: \fB\."foo$"\fR, or else \fB\.["foo$"]\fR\.
|
|
246
352
|
.
|
|
247
353
|
.P
|
|
248
|
-
For example \fB\.["foo::bar"]\fR and \fB\.["foo\.bar"]\fR work while \fB\.foo::bar\fR does not
|
|
354
|
+
For example \fB\.["foo::bar"]\fR and \fB\.["foo\.bar"]\fR work while \fB\.foo::bar\fR does not\.
|
|
249
355
|
.
|
|
250
356
|
.IP "" 4
|
|
251
357
|
.
|
|
@@ -268,7 +374,7 @@ jq \'\.["foo"]\'
|
|
|
268
374
|
.IP "" 0
|
|
269
375
|
.
|
|
270
376
|
.SS "Optional Object Identifier\-Index: \.foo?"
|
|
271
|
-
Just like \fB\.foo\fR, but does not output
|
|
377
|
+
Just like \fB\.foo\fR, but does not output an error when \fB\.\fR is not an object\.
|
|
272
378
|
.
|
|
273
379
|
.IP "" 4
|
|
274
380
|
.
|
|
@@ -294,11 +400,11 @@ jq \'[\.foo?]\'
|
|
|
294
400
|
.
|
|
295
401
|
.IP "" 0
|
|
296
402
|
.
|
|
297
|
-
.SS "
|
|
298
|
-
You can also look up fields of an object using syntax like \fB\.["foo"]\fR (\.foo above is a shorthand version of this, but only for identifier\-like strings)\.
|
|
403
|
+
.SS "Object Index: \.[<string>]"
|
|
404
|
+
You can also look up fields of an object using syntax like \fB\.["foo"]\fR (\fB\.foo\fR above is a shorthand version of this, but only for identifier\-like strings)\.
|
|
299
405
|
.
|
|
300
|
-
.SS "Array Index: \.[
|
|
301
|
-
When the index value is an integer, \fB\.[<
|
|
406
|
+
.SS "Array Index: \.[<number>]"
|
|
407
|
+
When the index value is an integer, \fB\.[<number>]\fR can index arrays\. Arrays are zero\-based, so \fB\.[2]\fR returns the third element\.
|
|
302
408
|
.
|
|
303
409
|
.P
|
|
304
410
|
Negative indices are allowed, with \-1 referring to the last element, \-2 referring to the next to last element, and so on\.
|
|
@@ -323,8 +429,8 @@ jq \'\.[\-2]\'
|
|
|
323
429
|
.
|
|
324
430
|
.IP "" 0
|
|
325
431
|
.
|
|
326
|
-
.SS "Array/String Slice: \.[
|
|
327
|
-
The \fB\.[
|
|
432
|
+
.SS "Array/String Slice: \.[<number>:<number>]"
|
|
433
|
+
The \fB\.[<number>:<number>]\fR syntax can be used to return a subarray of an array or substring of a string\. The array returned by \fB\.[10:15]\fR will be of length 5, containing the elements from index 10 (inclusive) to index 15 (exclusive)\. Either index may be negative (in which case it counts backwards from the end of the array), or omitted (in which case it refers to the start or end of the array)\. Indices are zero\-based\.
|
|
328
434
|
.
|
|
329
435
|
.IP "" 4
|
|
330
436
|
.
|
|
@@ -351,11 +457,14 @@ jq \'\.[\-2:]\'
|
|
|
351
457
|
.IP "" 0
|
|
352
458
|
.
|
|
353
459
|
.SS "Array/Object Value Iterator: \.[]"
|
|
354
|
-
If you use the \fB\.[index]\fR syntax, but omit the index entirely, it will return \fIall\fR of the elements of an array\. Running \fB\.[]\fR with the input \fB[1,2,3]\fR will produce the numbers as three separate results, rather than as a single array\.
|
|
460
|
+
If you use the \fB\.[index]\fR syntax, but omit the index entirely, it will return \fIall\fR of the elements of an array\. Running \fB\.[]\fR with the input \fB[1,2,3]\fR will produce the numbers as three separate results, rather than as a single array\. A filter of the form \fB\.foo[]\fR is equivalent to \fB\.foo | \.[]\fR\.
|
|
355
461
|
.
|
|
356
462
|
.P
|
|
357
463
|
You can also use this on an object, and it will return all the values of the object\.
|
|
358
464
|
.
|
|
465
|
+
.P
|
|
466
|
+
Note that the iterator operator is a generator of values\.
|
|
467
|
+
.
|
|
359
468
|
.IP "" 4
|
|
360
469
|
.
|
|
361
470
|
.nf
|
|
@@ -366,7 +475,11 @@ jq \'\.[]\'
|
|
|
366
475
|
|
|
367
476
|
jq \'\.[]\'
|
|
368
477
|
[]
|
|
369
|
-
=>
|
|
478
|
+
=>
|
|
479
|
+
|
|
480
|
+
jq \'\.foo[]\'
|
|
481
|
+
{"foo":[1,2,3]}
|
|
482
|
+
=> 1, 2, 3
|
|
370
483
|
|
|
371
484
|
jq \'\.[]\'
|
|
372
485
|
{"a": 1, "b": 1}
|
|
@@ -377,11 +490,14 @@ jq \'\.[]\'
|
|
|
377
490
|
.IP "" 0
|
|
378
491
|
.
|
|
379
492
|
.SS "\.[]?"
|
|
380
|
-
Like \fB\.[]\fR, but no errors will be output if \. is not an array or object\.
|
|
493
|
+
Like \fB\.[]\fR, but no errors will be output if \. is not an array or object\. A filter of the form \fB\.foo[]?\fR is equivalent to \fB\.foo | \.[]?\fR\.
|
|
381
494
|
.
|
|
382
495
|
.SS "Comma: ,"
|
|
383
496
|
If two filters are separated by a comma, then the same input will be fed into both and the two filters\' output value streams will be concatenated in order: first, all of the outputs produced by the left expression, and then all of the outputs produced by the right\. For instance, filter \fB\.foo, \.bar\fR, produces both the "foo" fields and "bar" fields as separate outputs\.
|
|
384
497
|
.
|
|
498
|
+
.P
|
|
499
|
+
The \fB,\fR operator is one way to construct generators\.
|
|
500
|
+
.
|
|
385
501
|
.IP "" 4
|
|
386
502
|
.
|
|
387
503
|
.nf
|
|
@@ -403,10 +519,10 @@ jq \'\.[4,2]\'
|
|
|
403
519
|
.IP "" 0
|
|
404
520
|
.
|
|
405
521
|
.SS "Pipe: |"
|
|
406
|
-
The | operator combines two filters by feeding the output(s) of the one on the left into the input of the one on the right\. It\'s
|
|
522
|
+
The | operator combines two filters by feeding the output(s) of the one on the left into the input of the one on the right\. It\'s similar to the Unix shell\'s pipe, if you\'re used to that\.
|
|
407
523
|
.
|
|
408
524
|
.P
|
|
409
|
-
If the one on the left produces multiple results, the one on the right will be run for each of those results\. So, the expression \fB\.[] | \.foo\fR retrieves the "foo" field of each element of the input array\.
|
|
525
|
+
If the one on the left produces multiple results, the one on the right will be run for each of those results\. So, the expression \fB\.[] | \.foo\fR retrieves the "foo" field of each element of the input array\. This is a cartesian product, which can be surprising\.
|
|
410
526
|
.
|
|
411
527
|
.P
|
|
412
528
|
Note that \fB\.a\.b\.c\fR is the same as \fB\.a | \.b | \.c\fR\.
|
|
@@ -445,7 +561,13 @@ jq \'(\. + 2) * 5\'
|
|
|
445
561
|
jq supports the same set of datatypes as JSON \- numbers, strings, booleans, arrays, objects (which in JSON\-speak are hashes with only string keys), and "null"\.
|
|
446
562
|
.
|
|
447
563
|
.P
|
|
448
|
-
Booleans, null, strings and numbers are written the same way as in
|
|
564
|
+
Booleans, null, strings and numbers are written the same way as in JSON\. Just like everything else in jq, these simple values take an input and produce an output \- \fB42\fR is a valid jq expression that takes an input, ignores it, and returns 42 instead\.
|
|
565
|
+
.
|
|
566
|
+
.P
|
|
567
|
+
Numbers in jq are internally represented by their IEEE754 double precision approximation\. Any arithmetic operation with numbers, whether they are literals or results of previous filters, will produce a double precision floating point result\.
|
|
568
|
+
.
|
|
569
|
+
.P
|
|
570
|
+
However, when parsing a literal jq will store the original literal string\. If no mutation is applied to this value then it will make to the output in its original form, even if conversion to double would result in a loss\.
|
|
449
571
|
.
|
|
450
572
|
.SS "Array construction: []"
|
|
451
573
|
As in JSON, \fB[]\fR is used to construct arrays, as in \fB[1,2,3]\fR\. The elements of the arrays can be any jq expression, including a pipeline\. All of the results produced by all of the expressions are collected into one big array\. You can use it to construct an array out of a known quantity of values (as in \fB[\.foo, \.bar, \.baz]\fR) or to "collect" all the results of a filter into an array (as in \fB[\.items[]\.name]\fR)
|
|
@@ -476,10 +598,10 @@ jq \'[ \.[] | \. * 2]\'
|
|
|
476
598
|
Like JSON, \fB{}\fR is for constructing objects (aka dictionaries or hashes), as in: \fB{"a": 42, "b": 17}\fR\.
|
|
477
599
|
.
|
|
478
600
|
.P
|
|
479
|
-
If the keys are "identifier\-like", then the quotes can be left off, as in \fB{a:42, b:17}\fR\.
|
|
601
|
+
If the keys are "identifier\-like", then the quotes can be left off, as in \fB{a:42, b:17}\fR\. Variable references as key expressions use the value of the variable as the key\. Key expressions other than constant literals, identifiers, or variable references, need to be parenthesized, e\.g\., \fB{("a"+"b"):59}\fR\.
|
|
480
602
|
.
|
|
481
603
|
.P
|
|
482
|
-
The value can be any expression (although you may need to wrap it in parentheses if it
|
|
604
|
+
The value can be any expression (although you may need to wrap it in parentheses if, for example, it contains colons), which gets applied to the {} expression\'s input (remember, all filters have an input and an output)\.
|
|
483
605
|
.
|
|
484
606
|
.IP "" 4
|
|
485
607
|
.
|
|
@@ -568,6 +690,32 @@ produces
|
|
|
568
690
|
.nf
|
|
569
691
|
|
|
570
692
|
{"stedolan": ["JQ Primer", "More JQ"]}
|
|
693
|
+
.
|
|
694
|
+
.fi
|
|
695
|
+
.
|
|
696
|
+
.IP "" 0
|
|
697
|
+
.
|
|
698
|
+
.P
|
|
699
|
+
Variable references as keys use the value of the variable as the key\. Without a value then the variable\'s name becomes the key and its value becomes the value,
|
|
700
|
+
.
|
|
701
|
+
.IP "" 4
|
|
702
|
+
.
|
|
703
|
+
.nf
|
|
704
|
+
|
|
705
|
+
"f o o" as $foo | "b a r" as $bar | {$foo, $bar:$foo}
|
|
706
|
+
.
|
|
707
|
+
.fi
|
|
708
|
+
.
|
|
709
|
+
.IP "" 0
|
|
710
|
+
.
|
|
711
|
+
.P
|
|
712
|
+
produces
|
|
713
|
+
.
|
|
714
|
+
.IP "" 4
|
|
715
|
+
.
|
|
716
|
+
.nf
|
|
717
|
+
|
|
718
|
+
{"foo":"f o o","b a r":"f o o"}
|
|
571
719
|
|
|
572
720
|
jq \'{user, title: \.titles[]}\'
|
|
573
721
|
{"user":"stedolan","titles":["JQ Primer", "More JQ"]}
|
|
@@ -582,7 +730,7 @@ jq \'{(\.user): \.titles}\'
|
|
|
582
730
|
.IP "" 0
|
|
583
731
|
.
|
|
584
732
|
.SS "Recursive Descent: \.\."
|
|
585
|
-
Recursively descends \fB\.\fR, producing every value\. This is the same as the zero\-argument \fBrecurse\fR builtin (see below)\. This is intended to resemble the XPath \fB//\fR operator\. Note that \fB\.\.a\fR does not work; use \fB
|
|
733
|
+
Recursively descends \fB\.\fR, producing every value\. This is the same as the zero\-argument \fBrecurse\fR builtin (see below)\. This is intended to resemble the XPath \fB//\fR operator\. Note that \fB\.\.a\fR does not work; use \fB\.\. | \.a\fR instead\. In the example below we use \fB\.\. | \.a?\fR to find all the values of object keys "a" in any object found "below" \fB\.\fR\.
|
|
586
734
|
.
|
|
587
735
|
.P
|
|
588
736
|
This is particularly useful in conjunction with \fBpath(EXP)\fR (also see below) and the \fB?\fR operator\.
|
|
@@ -591,7 +739,7 @@ This is particularly useful in conjunction with \fBpath(EXP)\fR (also see below)
|
|
|
591
739
|
.
|
|
592
740
|
.nf
|
|
593
741
|
|
|
594
|
-
jq \'
|
|
742
|
+
jq \'\.\. | \.a?\'
|
|
595
743
|
[[{"a":1}]]
|
|
596
744
|
=> 1
|
|
597
745
|
.
|
|
@@ -600,7 +748,13 @@ jq \'\.\.|\.a?\'
|
|
|
600
748
|
.IP "" 0
|
|
601
749
|
.
|
|
602
750
|
.SH "BUILTIN OPERATORS AND FUNCTIONS"
|
|
603
|
-
Some jq
|
|
751
|
+
Some jq operators (for instance, \fB+\fR) do different things depending on the type of their arguments (arrays, numbers, etc\.)\. However, jq never does implicit type conversions\. If you try to add a string to an object you\'ll get an error message and no result\.
|
|
752
|
+
.
|
|
753
|
+
.P
|
|
754
|
+
Please note that all numbers are converted to IEEE754 double precision floating point representation\. Arithmetic and logical operators are working with these converted doubles\. Results of all such operations are also limited to the double precision\.
|
|
755
|
+
.
|
|
756
|
+
.P
|
|
757
|
+
The only exception to this behaviour of number is a snapshot of original number literal\. When a number which originally was provided as a literal is never mutated until the end of the program then it is printed to the output in its original literal form\. This also includes cases when the original literal would be truncated when converted to the IEEE754 double precision floating point number\.
|
|
604
758
|
.
|
|
605
759
|
.SS "Addition: +"
|
|
606
760
|
The operator \fB+\fR takes two filters, applies them both to the same input, and adds the results together\. What "adding" means depends on the types involved:
|
|
@@ -669,11 +823,11 @@ jq \'\. \- ["xml", "yaml"]\'
|
|
|
669
823
|
.
|
|
670
824
|
.IP "" 0
|
|
671
825
|
.
|
|
672
|
-
.SS "Multiplication, division, modulo: *, /,
|
|
826
|
+
.SS "Multiplication, division, modulo: *, /, %"
|
|
673
827
|
These infix operators behave as expected when given two numbers\. Division by zero raises an error\. \fBx % y\fR computes x modulo y\.
|
|
674
828
|
.
|
|
675
829
|
.P
|
|
676
|
-
Multiplying a string by a number produces the concatenation of that string that many times\. \fB"x" * 0\fR produces \
|
|
830
|
+
Multiplying a string by a number produces the concatenation of that string that many times\. \fB"x" * 0\fR produces \fB""\fR\.
|
|
677
831
|
.
|
|
678
832
|
.P
|
|
679
833
|
Dividing a string by another splits the first using the second as separators\.
|
|
@@ -705,6 +859,27 @@ jq \'\.[] | (1 / \.)?\'
|
|
|
705
859
|
.
|
|
706
860
|
.IP "" 0
|
|
707
861
|
.
|
|
862
|
+
.SS "abs"
|
|
863
|
+
The builtin function \fBabs\fR is defined naively as: \fBif \. < 0 then \- \. else \. end\fR\.
|
|
864
|
+
.
|
|
865
|
+
.P
|
|
866
|
+
For numeric input, this is the absolute value\. See the section on the identity filter for the implications of this definition for numeric input\.
|
|
867
|
+
.
|
|
868
|
+
.P
|
|
869
|
+
To compute the absolute value of a number as a floating point number, you may wish use \fBfabs\fR\.
|
|
870
|
+
.
|
|
871
|
+
.IP "" 4
|
|
872
|
+
.
|
|
873
|
+
.nf
|
|
874
|
+
|
|
875
|
+
jq \'map(abs)\'
|
|
876
|
+
[\-10, \-1\.1, \-1e\-1]
|
|
877
|
+
=> [10,1\.1,1e\-1]
|
|
878
|
+
.
|
|
879
|
+
.fi
|
|
880
|
+
.
|
|
881
|
+
.IP "" 0
|
|
882
|
+
.
|
|
708
883
|
.SS "length"
|
|
709
884
|
The builtin function \fBlength\fR gets the length of various different types of value:
|
|
710
885
|
.
|
|
@@ -712,6 +887,9 @@ The builtin function \fBlength\fR gets the length of various different types of
|
|
|
712
887
|
The length of a \fBstring\fR is the number of Unicode codepoints it contains (which will be the same as its JSON\-encoded length in bytes if it\'s pure ASCII)\.
|
|
713
888
|
.
|
|
714
889
|
.IP "\(bu" 4
|
|
890
|
+
The length of a \fBnumber\fR is its absolute value\.
|
|
891
|
+
.
|
|
892
|
+
.IP "\(bu" 4
|
|
715
893
|
The length of an \fBarray\fR is the number of elements\.
|
|
716
894
|
.
|
|
717
895
|
.IP "\(bu" 4
|
|
@@ -720,8 +898,18 @@ The length of an \fBobject\fR is the number of key\-value pairs\.
|
|
|
720
898
|
.IP "\(bu" 4
|
|
721
899
|
The length of \fBnull\fR is zero\.
|
|
722
900
|
.
|
|
723
|
-
.IP
|
|
724
|
-
|
|
901
|
+
.IP "\(bu" 4
|
|
902
|
+
It is an error to use \fBlength\fR on a \fBboolean\fR\.
|
|
903
|
+
.
|
|
904
|
+
.IP "" 4
|
|
905
|
+
.
|
|
906
|
+
.nf
|
|
907
|
+
|
|
908
|
+
jq \'\.[] | length\'
|
|
909
|
+
[[1,2], "string", {"a":2}, null, \-5]
|
|
910
|
+
=> 2, 6, 1, 0, 5
|
|
911
|
+
.
|
|
912
|
+
.fi
|
|
725
913
|
.
|
|
726
914
|
.IP "" 0
|
|
727
915
|
.
|
|
@@ -809,41 +997,99 @@ jq \'map(in([0,1]))\'
|
|
|
809
997
|
.
|
|
810
998
|
.IP "" 0
|
|
811
999
|
.
|
|
812
|
-
.SS "map(
|
|
813
|
-
For any filter \
|
|
1000
|
+
.SS "map(f), map_values(f)"
|
|
1001
|
+
For any filter \fBf\fR, \fBmap(f)\fR and \fBmap_values(f)\fR apply \fBf\fR to each of the values in the input array or object, that is, to the values of \fB\.[]\fR\.
|
|
1002
|
+
.
|
|
1003
|
+
.P
|
|
1004
|
+
In the absence of errors, \fBmap(f)\fR always outputs an array whereas \fBmap_values(f)\fR outputs an array if given an array, or an object if given an object\.
|
|
1005
|
+
.
|
|
1006
|
+
.P
|
|
1007
|
+
When the input to \fBmap_values(f)\fR is an object, the output object has the same keys as the input object except for those keys whose values when piped to \fBf\fR produce no values at all\.
|
|
1008
|
+
.
|
|
1009
|
+
.P
|
|
1010
|
+
The key difference between \fBmap(f)\fR and \fBmap_values(f)\fR is that the former simply forms an array from all the values of \fB($x|f)\fR for each value, $x, in the input array or object, but \fBmap_values(f)\fR only uses \fBfirst($x|f)\fR\.
|
|
814
1011
|
.
|
|
815
1012
|
.P
|
|
816
|
-
|
|
1013
|
+
Specifically, for object inputs, \fBmap_values(f)\fR constructs the output object by examining in turn the value of \fBfirst(\.[$k]|f)\fR for each key, $k, of the input\. If this expression produces no values, then the corresponding key will be dropped; otherwise, the output object will have that value at the key, $k\.
|
|
817
1014
|
.
|
|
818
1015
|
.P
|
|
819
|
-
|
|
1016
|
+
Here are some examples to clarify the behavior of \fBmap\fR and \fBmap_values\fR when applied to arrays\. These examples assume the input is \fB[1]\fR in all cases:
|
|
820
1017
|
.
|
|
821
1018
|
.IP "" 4
|
|
822
1019
|
.
|
|
823
1020
|
.nf
|
|
824
1021
|
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
1022
|
+
map(\.+1) #=> [2]
|
|
1023
|
+
map(\., \.) #=> [1,1]
|
|
1024
|
+
map(empty) #=> []
|
|
828
1025
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
1026
|
+
map_values(\.+1) #=> [2]
|
|
1027
|
+
map_values(\., \.) #=> [1]
|
|
1028
|
+
map_values(empty) #=> []
|
|
832
1029
|
.
|
|
833
1030
|
.fi
|
|
834
1031
|
.
|
|
835
1032
|
.IP "" 0
|
|
836
1033
|
.
|
|
837
|
-
.SS "path(path_expression)"
|
|
838
|
-
Outputs array representations of the given path expression in \fB\.\fR\. The outputs are arrays of strings (object keys) and/or numbers (array indices)\.
|
|
839
|
-
.
|
|
840
1034
|
.P
|
|
841
|
-
|
|
1035
|
+
\fBmap(f)\fR is equivalent to \fB[\.[] | f]\fR and \fBmap_values(f)\fR is equivalent to \fB\.[] |= f\fR\.
|
|
842
1036
|
.
|
|
843
1037
|
.P
|
|
844
|
-
|
|
1038
|
+
In fact, these are their implementations\.
|
|
845
1039
|
.
|
|
846
|
-
.
|
|
1040
|
+
.IP "" 4
|
|
1041
|
+
.
|
|
1042
|
+
.nf
|
|
1043
|
+
|
|
1044
|
+
jq \'map(\.+1)\'
|
|
1045
|
+
[1,2,3]
|
|
1046
|
+
=> [2,3,4]
|
|
1047
|
+
|
|
1048
|
+
jq \'map_values(\.+1)\'
|
|
1049
|
+
{"a": 1, "b": 2, "c": 3}
|
|
1050
|
+
=> {"a": 2, "b": 3, "c": 4}
|
|
1051
|
+
|
|
1052
|
+
jq \'map(\., \.)\'
|
|
1053
|
+
[1,2]
|
|
1054
|
+
=> [1,1,2,2]
|
|
1055
|
+
|
|
1056
|
+
jq \'map_values(\. // empty)\'
|
|
1057
|
+
{"a": null, "b": true, "c": false}
|
|
1058
|
+
=> {"b":true}
|
|
1059
|
+
.
|
|
1060
|
+
.fi
|
|
1061
|
+
.
|
|
1062
|
+
.IP "" 0
|
|
1063
|
+
.
|
|
1064
|
+
.SS "pick(pathexps)"
|
|
1065
|
+
Emit the projection of the input object or array defined by the specified sequence of path expressions, such that if \fBp\fR is any one of these specifications, then \fB(\. | p)\fR will evaluate to the same value as \fB(\. | pick(pathexps) | p)\fR\. For arrays, negative indices and \fB\.[m:n]\fR specifications should not be used\.
|
|
1066
|
+
.
|
|
1067
|
+
.IP "" 4
|
|
1068
|
+
.
|
|
1069
|
+
.nf
|
|
1070
|
+
|
|
1071
|
+
jq \'pick(\.a, \.b\.c, \.x)\'
|
|
1072
|
+
{"a": 1, "b": {"c": 2, "d": 3}, "e": 4}
|
|
1073
|
+
=> {"a":1,"b":{"c":2},"x":null}
|
|
1074
|
+
|
|
1075
|
+
jq \'pick(\.[2], \.[0], \.[0])\'
|
|
1076
|
+
[1,2,3,4]
|
|
1077
|
+
=> [1,null,3]
|
|
1078
|
+
.
|
|
1079
|
+
.fi
|
|
1080
|
+
.
|
|
1081
|
+
.IP "" 0
|
|
1082
|
+
.
|
|
1083
|
+
.SS "path(path_expression)"
|
|
1084
|
+
Outputs array representations of the given path expression in \fB\.\fR\. The outputs are arrays of strings (object keys) and/or numbers (array indices)\.
|
|
1085
|
+
.
|
|
1086
|
+
.P
|
|
1087
|
+
Path expressions are jq expressions like \fB\.a\fR, but also \fB\.[]\fR\. There are two types of path expressions: ones that can match exactly, and ones that cannot\. For example, \fB\.a\.b\.c\fR is an exact match path expression, while \fB\.a[]\.b\fR is not\.
|
|
1088
|
+
.
|
|
1089
|
+
.P
|
|
1090
|
+
\fBpath(exact_path_expression)\fR will produce the array representation of the path expression even if it does not exist in \fB\.\fR, if \fB\.\fR is \fBnull\fR or an array or an object\.
|
|
1091
|
+
.
|
|
1092
|
+
.P
|
|
847
1093
|
\fBpath(pattern)\fR will produce array representations of the paths matching \fBpattern\fR if the paths exist in \fB\.\fR\.
|
|
848
1094
|
.
|
|
849
1095
|
.P
|
|
@@ -927,7 +1173,7 @@ jq \'setpath([0,"a"]; 1)\'
|
|
|
927
1173
|
.IP "" 0
|
|
928
1174
|
.
|
|
929
1175
|
.SS "delpaths(PATHS)"
|
|
930
|
-
The builtin function \fBdelpaths\fR
|
|
1176
|
+
The builtin function \fBdelpaths\fR deletes the \fBPATHS\fR in \fB\.\fR\. \fBPATHS\fR must be an array of paths, where each path is an array of strings and numbers\.
|
|
931
1177
|
.
|
|
932
1178
|
.IP "" 4
|
|
933
1179
|
.
|
|
@@ -941,11 +1187,11 @@ jq \'delpaths([["a","b"]])\'
|
|
|
941
1187
|
.
|
|
942
1188
|
.IP "" 0
|
|
943
1189
|
.
|
|
944
|
-
.SS "to_entries, from_entries, with_entries"
|
|
1190
|
+
.SS "to_entries, from_entries, with_entries(f)"
|
|
945
1191
|
These functions convert between an object and an array of key\-value pairs\. If \fBto_entries\fR is passed an object, then for each \fBk: v\fR entry in the input, the output array includes \fB{"key": k, "value": v}\fR\.
|
|
946
1192
|
.
|
|
947
1193
|
.P
|
|
948
|
-
\fBfrom_entries\fR does the opposite conversion, and \fBwith_entries(
|
|
1194
|
+
\fBfrom_entries\fR does the opposite conversion, and \fBwith_entries(f)\fR is a shorthand for \fBto_entries | map(f) | from_entries\fR, useful for doing some operation to all keys and values of an object\. \fBfrom_entries\fR accepts \fB"key"\fR, \fB"Key"\fR, \fB"name"\fR, \fB"Name"\fR, \fB"value"\fR, and \fB"Value"\fR as keys\.
|
|
949
1195
|
.
|
|
950
1196
|
.IP "" 4
|
|
951
1197
|
.
|
|
@@ -968,7 +1214,7 @@ jq \'with_entries(\.key |= "KEY_" + \.)\'
|
|
|
968
1214
|
.IP "" 0
|
|
969
1215
|
.
|
|
970
1216
|
.SS "select(boolean_expression)"
|
|
971
|
-
The function \fBselect(
|
|
1217
|
+
The function \fBselect(f)\fR produces its input unchanged if \fBf\fR returns true for that input, and produces no output otherwise\.
|
|
972
1218
|
.
|
|
973
1219
|
.P
|
|
974
1220
|
It\'s useful for filtering lists: \fB[1,2,3] | map(select(\. >= 2))\fR will give you \fB[2,3]\fR\.
|
|
@@ -1026,8 +1272,24 @@ jq \'[1,2,empty,3]\'
|
|
|
1026
1272
|
.
|
|
1027
1273
|
.IP "" 0
|
|
1028
1274
|
.
|
|
1029
|
-
.SS "error(message)"
|
|
1030
|
-
Produces an error
|
|
1275
|
+
.SS "error, error(message)"
|
|
1276
|
+
Produces an error with the input value, or with the message given as the argument\. Errors can be caught with try/catch; see below\.
|
|
1277
|
+
.
|
|
1278
|
+
.IP "" 4
|
|
1279
|
+
.
|
|
1280
|
+
.nf
|
|
1281
|
+
|
|
1282
|
+
jq \'try error catch \.\'
|
|
1283
|
+
"error message"
|
|
1284
|
+
=> "error message"
|
|
1285
|
+
|
|
1286
|
+
jq \'try error("invalid value: \e(\.)") catch \.\'
|
|
1287
|
+
42
|
|
1288
|
+
=> "invalid value: 42"
|
|
1289
|
+
.
|
|
1290
|
+
.fi
|
|
1291
|
+
.
|
|
1292
|
+
.IP "" 0
|
|
1031
1293
|
.
|
|
1032
1294
|
.SS "halt"
|
|
1033
1295
|
Stops the jq program with no further outputs\. jq will exit with exit status \fB0\fR\.
|
|
@@ -1039,7 +1301,7 @@ Stops the jq program with no further outputs\. The input will be printed on \fBs
|
|
|
1039
1301
|
The given \fBexit_code\fR (defaulting to \fB5\fR) will be jq\'s exit status\.
|
|
1040
1302
|
.
|
|
1041
1303
|
.P
|
|
1042
|
-
For example, \fB"Error:
|
|
1304
|
+
For example, \fB"Error: something went wrong\en"|halt_error(1)\fR\.
|
|
1043
1305
|
.
|
|
1044
1306
|
.SS "$__loc__"
|
|
1045
1307
|
Produces an object with a "file" key and a "line" key, with the filename and line number where \fB$__loc__\fR occurs, as values\.
|
|
@@ -1056,14 +1318,11 @@ jq \'try error("\e($__loc__)") catch \.\'
|
|
|
1056
1318
|
.
|
|
1057
1319
|
.IP "" 0
|
|
1058
1320
|
.
|
|
1059
|
-
.SS "paths, paths(node_filter)
|
|
1321
|
+
.SS "paths, paths(node_filter)"
|
|
1060
1322
|
\fBpaths\fR outputs the paths to all the elements in its input (except it does not output the empty list, representing \. itself)\.
|
|
1061
1323
|
.
|
|
1062
1324
|
.P
|
|
1063
|
-
\fBpaths(f)\fR outputs the paths to any values for which \fBf\fR is
|
|
1064
|
-
.
|
|
1065
|
-
.P
|
|
1066
|
-
\fBleaf_paths\fR is an alias of \fBpaths(scalars)\fR; \fBleaf_paths\fR is \fIdeprecated\fR and will be removed in the next major release\.
|
|
1325
|
+
\fBpaths(f)\fR outputs the paths to any values for which \fBf\fR is \fBtrue\fR\. That is, \fBpaths(type == "number")\fR outputs the paths to all numeric values\.
|
|
1067
1326
|
.
|
|
1068
1327
|
.IP "" 4
|
|
1069
1328
|
.
|
|
@@ -1073,7 +1332,7 @@ jq \'[paths]\'
|
|
|
1073
1332
|
[1,[[],{"a":2}]]
|
|
1074
1333
|
=> [[0],[1],[1,0],[1,1],[1,1,"a"]]
|
|
1075
1334
|
|
|
1076
|
-
jq \'[paths(
|
|
1335
|
+
jq \'[paths(type == "number")]\'
|
|
1077
1336
|
[1,[[],{"a":2}]]
|
|
1078
1337
|
=> [[0],[1,1,"a"]]
|
|
1079
1338
|
.
|
|
@@ -1081,12 +1340,15 @@ jq \'[paths(scalars)]\'
|
|
|
1081
1340
|
.
|
|
1082
1341
|
.IP "" 0
|
|
1083
1342
|
.
|
|
1084
|
-
.SS "add"
|
|
1343
|
+
.SS "add, add(generator)"
|
|
1085
1344
|
The filter \fBadd\fR takes as input an array, and produces as output the elements of the array added together\. This might mean summed, concatenated or merged depending on the types of the elements of the input array \- the rules are the same as those for the \fB+\fR operator (described above)\.
|
|
1086
1345
|
.
|
|
1087
1346
|
.P
|
|
1088
1347
|
If the input is an empty array, \fBadd\fR returns \fBnull\fR\.
|
|
1089
1348
|
.
|
|
1349
|
+
.P
|
|
1350
|
+
\fBadd(generator)\fR operates on the given generator rather than the input\.
|
|
1351
|
+
.
|
|
1090
1352
|
.IP "" 4
|
|
1091
1353
|
.
|
|
1092
1354
|
.nf
|
|
@@ -1102,6 +1364,10 @@ jq \'add\'
|
|
|
1102
1364
|
jq \'add\'
|
|
1103
1365
|
[]
|
|
1104
1366
|
=> null
|
|
1367
|
+
|
|
1368
|
+
jq \'add(\.[]\.a)\'
|
|
1369
|
+
[{"a":3}, {"a":5}, {"b":6}]
|
|
1370
|
+
=> 8
|
|
1105
1371
|
.
|
|
1106
1372
|
.fi
|
|
1107
1373
|
.
|
|
@@ -1201,8 +1467,8 @@ jq \'flatten\'
|
|
|
1201
1467
|
.
|
|
1202
1468
|
.IP "" 0
|
|
1203
1469
|
.
|
|
1204
|
-
.SS "range(upto), range(from;upto) range(from;upto;by)"
|
|
1205
|
-
The \fBrange\fR function produces a range of numbers\. \fBrange(4;10)\fR produces 6 numbers, from 4 (inclusive) to 10 (exclusive)\. The numbers are produced as separate outputs\. Use \fB[range(4;10)]\fR to get a range as an array\.
|
|
1470
|
+
.SS "range(upto), range(from; upto), range(from; upto; by)"
|
|
1471
|
+
The \fBrange\fR function produces a range of numbers\. \fBrange(4; 10)\fR produces 6 numbers, from 4 (inclusive) to 10 (exclusive)\. The numbers are produced as separate outputs\. Use \fB[range(4; 10)]\fR to get a range as an array\.
|
|
1206
1472
|
.
|
|
1207
1473
|
.P
|
|
1208
1474
|
The one argument form generates numbers from 0 to the given number, with an increment of 1\.
|
|
@@ -1217,11 +1483,11 @@ The three argument form generates numbers \fBfrom\fR to \fBupto\fR with an incre
|
|
|
1217
1483
|
.
|
|
1218
1484
|
.nf
|
|
1219
1485
|
|
|
1220
|
-
jq \'range(2;4)\'
|
|
1486
|
+
jq \'range(2; 4)\'
|
|
1221
1487
|
null
|
|
1222
1488
|
=> 2, 3
|
|
1223
1489
|
|
|
1224
|
-
jq \'[range(2;4)]\'
|
|
1490
|
+
jq \'[range(2; 4)]\'
|
|
1225
1491
|
null
|
|
1226
1492
|
=> [2,3]
|
|
1227
1493
|
|
|
@@ -1229,15 +1495,15 @@ jq \'[range(4)]\'
|
|
|
1229
1495
|
null
|
|
1230
1496
|
=> [0,1,2,3]
|
|
1231
1497
|
|
|
1232
|
-
jq \'[range(0;10;3)]\'
|
|
1498
|
+
jq \'[range(0; 10; 3)]\'
|
|
1233
1499
|
null
|
|
1234
1500
|
=> [0,3,6,9]
|
|
1235
1501
|
|
|
1236
|
-
jq \'[range(0;10
|
|
1502
|
+
jq \'[range(0; 10; \-1)]\'
|
|
1237
1503
|
null
|
|
1238
1504
|
=> []
|
|
1239
1505
|
|
|
1240
|
-
jq \'[range(0
|
|
1506
|
+
jq \'[range(0; \-5; \-1)]\'
|
|
1241
1507
|
null
|
|
1242
1508
|
=> [0,\-1,\-2,\-3,\-4]
|
|
1243
1509
|
.
|
|
@@ -1375,10 +1641,7 @@ objects
|
|
|
1375
1641
|
The ordering for objects is a little complex: first they\'re compared by comparing their sets of keys (as arrays in sorted order), and if their keys are equal then the values are compared key by key\.
|
|
1376
1642
|
.
|
|
1377
1643
|
.P
|
|
1378
|
-
\
|
|
1379
|
-
.
|
|
1380
|
-
.P
|
|
1381
|
-
\fBsort_by(foo)\fR compares two elements by comparing the result of \fBfoo\fR on each element\.
|
|
1644
|
+
\fBsort_by\fR may be used to sort by a particular field of an object, or by applying any jq filter\. \fBsort_by(f)\fR compares two elements by comparing the result of \fBf\fR on each element\. When \fBf\fR produces multiple values, it firstly compares the first values, and the second values if the first values are equal, and so on\.
|
|
1382
1645
|
.
|
|
1383
1646
|
.IP "" 4
|
|
1384
1647
|
.
|
|
@@ -1389,8 +1652,12 @@ jq \'sort\'
|
|
|
1389
1652
|
=> [null,3,6,8]
|
|
1390
1653
|
|
|
1391
1654
|
jq \'sort_by(\.foo)\'
|
|
1392
|
-
[{"foo":4, "bar":10}, {"foo":3, "bar":
|
|
1393
|
-
=> [{"foo":2, "bar":1}, {"foo":3, "bar":
|
|
1655
|
+
[{"foo":4, "bar":10}, {"foo":3, "bar":10}, {"foo":2, "bar":1}]
|
|
1656
|
+
=> [{"foo":2, "bar":1}, {"foo":3, "bar":10}, {"foo":4, "bar":10}]
|
|
1657
|
+
|
|
1658
|
+
jq \'sort_by(\.foo, \.bar)\'
|
|
1659
|
+
[{"foo":4, "bar":10}, {"foo":3, "bar":20}, {"foo":2, "bar":1}, {"foo":3, "bar":10}]
|
|
1660
|
+
=> [{"foo":2, "bar":1}, {"foo":3, "bar":10}, {"foo":3, "bar":20}, {"foo":4, "bar":10}]
|
|
1394
1661
|
.
|
|
1395
1662
|
.fi
|
|
1396
1663
|
.
|
|
@@ -1542,9 +1809,25 @@ jq \'index(", ")\'
|
|
|
1542
1809
|
"a,b, cd, efg, hijk"
|
|
1543
1810
|
=> 3
|
|
1544
1811
|
|
|
1812
|
+
jq \'index(1)\'
|
|
1813
|
+
[0,1,2,1,3,1,4]
|
|
1814
|
+
=> 1
|
|
1815
|
+
|
|
1816
|
+
jq \'index([1,2])\'
|
|
1817
|
+
[0,1,2,3,1,4,2,5,1,2,6,7]
|
|
1818
|
+
=> 1
|
|
1819
|
+
|
|
1545
1820
|
jq \'rindex(", ")\'
|
|
1546
1821
|
"a,b, cd, efg, hijk"
|
|
1547
1822
|
=> 12
|
|
1823
|
+
|
|
1824
|
+
jq \'rindex(1)\'
|
|
1825
|
+
[0,1,2,1,3,1,4]
|
|
1826
|
+
=> 5
|
|
1827
|
+
|
|
1828
|
+
jq \'rindex([1,2])\'
|
|
1829
|
+
[0,1,2,3,1,4,2,5,1,2,6,7]
|
|
1830
|
+
=> 8
|
|
1548
1831
|
.
|
|
1549
1832
|
.fi
|
|
1550
1833
|
.
|
|
@@ -1660,6 +1943,30 @@ jq \'[\.[]|rtrimstr("foo")]\'
|
|
|
1660
1943
|
.
|
|
1661
1944
|
.IP "" 0
|
|
1662
1945
|
.
|
|
1946
|
+
.SS "trim, ltrim, rtrim"
|
|
1947
|
+
\fBtrim\fR trims both leading and trailing whitespace\.
|
|
1948
|
+
.
|
|
1949
|
+
.P
|
|
1950
|
+
\fBltrim\fR trims only leading (left side) whitespace\.
|
|
1951
|
+
.
|
|
1952
|
+
.P
|
|
1953
|
+
\fBrtrim\fR trims only trailing (right side) whitespace\.
|
|
1954
|
+
.
|
|
1955
|
+
.P
|
|
1956
|
+
Whitespace characters are the usual \fB" "\fR, \fB"\en"\fR \fB"\et"\fR, \fB"\er"\fR and also all characters in the Unicode character database with the whitespace property\. Note that what considers whitespace might change in the future\.
|
|
1957
|
+
.
|
|
1958
|
+
.IP "" 4
|
|
1959
|
+
.
|
|
1960
|
+
.nf
|
|
1961
|
+
|
|
1962
|
+
jq \'trim, ltrim, rtrim\'
|
|
1963
|
+
" abc "
|
|
1964
|
+
=> "abc", "abc ", " abc"
|
|
1965
|
+
.
|
|
1966
|
+
.fi
|
|
1967
|
+
.
|
|
1968
|
+
.IP "" 0
|
|
1969
|
+
.
|
|
1663
1970
|
.SS "explode"
|
|
1664
1971
|
Converts an input string into an array of the string\'s codepoint numbers\.
|
|
1665
1972
|
.
|
|
@@ -1693,6 +2000,9 @@ jq \'implode\'
|
|
|
1693
2000
|
.SS "split(str)"
|
|
1694
2001
|
Splits an input string on the separator argument\.
|
|
1695
2002
|
.
|
|
2003
|
+
.P
|
|
2004
|
+
\fBsplit\fR can also split on regex matches when called with two arguments (see the regular expressions section below)\.
|
|
2005
|
+
.
|
|
1696
2006
|
.IP "" 4
|
|
1697
2007
|
.
|
|
1698
2008
|
.nf
|
|
@@ -1730,6 +2040,18 @@ jq \'join(" ")\'
|
|
|
1730
2040
|
.SS "ascii_downcase, ascii_upcase"
|
|
1731
2041
|
Emit a copy of the input string with its alphabetic characters (a\-z and A\-Z) converted to the specified case\.
|
|
1732
2042
|
.
|
|
2043
|
+
.IP "" 4
|
|
2044
|
+
.
|
|
2045
|
+
.nf
|
|
2046
|
+
|
|
2047
|
+
jq \'ascii_upcase\'
|
|
2048
|
+
"useful but not for é"
|
|
2049
|
+
=> "USEFUL BUT NOT FOR é"
|
|
2050
|
+
.
|
|
2051
|
+
.fi
|
|
2052
|
+
.
|
|
2053
|
+
.IP "" 0
|
|
2054
|
+
.
|
|
1733
2055
|
.SS "while(cond; update)"
|
|
1734
2056
|
The \fBwhile(cond; update)\fR function allows you to repeatedly apply an update to \fB\.\fR until \fBcond\fR is false\.
|
|
1735
2057
|
.
|
|
@@ -1748,6 +2070,24 @@ jq \'[while(\.<100; \.*2)]\'
|
|
|
1748
2070
|
.
|
|
1749
2071
|
.IP "" 0
|
|
1750
2072
|
.
|
|
2073
|
+
.SS "repeat(exp)"
|
|
2074
|
+
The \fBrepeat(exp)\fR function allows you to repeatedly apply expression \fBexp\fR to \fB\.\fR until an error is raised\.
|
|
2075
|
+
.
|
|
2076
|
+
.P
|
|
2077
|
+
Note that \fBrepeat(exp)\fR is internally defined as a recursive jq function\. Recursive calls within \fBrepeat\fR will not consume additional memory if \fBexp\fR produces at most one output for each input\. See advanced topics below\.
|
|
2078
|
+
.
|
|
2079
|
+
.IP "" 4
|
|
2080
|
+
.
|
|
2081
|
+
.nf
|
|
2082
|
+
|
|
2083
|
+
jq \'[repeat(\.*2, error)?]\'
|
|
2084
|
+
1
|
|
2085
|
+
=> [2]
|
|
2086
|
+
.
|
|
2087
|
+
.fi
|
|
2088
|
+
.
|
|
2089
|
+
.IP "" 0
|
|
2090
|
+
.
|
|
1751
2091
|
.SS "until(cond; next)"
|
|
1752
2092
|
The \fBuntil(cond; next)\fR function allows you to repeatedly apply the expression \fBnext\fR, initially to \fB\.\fR then to its own output, until \fBcond\fR is true\. For example, this can be used to implement a factorial function (see below)\.
|
|
1753
2093
|
.
|
|
@@ -1766,7 +2106,7 @@ jq \'[\.,1]|until(\.[0] < 1; [\.[0] \- 1, \.[1] * \.[0]])|\.[1]\'
|
|
|
1766
2106
|
.
|
|
1767
2107
|
.IP "" 0
|
|
1768
2108
|
.
|
|
1769
|
-
.SS "recurse(f), recurse, recurse(f; condition)
|
|
2109
|
+
.SS "recurse(f), recurse, recurse(f; condition)"
|
|
1770
2110
|
The \fBrecurse(f)\fR function allows you to search through a recursive structure, and extract interesting data from all levels\. Suppose your input represents a filesystem:
|
|
1771
2111
|
.
|
|
1772
2112
|
.IP "" 4
|
|
@@ -1802,15 +2142,12 @@ recurse(\.children[]) | \.name
|
|
|
1802
2142
|
When called without an argument, \fBrecurse\fR is equivalent to \fBrecurse(\.[]?)\fR\.
|
|
1803
2143
|
.
|
|
1804
2144
|
.P
|
|
1805
|
-
\fBrecurse(f)\fR is identical to \fBrecurse(f;
|
|
2145
|
+
\fBrecurse(f)\fR is identical to \fBrecurse(f; true)\fR and can be used without concerns about recursion depth\.
|
|
1806
2146
|
.
|
|
1807
2147
|
.P
|
|
1808
2148
|
\fBrecurse(f; condition)\fR is a generator which begins by emitting \. and then emits in turn \.|f, \.|f|f, \.|f|f|f, \.\.\. so long as the computed value satisfies the condition\. For example, to generate all the integers, at least in principle, one could write \fBrecurse(\.+1; true)\fR\.
|
|
1809
2149
|
.
|
|
1810
2150
|
.P
|
|
1811
|
-
For legacy reasons, \fBrecurse_down\fR exists as an alias to calling \fBrecurse\fR without arguments\. This alias is considered \fIdeprecated\fR and will be removed in the next major release\.
|
|
1812
|
-
.
|
|
1813
|
-
.P
|
|
1814
2151
|
The recursive calls in \fBrecurse\fR will not consume additional memory whenever \fBf\fR produces at most a single output for each input\.
|
|
1815
2152
|
.
|
|
1816
2153
|
.IP "" 4
|
|
@@ -1852,6 +2189,18 @@ jq \'walk( if type == "object" then with_entries( \.key |= sub( "^_+"; "") ) els
|
|
|
1852
2189
|
.
|
|
1853
2190
|
.IP "" 0
|
|
1854
2191
|
.
|
|
2192
|
+
.SS "have_literal_numbers"
|
|
2193
|
+
This builtin returns true if jq\'s build configuration includes support for preservation of input number literals\.
|
|
2194
|
+
.
|
|
2195
|
+
.SS "have_decnum"
|
|
2196
|
+
This builtin returns true if jq was built with "decnum", which is the current literal number preserving numeric backend implementation for jq\.
|
|
2197
|
+
.
|
|
2198
|
+
.SS "$JQ_BUILD_CONFIGURATION"
|
|
2199
|
+
This builtin binding shows the jq executable\'s build configuration\. Its value has no particular format, but it can be expected to be at least the \fB\./configure\fR command\-line arguments, and may be enriched in the future to include the version strings for the build tooling used\.
|
|
2200
|
+
.
|
|
2201
|
+
.P
|
|
2202
|
+
Note that this can be overridden in the command\-line with \fB\-\-arg\fR and related options\.
|
|
2203
|
+
.
|
|
1855
2204
|
.SS "$ENV, env"
|
|
1856
2205
|
\fB$ENV\fR is an object representing the environment variables as set when the jq program started\.
|
|
1857
2206
|
.
|
|
@@ -1893,7 +2242,7 @@ jq \'transpose\'
|
|
|
1893
2242
|
.IP "" 0
|
|
1894
2243
|
.
|
|
1895
2244
|
.SS "bsearch(x)"
|
|
1896
|
-
|
|
2245
|
+
\fBbsearch(x)\fR conducts a binary search for x in the input array\. If the input is sorted and contains x, then \fBbsearch(x)\fR will return its index in the array; otherwise, if the array is sorted, it will return (\-1 \- ix) where ix is an insertion point such that the array would still be sorted after the insertion of x at ix\. If the array is not sorted, \fBbsearch(x)\fR will return an integer that is probably of no interest\.
|
|
1897
2246
|
.
|
|
1898
2247
|
.IP "" 4
|
|
1899
2248
|
.
|
|
@@ -1915,7 +2264,7 @@ jq \'bsearch(4) as $ix | if $ix < 0 then \.[\-(1+$ix)] = 4 else \. end\'
|
|
|
1915
2264
|
.
|
|
1916
2265
|
.IP "" 0
|
|
1917
2266
|
.
|
|
1918
|
-
.SS "String interpolation
|
|
2267
|
+
.SS "String interpolation: \e(exp)"
|
|
1919
2268
|
Inside a string, you can put an expression inside parens after a backslash\. Whatever the expression returns will be interpolated into the string\.
|
|
1920
2269
|
.
|
|
1921
2270
|
.IP "" 4
|
|
@@ -1931,7 +2280,7 @@ jq \'"The input was \e(\.), which is one less than \e(\.+1)"\'
|
|
|
1931
2280
|
.IP "" 0
|
|
1932
2281
|
.
|
|
1933
2282
|
.SS "Convert to/from JSON"
|
|
1934
|
-
The \fBtojson\fR and \fBfromjson\fR builtins dump values as JSON texts or parse JSON texts into values, respectively\. The
|
|
2283
|
+
The \fBtojson\fR and \fBfromjson\fR builtins dump values as JSON texts or parse JSON texts into values, respectively\. The \fBtojson\fR builtin differs from \fBtostring\fR in that \fBtostring\fR returns strings unmodified, while \fBtojson\fR encodes strings as JSON strings\.
|
|
1935
2284
|
.
|
|
1936
2285
|
.IP "" 4
|
|
1937
2286
|
.
|
|
@@ -1981,6 +2330,12 @@ Applies HTML/XML escaping, by mapping the characters \fB<>&\'"\fR to their entit
|
|
|
1981
2330
|
Applies percent\-encoding, by mapping all reserved URI characters to a \fB%XX\fR sequence\.
|
|
1982
2331
|
.
|
|
1983
2332
|
.TP
|
|
2333
|
+
\fB@urid\fR:
|
|
2334
|
+
.
|
|
2335
|
+
.IP
|
|
2336
|
+
The inverse of \fB@uri\fR, applies percent\-decoding, by mapping all \fB%XX\fR sequences to their corresponding URI characters\.
|
|
2337
|
+
.
|
|
2338
|
+
.TP
|
|
1984
2339
|
\fB@csv\fR:
|
|
1985
2340
|
.
|
|
1986
2341
|
.IP
|
|
@@ -2008,7 +2363,7 @@ The input is converted to base64 as specified by RFC 4648\.
|
|
|
2008
2363
|
\fB@base64d\fR:
|
|
2009
2364
|
.
|
|
2010
2365
|
.IP
|
|
2011
|
-
The inverse of \fB@base64\fR, input is decoded as specified by RFC 4648\. Note: If the decoded string is not UTF\-8, the results are undefined\.
|
|
2366
|
+
The inverse of \fB@base64\fR, input is decoded as specified by RFC 4648\. Note\e: If the decoded string is not UTF\-8, the results are undefined\.
|
|
2012
2367
|
.
|
|
2013
2368
|
.P
|
|
2014
2369
|
This syntax can be combined with string interpolation in a useful way\. You can follow a \fB@foo\fR token with a string literal\. The contents of the string literal will \fInot\fR be escaped\. However, all interpolations made inside that string literal will be escaped\. For instance,
|
|
@@ -2082,7 +2437,7 @@ The \fBnow\fR builtin outputs the current time, in seconds since the Unix epoch\
|
|
|
2082
2437
|
Low\-level jq interfaces to the C\-library time functions are also provided: \fBstrptime\fR, \fBstrftime\fR, \fBstrflocaltime\fR, \fBmktime\fR, \fBgmtime\fR, and \fBlocaltime\fR\. Refer to your host operating system\'s documentation for the format strings used by \fBstrptime\fR and \fBstrftime\fR\. Note: these are not necessarily stable interfaces in jq, particularly as to their localization functionality\.
|
|
2083
2438
|
.
|
|
2084
2439
|
.P
|
|
2085
|
-
The \fBgmtime\fR builtin consumes a number of seconds since the Unix epoch and outputs a "broken down time" representation of
|
|
2440
|
+
The \fBgmtime\fR builtin consumes a number of seconds since the Unix epoch and outputs a "broken down time" representation of Greenwich Mean Time as an array of numbers representing (in this order): the year, the month (zero\-based), the day of the month (one\-based), the hour of the day, the minute of the hour, the second of the minute, the day of the week, and the day of the year \-\- all one\-based unless otherwise stated\. The day of the week number may be wrong on some systems for dates before March 1st 1900, or after December 31 2099\.
|
|
2086
2441
|
.
|
|
2087
2442
|
.P
|
|
2088
2443
|
The \fBlocaltime\fR builtin works like the \fBgmtime\fR builtin, but using the local timezone setting\.
|
|
@@ -2091,7 +2446,7 @@ The \fBlocaltime\fR builtin works like the \fBgmtime\fR builtin, but using the l
|
|
|
2091
2446
|
The \fBmktime\fR builtin consumes "broken down time" representations of time output by \fBgmtime\fR and \fBstrptime\fR\.
|
|
2092
2447
|
.
|
|
2093
2448
|
.P
|
|
2094
|
-
The \fBstrptime(fmt)\fR builtin parses input strings matching the \fBfmt\fR argument\. The output is in the "broken down time" representation consumed by \
|
|
2449
|
+
The \fBstrptime(fmt)\fR builtin parses input strings matching the \fBfmt\fR argument\. The output is in the "broken down time" representation consumed by \fBmktime\fR and output by \fBgmtime\fR\.
|
|
2095
2450
|
.
|
|
2096
2451
|
.P
|
|
2097
2452
|
The \fBstrftime(fmt)\fR builtin formats a time (GMT) with the given format\. The \fBstrflocaltime\fR does the same, but using the local timezone setting\.
|
|
@@ -2167,7 +2522,7 @@ Returns a list of all builtin functions in the format \fBname/arity\fR\. Since f
|
|
|
2167
2522
|
.SH "CONDITIONALS AND COMPARISONS"
|
|
2168
2523
|
.
|
|
2169
2524
|
.SS "==, !="
|
|
2170
|
-
The expression \'a == b\' will produce \'true\' if the
|
|
2525
|
+
The expression \'a == b\' will produce \'true\' if the results of evaluating a and b are equal (that is, if they represent equivalent JSON values) and \'false\' otherwise\. In particular, strings are never considered equal to numbers\. In checking for the equality of JSON objects, the ordering of keys is irrelevant\. If you\'re coming from JavaScript, please note that jq\'s \fB==\fR is like JavaScript\'s \fB===\fR, the "strict equality" operator\.
|
|
2171
2526
|
.
|
|
2172
2527
|
.P
|
|
2173
2528
|
!= is "not equal", and \'a != b\' returns the opposite value of \'a == b\'
|
|
@@ -2176,6 +2531,14 @@ The expression \'a == b\' will produce \'true\' if the result of a and b are equ
|
|
|
2176
2531
|
.
|
|
2177
2532
|
.nf
|
|
2178
2533
|
|
|
2534
|
+
jq \'\. == false\'
|
|
2535
|
+
null
|
|
2536
|
+
=> false
|
|
2537
|
+
|
|
2538
|
+
jq \'\. == {"b": {"d": (4 + 1e\-20), "c": 3}, "a":1}\'
|
|
2539
|
+
{"a":1, "b": {"c": 3, "d": 4}}
|
|
2540
|
+
=> true
|
|
2541
|
+
|
|
2179
2542
|
jq \'\.[] == 1\'
|
|
2180
2543
|
[1, 1\.0, "1", "banana"]
|
|
2181
2544
|
=> true, true, false, false
|
|
@@ -2184,11 +2547,14 @@ jq \'\.[] == 1\'
|
|
|
2184
2547
|
.
|
|
2185
2548
|
.IP "" 0
|
|
2186
2549
|
.
|
|
2187
|
-
.SS "if\-then\-else"
|
|
2550
|
+
.SS "if\-then\-else\-end"
|
|
2188
2551
|
\fBif A then B else C end\fR will act the same as \fBB\fR if \fBA\fR produces a value other than false or null, but act the same as \fBC\fR otherwise\.
|
|
2189
2552
|
.
|
|
2190
2553
|
.P
|
|
2191
|
-
|
|
2554
|
+
\fBif A then B end\fR is the same as \fBif A then B else \. end\fR\. That is, the \fBelse\fR branch is optional, and if absent is the same as \fB\.\fR\. This also applies to \fBelif\fR with absent ending \fBelse\fR branch\.
|
|
2555
|
+
.
|
|
2556
|
+
.P
|
|
2557
|
+
Checking for false or null is a simpler notion of "truthiness" than is found in JavaScript or Python, but it means that you\'ll sometimes have to be more explicit about the condition you want\. You can\'t test whether, e\.g\. a string is empty using \fBif \.name then A else B end\fR; you\'ll need something like \fBif \.name == "" then A else B end\fR instead\.
|
|
2192
2558
|
.
|
|
2193
2559
|
.P
|
|
2194
2560
|
If the condition \fBA\fR produces multiple results, then \fBB\fR is evaluated once for each result that is not false or null, and \fBC\fR is evaluated once for each false or null\.
|
|
@@ -2201,14 +2567,19 @@ More cases can be added to an if using \fBelif A then B\fR syntax\.
|
|
|
2201
2567
|
.nf
|
|
2202
2568
|
|
|
2203
2569
|
jq \'if \. == 0 then
|
|
2570
|
+
"zero"
|
|
2571
|
+
elif \. == 1 then
|
|
2572
|
+
"one"
|
|
2573
|
+
else
|
|
2574
|
+
"many"
|
|
2575
|
+
end\'
|
|
2576
|
+
2
|
|
2577
|
+
=> "many"
|
|
2204
2578
|
.
|
|
2205
2579
|
.fi
|
|
2206
2580
|
.
|
|
2207
2581
|
.IP "" 0
|
|
2208
2582
|
.
|
|
2209
|
-
.P
|
|
2210
|
-
"zero" elif \. == 1 then "one" else "many" end\' 2 => "many"
|
|
2211
|
-
.
|
|
2212
2583
|
.SS ">, >=, <=, <"
|
|
2213
2584
|
The comparison operators \fB>\fR, \fB>=\fR, \fB<=\fR, \fB<\fR return whether their left argument is greater than, greater than or equal to, less than or equal to or less than their right argument (respectively)\.
|
|
2214
2585
|
.
|
|
@@ -2227,8 +2598,8 @@ jq \'\. < 5\'
|
|
|
2227
2598
|
.
|
|
2228
2599
|
.IP "" 0
|
|
2229
2600
|
.
|
|
2230
|
-
.SS "and
|
|
2231
|
-
jq supports the normal Boolean operators
|
|
2601
|
+
.SS "and, or, not"
|
|
2602
|
+
jq supports the normal Boolean operators \fBand\fR, \fBor\fR, \fBnot\fR\. They have the same standard of truth as if expressions \- \fBfalse\fR and \fBnull\fR are considered "false values", and anything else is a "true value"\.
|
|
2232
2603
|
.
|
|
2233
2604
|
.P
|
|
2234
2605
|
If an operand of one of these operators produces multiple results, the operator itself will produce a result for each input\.
|
|
@@ -2237,7 +2608,7 @@ If an operand of one of these operators produces multiple results, the operator
|
|
|
2237
2608
|
\fBnot\fR is in fact a builtin function rather than an operator, so it is called as a filter to which things can be piped rather than with special syntax, as in \fB\.foo and \.bar | not\fR\.
|
|
2238
2609
|
.
|
|
2239
2610
|
.P
|
|
2240
|
-
These three only produce the values
|
|
2611
|
+
These three only produce the values \fBtrue\fR and \fBfalse\fR, and so are only useful for genuine Boolean operations, rather than the common Perl/Python/Ruby idiom of "value_that_may_be_null or default"\. If you want to use this form of "or", picking between two values rather than evaluating a condition, see the \fB//\fR operator below\.
|
|
2241
2612
|
.
|
|
2242
2613
|
.IP "" 4
|
|
2243
2614
|
.
|
|
@@ -2264,15 +2635,25 @@ jq \'[true, false | not]\'
|
|
|
2264
2635
|
.IP "" 0
|
|
2265
2636
|
.
|
|
2266
2637
|
.SS "Alternative operator: //"
|
|
2267
|
-
|
|
2638
|
+
The \fB//\fR operator produces all the values of its left\-hand side that are neither \fBfalse\fR nor \fBnull\fR\. If the left\-hand side produces no values other than \fBfalse\fR or \fBnull\fR, then \fB//\fR produces all the values of its right\-hand side\.
|
|
2639
|
+
.
|
|
2640
|
+
.P
|
|
2641
|
+
A filter of the form \fBa // b\fR produces all the results of \fBa\fR that are not \fBfalse\fR or \fBnull\fR\. If \fBa\fR produces no results, or no results other than \fBfalse\fR or \fBnull\fR, then \fBa // b\fR produces the results of \fBb\fR\.
|
|
2268
2642
|
.
|
|
2269
2643
|
.P
|
|
2270
2644
|
This is useful for providing defaults: \fB\.foo // 1\fR will evaluate to \fB1\fR if there\'s no \fB\.foo\fR element in the input\. It\'s similar to how \fBor\fR is sometimes used in Python (jq\'s \fBor\fR operator is reserved for strictly Boolean operations)\.
|
|
2271
2645
|
.
|
|
2646
|
+
.P
|
|
2647
|
+
Note: \fBsome_generator // defaults_here\fR is not the same as \fBsome_generator | \. // defaults_here\fR\. The latter will produce default values for all non\-\fBfalse\fR, non\-\fBnull\fR values of the left\-hand side, while the former will not\. Precedence rules can make this confusing\. For example, in \fBfalse, 1 // 2\fR the left\-hand side of \fB//\fR is \fB1\fR, not \fBfalse, 1\fR \-\- \fBfalse, 1 // 2\fR parses the same way as \fBfalse, (1 // 2)\fR\. In \fB(false, null, 1) | \. // 42\fR the left\-hand side of \fB//\fR is \fB\.\fR, which always produces just one value, while in \fB(false, null, 1) // 42\fR the left\-hand side is a generator of three values, and since it produces a value other \fBfalse\fR and \fBnull\fR, the default \fB42\fR is not produced\.
|
|
2648
|
+
.
|
|
2272
2649
|
.IP "" 4
|
|
2273
2650
|
.
|
|
2274
2651
|
.nf
|
|
2275
2652
|
|
|
2653
|
+
jq \'empty // 42\'
|
|
2654
|
+
null
|
|
2655
|
+
=> 42
|
|
2656
|
+
|
|
2276
2657
|
jq \'\.foo // 42\'
|
|
2277
2658
|
{"foo": 19}
|
|
2278
2659
|
=> 19
|
|
@@ -2280,6 +2661,14 @@ jq \'\.foo // 42\'
|
|
|
2280
2661
|
jq \'\.foo // 42\'
|
|
2281
2662
|
{}
|
|
2282
2663
|
=> 42
|
|
2664
|
+
|
|
2665
|
+
jq \'(false, null, 1) // 42\'
|
|
2666
|
+
null
|
|
2667
|
+
=> 1
|
|
2668
|
+
|
|
2669
|
+
jq \'(false, null, 1) | \. // 42\'
|
|
2670
|
+
null
|
|
2671
|
+
=> 42, 42, 1
|
|
2283
2672
|
.
|
|
2284
2673
|
.fi
|
|
2285
2674
|
.
|
|
@@ -2324,7 +2713,7 @@ For example:
|
|
|
2324
2713
|
# Repeat an expression until it raises "break" as an
|
|
2325
2714
|
# error, then stop repeating without re\-raising the error\.
|
|
2326
2715
|
# But if the error caught is not "break" then re\-raise it\.
|
|
2327
|
-
try repeat(exp) catch \.=="break" then empty else error
|
|
2716
|
+
try repeat(exp) catch if \.=="break" then empty else error
|
|
2328
2717
|
.
|
|
2329
2718
|
.fi
|
|
2330
2719
|
.
|
|
@@ -2344,7 +2733,7 @@ label $out | \.\.\. break $out \.\.\.
|
|
|
2344
2733
|
.IP "" 0
|
|
2345
2734
|
.
|
|
2346
2735
|
.P
|
|
2347
|
-
The \fBbreak $label_name\fR expression will cause the program to
|
|
2736
|
+
The \fBbreak $label_name\fR expression will cause the program to act as though the nearest (to the left) \fBlabel $label_name\fR produced \fBempty\fR\.
|
|
2348
2737
|
.
|
|
2349
2738
|
.P
|
|
2350
2739
|
The relationship between the \fBbreak\fR and corresponding \fBlabel\fR is lexical: the label has to be "visible" from the break\.
|
|
@@ -2385,16 +2774,25 @@ The \fB?\fR operator, used as \fBEXP?\fR, is shorthand for \fBtry EXP\fR\.
|
|
|
2385
2774
|
.
|
|
2386
2775
|
.nf
|
|
2387
2776
|
|
|
2388
|
-
jq \'[\.[]|
|
|
2777
|
+
jq \'[\.[] | \.a?]\'
|
|
2389
2778
|
[{}, true, {"a":1}]
|
|
2390
2779
|
=> [null, 1]
|
|
2780
|
+
|
|
2781
|
+
jq \'[\.[] | tonumber?]\'
|
|
2782
|
+
["1", "invalid", "3", 4]
|
|
2783
|
+
=> [1, 3, 4]
|
|
2391
2784
|
.
|
|
2392
2785
|
.fi
|
|
2393
2786
|
.
|
|
2394
2787
|
.IP "" 0
|
|
2395
2788
|
.
|
|
2396
|
-
.SH "REGULAR EXPRESSIONS
|
|
2397
|
-
jq uses the Oniguruma regular expression library, as do
|
|
2789
|
+
.SH "REGULAR EXPRESSIONS"
|
|
2790
|
+
jq uses the Oniguruma regular expression library, as do PHP, TextMate, Sublime Text, etc, so the description here will focus on jq specifics\.
|
|
2791
|
+
|
|
2792
|
+
.
|
|
2793
|
+
.P
|
|
2794
|
+
Oniguruma supports several flavors of regular expression, so it is important to know that jq uses the "Perl NG" (Perl with named groups) flavor\.
|
|
2795
|
+
|
|
2398
2796
|
.
|
|
2399
2797
|
.P
|
|
2400
2798
|
The jq regex filters are defined so that they can be used using one of these patterns:
|
|
@@ -2403,17 +2801,31 @@ The jq regex filters are defined so that they can be used using one of these pat
|
|
|
2403
2801
|
.
|
|
2404
2802
|
.nf
|
|
2405
2803
|
|
|
2406
|
-
STRING | FILTER(
|
|
2407
|
-
STRING | FILTER(
|
|
2408
|
-
STRING | FILTER(
|
|
2409
|
-
STRING | FILTER(
|
|
2804
|
+
STRING | FILTER(REGEX)
|
|
2805
|
+
STRING | FILTER(REGEX; FLAGS)
|
|
2806
|
+
STRING | FILTER([REGEX])
|
|
2807
|
+
STRING | FILTER([REGEX, FLAGS])
|
|
2410
2808
|
.
|
|
2411
2809
|
.fi
|
|
2412
2810
|
.
|
|
2413
2811
|
.IP "" 0
|
|
2414
2812
|
.
|
|
2415
2813
|
.P
|
|
2416
|
-
where:
|
|
2814
|
+
where:
|
|
2815
|
+
.
|
|
2816
|
+
.IP "\(bu" 4
|
|
2817
|
+
STRING, REGEX, and FLAGS are jq strings and subject to jq string interpolation;
|
|
2818
|
+
.
|
|
2819
|
+
.IP "\(bu" 4
|
|
2820
|
+
REGEX, after string interpolation, should be a valid regular expression;
|
|
2821
|
+
.
|
|
2822
|
+
.IP "\(bu" 4
|
|
2823
|
+
FILTER is one of \fBtest\fR, \fBmatch\fR, or \fBcapture\fR, as described below\.
|
|
2824
|
+
.
|
|
2825
|
+
.IP "" 0
|
|
2826
|
+
.
|
|
2827
|
+
.P
|
|
2828
|
+
Since REGEX must evaluate to a JSON string, some characters that are needed to form a regular expression must be escaped\. For example, the regular expression \fB\es\fR signifying a whitespace character would be written as \fB"\e\es"\fR\.
|
|
2417
2829
|
.
|
|
2418
2830
|
.P
|
|
2419
2831
|
FLAGS is a string consisting of one of more of the supported flags:
|
|
@@ -2425,7 +2837,7 @@ FLAGS is a string consisting of one of more of the supported flags:
|
|
|
2425
2837
|
\fBi\fR \- Case insensitive search
|
|
2426
2838
|
.
|
|
2427
2839
|
.IP "\(bu" 4
|
|
2428
|
-
\fBm\fR \- Multi line mode (\
|
|
2840
|
+
\fBm\fR \- Multi line mode (\fB\.\fR will match newlines)
|
|
2429
2841
|
.
|
|
2430
2842
|
.IP "\(bu" 4
|
|
2431
2843
|
\fBn\fR \- Ignore empty matches
|
|
@@ -2434,7 +2846,7 @@ FLAGS is a string consisting of one of more of the supported flags:
|
|
|
2434
2846
|
\fBp\fR \- Both s and m modes are enabled
|
|
2435
2847
|
.
|
|
2436
2848
|
.IP "\(bu" 4
|
|
2437
|
-
\fBs\fR \- Single line mode (\
|
|
2849
|
+
\fBs\fR \- Single line mode (\fB^\fR \-> \fB\eA\fR, \fB$\fR \-> \fB\eZ\fR)
|
|
2438
2850
|
.
|
|
2439
2851
|
.IP "\(bu" 4
|
|
2440
2852
|
\fBl\fR \- Find longest possible matches
|
|
@@ -2445,23 +2857,33 @@ FLAGS is a string consisting of one of more of the supported flags:
|
|
|
2445
2857
|
.IP "" 0
|
|
2446
2858
|
.
|
|
2447
2859
|
.P
|
|
2448
|
-
To match whitespace
|
|
2860
|
+
To match a whitespace with the \fBx\fR flag, use \fB\es\fR, e\.g\.
|
|
2449
2861
|
.
|
|
2450
|
-
.IP "
|
|
2451
|
-
|
|
2862
|
+
.IP "" 4
|
|
2863
|
+
.
|
|
2864
|
+
.nf
|
|
2865
|
+
|
|
2866
|
+
jq \-n \'"a b" | test("a\e\esb"; "x")\'
|
|
2867
|
+
.
|
|
2868
|
+
.fi
|
|
2452
2869
|
.
|
|
2453
2870
|
.IP "" 0
|
|
2454
2871
|
.
|
|
2455
2872
|
.P
|
|
2456
2873
|
Note that certain flags may also be specified within REGEX, e\.g\.
|
|
2457
2874
|
.
|
|
2458
|
-
.IP "
|
|
2459
|
-
|
|
2875
|
+
.IP "" 4
|
|
2876
|
+
.
|
|
2877
|
+
.nf
|
|
2878
|
+
|
|
2879
|
+
jq \-n \'("test", "TEst", "teST", "TEST") | test("(?i)te(?\-i)st")\'
|
|
2880
|
+
.
|
|
2881
|
+
.fi
|
|
2460
2882
|
.
|
|
2461
2883
|
.IP "" 0
|
|
2462
2884
|
.
|
|
2463
2885
|
.P
|
|
2464
|
-
evaluates to:
|
|
2886
|
+
evaluates to: \fBtrue\fR, \fBtrue\fR, \fBfalse\fR, \fBfalse\fR\.
|
|
2465
2887
|
.
|
|
2466
2888
|
.SS "test(val), test(regex; flags)"
|
|
2467
2889
|
Like \fBmatch\fR, but does not return match objects, only \fBtrue\fR or \fBfalse\fR for whether or not the regex matches the input\.
|
|
@@ -2565,17 +2987,88 @@ jq \'capture("(?<a>[a\-z]+)\-(?<n>[0\-9]+)")\'
|
|
|
2565
2987
|
.SS "scan(regex), scan(regex; flags)"
|
|
2566
2988
|
Emit a stream of the non\-overlapping substrings of the input that match the regex in accordance with the flags, if any have been specified\. If there is no match, the stream is empty\. To capture all the matches for each input string, use the idiom \fB[ expr ]\fR, e\.g\. \fB[ scan(regex) ]\fR\.
|
|
2567
2989
|
.
|
|
2990
|
+
.IP "" 4
|
|
2991
|
+
.
|
|
2992
|
+
.nf
|
|
2993
|
+
|
|
2994
|
+
jq \'scan("c")\'
|
|
2995
|
+
"abcdefabc"
|
|
2996
|
+
=> "c", "c"
|
|
2997
|
+
.
|
|
2998
|
+
.fi
|
|
2999
|
+
.
|
|
3000
|
+
.IP "" 0
|
|
3001
|
+
.
|
|
2568
3002
|
.SS "split(regex; flags)"
|
|
2569
|
-
|
|
3003
|
+
Splits an input string on each regex match\.
|
|
3004
|
+
.
|
|
3005
|
+
.P
|
|
3006
|
+
For backwards compatibility, when called with a single argument, \fBsplit\fR splits on a string, not a regex\.
|
|
3007
|
+
.
|
|
3008
|
+
.IP "" 4
|
|
3009
|
+
.
|
|
3010
|
+
.nf
|
|
3011
|
+
|
|
3012
|
+
jq \'split(", *"; null)\'
|
|
3013
|
+
"ab,cd, ef"
|
|
3014
|
+
=> ["ab","cd","ef"]
|
|
3015
|
+
.
|
|
3016
|
+
.fi
|
|
3017
|
+
.
|
|
3018
|
+
.IP "" 0
|
|
2570
3019
|
.
|
|
2571
3020
|
.SS "splits(regex), splits(regex; flags)"
|
|
2572
3021
|
These provide the same results as their \fBsplit\fR counterparts, but as a stream instead of an array\.
|
|
2573
3022
|
.
|
|
2574
|
-
.
|
|
2575
|
-
|
|
3023
|
+
.IP "" 4
|
|
3024
|
+
.
|
|
3025
|
+
.nf
|
|
3026
|
+
|
|
3027
|
+
jq \'splits(", *")\'
|
|
3028
|
+
"ab,cd, ef, gh"
|
|
3029
|
+
=> "ab", "cd", "ef", "gh"
|
|
3030
|
+
.
|
|
3031
|
+
.fi
|
|
3032
|
+
.
|
|
3033
|
+
.IP "" 0
|
|
3034
|
+
.
|
|
3035
|
+
.SS "sub(regex; tostring), sub(regex; tostring; flags)"
|
|
3036
|
+
Emit the string obtained by replacing the first match of regex in the input string with \fBtostring\fR, after interpolation\. \fBtostring\fR should be a jq string or a stream of such strings, each of which may contain references to named captures\. The named captures are, in effect, presented as a JSON object (as constructed by \fBcapture\fR) to \fBtostring\fR, so a reference to a captured variable named "x" would take the form: \fB"\e(\.x)"\fR\.
|
|
3037
|
+
.
|
|
3038
|
+
.IP "" 4
|
|
3039
|
+
.
|
|
3040
|
+
.nf
|
|
3041
|
+
|
|
3042
|
+
jq \'sub("[^a\-z]*(?<x>[a\-z]+)"; "Z\e(\.x)"; "g")\'
|
|
3043
|
+
"123abc456def"
|
|
3044
|
+
=> "ZabcZdef"
|
|
3045
|
+
|
|
3046
|
+
jq \'[sub("(?<a>\.)"; "\e(\.a|ascii_upcase)", "\e(\.a|ascii_downcase)")]\'
|
|
3047
|
+
"aB"
|
|
3048
|
+
=> ["AB","aB"]
|
|
3049
|
+
.
|
|
3050
|
+
.fi
|
|
3051
|
+
.
|
|
3052
|
+
.IP "" 0
|
|
3053
|
+
.
|
|
3054
|
+
.SS "gsub(regex; tostring), gsub(regex; tostring; flags)"
|
|
3055
|
+
\fBgsub\fR is like \fBsub\fR but all the non\-overlapping occurrences of the regex are replaced by \fBtostring\fR, after interpolation\. If the second argument is a stream of jq strings, then \fBgsub\fR will produce a corresponding stream of JSON strings\.
|
|
3056
|
+
.
|
|
3057
|
+
.IP "" 4
|
|
2576
3058
|
.
|
|
2577
|
-
.
|
|
2578
|
-
|
|
3059
|
+
.nf
|
|
3060
|
+
|
|
3061
|
+
jq \'gsub("(?<x>\.)[^a]*"; "+\e(\.x)\-")\'
|
|
3062
|
+
"Abcabc"
|
|
3063
|
+
=> "+A\-+a\-"
|
|
3064
|
+
|
|
3065
|
+
jq \'[gsub("p"; "a", "b")]\'
|
|
3066
|
+
"p"
|
|
3067
|
+
=> ["a","b"]
|
|
3068
|
+
.
|
|
3069
|
+
.fi
|
|
3070
|
+
.
|
|
3071
|
+
.IP "" 0
|
|
2579
3072
|
.
|
|
2580
3073
|
.SH "ADVANCED FEATURES"
|
|
2581
3074
|
Variables are an absolute necessity in most programming languages, but they\'re relegated to an "advanced feature" in jq\.
|
|
@@ -2584,7 +3077,7 @@ Variables are an absolute necessity in most programming languages, but they\'re
|
|
|
2584
3077
|
In most languages, variables are the only means of passing around data\. If you calculate a value, and you want to use it more than once, you\'ll need to store it in a variable\. To pass a value to another part of the program, you\'ll need that part of the program to define a variable (as a function parameter, object member, or whatever) in which to place the data\.
|
|
2585
3078
|
.
|
|
2586
3079
|
.P
|
|
2587
|
-
It is also possible to define functions in jq, although this is is a feature whose biggest use is defining jq\'s standard library (many jq functions such as \fBmap\fR and \
|
|
3080
|
+
It is also possible to define functions in jq, although this is is a feature whose biggest use is defining jq\'s standard library (many jq functions such as \fBmap\fR and \fBselect\fR are in fact written in jq)\.
|
|
2588
3081
|
.
|
|
2589
3082
|
.P
|
|
2590
3083
|
jq has reduction operators, which are very powerful but a bit tricky\. Again, these are mostly used internally, to define some useful bits of jq\'s standard library\.
|
|
@@ -2627,7 +3120,7 @@ Suppose we have an array of blog posts, with "author" and "title" fields, and an
|
|
|
2627
3120
|
.
|
|
2628
3121
|
.nf
|
|
2629
3122
|
|
|
2630
|
-
{"posts": [{"title": "
|
|
3123
|
+
{"posts": [{"title": "First post", "author": "anon"},
|
|
2631
3124
|
{"title": "A well\-written article", "author": "person1"}],
|
|
2632
3125
|
"realnames": {"anon": "Anonymous Coward",
|
|
2633
3126
|
"person1": "Person McPherson"}}
|
|
@@ -2643,7 +3136,7 @@ We want to produce the posts with the author field containing a real name, as in
|
|
|
2643
3136
|
.
|
|
2644
3137
|
.nf
|
|
2645
3138
|
|
|
2646
|
-
{"title": "
|
|
3139
|
+
{"title": "First post", "author": "Anonymous Coward"}
|
|
2647
3140
|
{"title": "A well\-written article", "author": "Person McPherson"}
|
|
2648
3141
|
.
|
|
2649
3142
|
.fi
|
|
@@ -2657,7 +3150,7 @@ We use a variable, $names, to store the realnames object, so that we can refer t
|
|
|
2657
3150
|
.
|
|
2658
3151
|
.nf
|
|
2659
3152
|
|
|
2660
|
-
|
|
3153
|
+
\&.realnames as $names | \.posts[] | {title, author: $names[\.author]}
|
|
2661
3154
|
.
|
|
2662
3155
|
.fi
|
|
2663
3156
|
.
|
|
@@ -2667,7 +3160,7 @@ We use a variable, $names, to store the realnames object, so that we can refer t
|
|
|
2667
3160
|
The expression \fBexp as $x | \.\.\.\fR means: for each value of expression \fBexp\fR, run the rest of the pipeline with the entire original input, and with \fB$x\fR set to that value\. Thus \fBas\fR functions as something of a foreach loop\.
|
|
2668
3161
|
.
|
|
2669
3162
|
.P
|
|
2670
|
-
Just as \fB{foo}\fR is a handy way of writing \fB{foo: \.foo}\fR, so \fB{$foo}\fR is a handy way of writing \fB{foo
|
|
3163
|
+
Just as \fB{foo}\fR is a handy way of writing \fB{foo: \.foo}\fR, so \fB{$foo}\fR is a handy way of writing \fB{foo: $foo}\fR\.
|
|
2671
3164
|
.
|
|
2672
3165
|
.P
|
|
2673
3166
|
Multiple variables may be declared using a single \fBas\fR expression by providing a pattern that matches the structure of the input (this is known as "destructuring"):
|
|
@@ -2676,7 +3169,7 @@ Multiple variables may be declared using a single \fBas\fR expression by providi
|
|
|
2676
3169
|
.
|
|
2677
3170
|
.nf
|
|
2678
3171
|
|
|
2679
|
-
|
|
3172
|
+
\&. as {realnames: $names, posts: [$first, $second]} | \.\.\.
|
|
2680
3173
|
.
|
|
2681
3174
|
.fi
|
|
2682
3175
|
.
|
|
@@ -2692,7 +3185,7 @@ Variables are scoped over the rest of the expression that defines them, so
|
|
|
2692
3185
|
.
|
|
2693
3186
|
.nf
|
|
2694
3187
|
|
|
2695
|
-
|
|
3188
|
+
\&.realnames as $names | (\.posts[] | {title, author: $names[\.author]})
|
|
2696
3189
|
.
|
|
2697
3190
|
.fi
|
|
2698
3191
|
.
|
|
@@ -2741,6 +3234,87 @@ jq \'\.[] as [$a, $b] | {a: $a, b: $b}\'
|
|
|
2741
3234
|
.
|
|
2742
3235
|
.IP "" 0
|
|
2743
3236
|
.
|
|
3237
|
+
.SS "Destructuring Alternative Operator: ?//"
|
|
3238
|
+
The destructuring alternative operator provides a concise mechanism for destructuring an input that can take one of several forms\.
|
|
3239
|
+
.
|
|
3240
|
+
.P
|
|
3241
|
+
Suppose we have an API that returns a list of resources and events associated with them, and we want to get the user_id and timestamp of the first event for each resource\. The API (having been clumsily converted from XML) will only wrap the events in an array if the resource has multiple events:
|
|
3242
|
+
.
|
|
3243
|
+
.IP "" 4
|
|
3244
|
+
.
|
|
3245
|
+
.nf
|
|
3246
|
+
|
|
3247
|
+
{"resources": [{"id": 1, "kind": "widget", "events": {"action": "create", "user_id": 1, "ts": 13}},
|
|
3248
|
+
{"id": 2, "kind": "widget", "events": [{"action": "create", "user_id": 1, "ts": 14}, {"action": "destroy", "user_id": 1, "ts": 15}]}]}
|
|
3249
|
+
.
|
|
3250
|
+
.fi
|
|
3251
|
+
.
|
|
3252
|
+
.IP "" 0
|
|
3253
|
+
.
|
|
3254
|
+
.P
|
|
3255
|
+
We can use the destructuring alternative operator to handle this structural change simply:
|
|
3256
|
+
.
|
|
3257
|
+
.IP "" 4
|
|
3258
|
+
.
|
|
3259
|
+
.nf
|
|
3260
|
+
|
|
3261
|
+
\&.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}
|
|
3262
|
+
.
|
|
3263
|
+
.fi
|
|
3264
|
+
.
|
|
3265
|
+
.IP "" 0
|
|
3266
|
+
.
|
|
3267
|
+
.P
|
|
3268
|
+
Or, if we aren\'t sure if the input is an array of values or an object:
|
|
3269
|
+
.
|
|
3270
|
+
.IP "" 4
|
|
3271
|
+
.
|
|
3272
|
+
.nf
|
|
3273
|
+
|
|
3274
|
+
\&.[] as [$id, $kind, $user_id, $ts] ?// {$id, $kind, $user_id, $ts} | \.\.\.
|
|
3275
|
+
.
|
|
3276
|
+
.fi
|
|
3277
|
+
.
|
|
3278
|
+
.IP "" 0
|
|
3279
|
+
.
|
|
3280
|
+
.P
|
|
3281
|
+
Each alternative need not define all of the same variables, but all named variables will be available to the subsequent expression\. Variables not matched in the alternative that succeeded will be \fBnull\fR:
|
|
3282
|
+
.
|
|
3283
|
+
.IP "" 4
|
|
3284
|
+
.
|
|
3285
|
+
.nf
|
|
3286
|
+
|
|
3287
|
+
\&.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}
|
|
3288
|
+
.
|
|
3289
|
+
.fi
|
|
3290
|
+
.
|
|
3291
|
+
.IP "" 0
|
|
3292
|
+
.
|
|
3293
|
+
.P
|
|
3294
|
+
Additionally, if the subsequent expression returns an error, the alternative operator will attempt to try the next binding\. Errors that occur during the final alternative are passed through\.
|
|
3295
|
+
.
|
|
3296
|
+
.IP "" 4
|
|
3297
|
+
.
|
|
3298
|
+
.nf
|
|
3299
|
+
|
|
3300
|
+
[[3]] | \.[] as [$a] ?// [$b] | if $a != null then error("err: \e($a)") else {$a,$b} end
|
|
3301
|
+
|
|
3302
|
+
jq \'\.[] as {$a, $b, c: {$d, $e}} ?// {$a, $b, c: [{$d, $e}]} | {$a, $b, $d, $e}\'
|
|
3303
|
+
[{"a": 1, "b": 2, "c": {"d": 3, "e": 4}}, {"a": 1, "b": 2, "c": [{"d": 3, "e": 4}]}]
|
|
3304
|
+
=> {"a":1,"b":2,"d":3,"e":4}, {"a":1,"b":2,"d":3,"e":4}
|
|
3305
|
+
|
|
3306
|
+
jq \'\.[] as {$a, $b, c: {$d}} ?// {$a, $b, c: [{$e}]} | {$a, $b, $d, $e}\'
|
|
3307
|
+
[{"a": 1, "b": 2, "c": {"d": 3, "e": 4}}, {"a": 1, "b": 2, "c": [{"d": 3, "e": 4}]}]
|
|
3308
|
+
=> {"a":1,"b":2,"d":3,"e":null}, {"a":1,"b":2,"d":null,"e":4}
|
|
3309
|
+
|
|
3310
|
+
jq \'\.[] as [$a] ?// [$b] | if $a != null then error("err: \e($a)") else {$a,$b} end\'
|
|
3311
|
+
[[3]]
|
|
3312
|
+
=> {"a":null,"b":3}
|
|
3313
|
+
.
|
|
3314
|
+
.fi
|
|
3315
|
+
.
|
|
3316
|
+
.IP "" 0
|
|
3317
|
+
.
|
|
2744
3318
|
.SS "Defining Functions"
|
|
2745
3319
|
You can give a filter a name using "def" syntax:
|
|
2746
3320
|
.
|
|
@@ -2836,65 +3410,56 @@ jq \'def addvalue(f): f as $x | map(\. + $x); addvalue(\.[0])\'
|
|
|
2836
3410
|
There are two types of symbols in jq: value bindings (a\.k\.a\., "variables"), and functions\. Both are scoped lexically, with expressions being able to refer only to symbols that have been defined "to the left" of them\. The only exception to this rule is that functions can refer to themselves so as to be able to create recursive functions\.
|
|
2837
3411
|
.
|
|
2838
3412
|
.P
|
|
2839
|
-
For example, in the following expression there is a binding which is visible "to the right" of it, \fB\.\.\. | \.*3 as $times_three | [\. + $times_three] | \.\.\.\fR, but not "to the left"\. Consider this expression now, \fB\.\.\. | (\.*3 as $times_three | [
|
|
3413
|
+
For example, in the following expression there is a binding which is visible "to the right" of it, \fB\.\.\. | \.*3 as $times_three | [\. + $times_three] | \.\.\.\fR, but not "to the left"\. Consider this expression now, \fB\.\.\. | (\.*3 as $times_three | [\. + $times_three]) | \.\.\.\fR: here the binding \fB$times_three\fR is \fInot\fR visible past the closing parenthesis\.
|
|
2840
3414
|
.
|
|
2841
|
-
.SS "
|
|
2842
|
-
|
|
3415
|
+
.SS "isempty(exp)"
|
|
3416
|
+
Returns true if \fBexp\fR produces no outputs, false otherwise\.
|
|
2843
3417
|
.
|
|
2844
3418
|
.IP "" 4
|
|
2845
3419
|
.
|
|
2846
3420
|
.nf
|
|
2847
3421
|
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
.
|
|
2852
|
-
.IP "" 0
|
|
2853
|
-
.
|
|
2854
|
-
.P
|
|
2855
|
-
For each result that \fB\.[]\fR produces, \fB\. + $item\fR is run to accumulate a running total, starting from 0\. In this example, \fB\.[]\fR produces the results 3, 2, and 1, so the effect is similar to running something like this:
|
|
2856
|
-
.
|
|
2857
|
-
.IP "" 4
|
|
2858
|
-
.
|
|
2859
|
-
.nf
|
|
3422
|
+
jq \'isempty(empty)\'
|
|
3423
|
+
null
|
|
3424
|
+
=> true
|
|
2860
3425
|
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
3426
|
+
jq \'isempty(\.[])\'
|
|
3427
|
+
[]
|
|
3428
|
+
=> true
|
|
2864
3429
|
|
|
2865
|
-
jq \'
|
|
2866
|
-
[
|
|
2867
|
-
=>
|
|
3430
|
+
jq \'isempty(\.[])\'
|
|
3431
|
+
[1,2,3]
|
|
3432
|
+
=> false
|
|
2868
3433
|
.
|
|
2869
3434
|
.fi
|
|
2870
3435
|
.
|
|
2871
3436
|
.IP "" 0
|
|
2872
3437
|
.
|
|
2873
|
-
.SS "
|
|
2874
|
-
|
|
3438
|
+
.SS "limit(n; expr)"
|
|
3439
|
+
The \fBlimit\fR function extracts up to \fBn\fR outputs from \fBexpr\fR\.
|
|
2875
3440
|
.
|
|
2876
3441
|
.IP "" 4
|
|
2877
3442
|
.
|
|
2878
3443
|
.nf
|
|
2879
3444
|
|
|
2880
|
-
jq \'
|
|
2881
|
-
|
|
2882
|
-
=>
|
|
3445
|
+
jq \'[limit(3; \.[])]\'
|
|
3446
|
+
[0,1,2,3,4,5,6,7,8,9]
|
|
3447
|
+
=> [0,1,2]
|
|
2883
3448
|
.
|
|
2884
3449
|
.fi
|
|
2885
3450
|
.
|
|
2886
3451
|
.IP "" 0
|
|
2887
3452
|
.
|
|
2888
|
-
.SS "
|
|
2889
|
-
The \
|
|
3453
|
+
.SS "skip(n; expr)"
|
|
3454
|
+
The \fBskip\fR function skips the first \fBn\fR outputs from \fBexpr\fR\.
|
|
2890
3455
|
.
|
|
2891
3456
|
.IP "" 4
|
|
2892
3457
|
.
|
|
2893
3458
|
.nf
|
|
2894
3459
|
|
|
2895
|
-
jq \'[
|
|
3460
|
+
jq \'[skip(3; \.[])]\'
|
|
2896
3461
|
[0,1,2,3,4,5,6,7,8,9]
|
|
2897
|
-
=> [
|
|
3462
|
+
=> [3,4,5,6,7,8,9]
|
|
2898
3463
|
.
|
|
2899
3464
|
.fi
|
|
2900
3465
|
.
|
|
@@ -2904,15 +3469,19 @@ jq \'[limit(3;\.[])]\'
|
|
|
2904
3469
|
The \fBfirst(expr)\fR and \fBlast(expr)\fR functions extract the first and last values from \fBexpr\fR, respectively\.
|
|
2905
3470
|
.
|
|
2906
3471
|
.P
|
|
2907
|
-
The \fBnth(n; expr)\fR function extracts the nth value output by \fBexpr\fR\.
|
|
3472
|
+
The \fBnth(n; expr)\fR function extracts the nth value output by \fBexpr\fR\. Note that \fBnth(n; expr)\fR doesn\'t support negative values of \fBn\fR\.
|
|
2908
3473
|
.
|
|
2909
3474
|
.IP "" 4
|
|
2910
3475
|
.
|
|
2911
3476
|
.nf
|
|
2912
3477
|
|
|
2913
|
-
jq \'[first(range(\.)), last(range(\.)), nth(
|
|
3478
|
+
jq \'[first(range(\.)), last(range(\.)), nth(5; range(\.))]\'
|
|
2914
3479
|
10
|
|
2915
3480
|
=> [0,9,5]
|
|
3481
|
+
|
|
3482
|
+
jq \'[first(empty), last(empty), nth(5; empty)]\'
|
|
3483
|
+
null
|
|
3484
|
+
=> []
|
|
2916
3485
|
.
|
|
2917
3486
|
.fi
|
|
2918
3487
|
.
|
|
@@ -2936,22 +3505,95 @@ jq \'[range(\.)]|[first, last, nth(5)]\'
|
|
|
2936
3505
|
.
|
|
2937
3506
|
.IP "" 0
|
|
2938
3507
|
.
|
|
3508
|
+
.SS "reduce"
|
|
3509
|
+
The \fBreduce\fR syntax allows you to combine all of the results of an expression by accumulating them into a single answer\. The form is \fBreduce EXP as $var (INIT; UPDATE)\fR\. As an example, we\'ll pass \fB[1,2,3]\fR to this expression:
|
|
3510
|
+
.
|
|
3511
|
+
.IP "" 4
|
|
3512
|
+
.
|
|
3513
|
+
.nf
|
|
3514
|
+
|
|
3515
|
+
reduce \.[] as $item (0; \. + $item)
|
|
3516
|
+
.
|
|
3517
|
+
.fi
|
|
3518
|
+
.
|
|
3519
|
+
.IP "" 0
|
|
3520
|
+
.
|
|
3521
|
+
.P
|
|
3522
|
+
For each result that \fB\.[]\fR produces, \fB\. + $item\fR is run to accumulate a running total, starting from 0 as the input value\. In this example, \fB\.[]\fR produces the results \fB1\fR, \fB2\fR, and \fB3\fR, so the effect is similar to running something like this:
|
|
3523
|
+
.
|
|
3524
|
+
.IP "" 4
|
|
3525
|
+
.
|
|
3526
|
+
.nf
|
|
3527
|
+
|
|
3528
|
+
0 | 1 as $item | \. + $item |
|
|
3529
|
+
2 as $item | \. + $item |
|
|
3530
|
+
3 as $item | \. + $item
|
|
3531
|
+
|
|
3532
|
+
jq \'reduce \.[] as $item (0; \. + $item)\'
|
|
3533
|
+
[1,2,3,4,5]
|
|
3534
|
+
=> 15
|
|
3535
|
+
|
|
3536
|
+
jq \'reduce \.[] as [$i,$j] (0; \. + $i * $j)\'
|
|
3537
|
+
[[1,2],[3,4],[5,6]]
|
|
3538
|
+
=> 44
|
|
3539
|
+
|
|
3540
|
+
jq \'reduce \.[] as {$x,$y} (null; \.x += $x | \.y += [$y])\'
|
|
3541
|
+
[{"x":"a","y":1},{"x":"b","y":2},{"x":"c","y":3}]
|
|
3542
|
+
=> {"x":"abc","y":[1,2,3]}
|
|
3543
|
+
.
|
|
3544
|
+
.fi
|
|
3545
|
+
.
|
|
3546
|
+
.IP "" 0
|
|
3547
|
+
.
|
|
2939
3548
|
.SS "foreach"
|
|
2940
|
-
The \fBforeach\fR syntax is similar to \fBreduce\fR, but intended to allow the construction of \fBlimit\fR and reducers that produce intermediate results
|
|
3549
|
+
The \fBforeach\fR syntax is similar to \fBreduce\fR, but intended to allow the construction of \fBlimit\fR and reducers that produce intermediate results\.
|
|
3550
|
+
.
|
|
3551
|
+
.P
|
|
3552
|
+
The form is \fBforeach EXP as $var (INIT; UPDATE; EXTRACT)\fR\. As an example, we\'ll pass \fB[1,2,3]\fR to this expression:
|
|
3553
|
+
.
|
|
3554
|
+
.IP "" 4
|
|
3555
|
+
.
|
|
3556
|
+
.nf
|
|
3557
|
+
|
|
3558
|
+
foreach \.[] as $item (0; \. + $item; [$item, \. * 2])
|
|
3559
|
+
.
|
|
3560
|
+
.fi
|
|
3561
|
+
.
|
|
3562
|
+
.IP "" 0
|
|
2941
3563
|
.
|
|
2942
3564
|
.P
|
|
2943
|
-
|
|
3565
|
+
Like the \fBreduce\fR syntax, \fB\. + $item\fR is run for each result that \fB\.[]\fR produces, but \fB[$item, \. * 2]\fR is run for each intermediate values\. In this example, since the intermediate values are \fB1\fR, \fB3\fR, and \fB6\fR, the \fBforeach\fR expression produces \fB[1,2]\fR, \fB[2,6]\fR, and \fB[3,12]\fR\. So the effect is similar to running something like this:
|
|
3566
|
+
.
|
|
3567
|
+
.IP "" 4
|
|
3568
|
+
.
|
|
3569
|
+
.nf
|
|
3570
|
+
|
|
3571
|
+
0 | 1 as $item | \. + $item | [$item, \. * 2],
|
|
3572
|
+
2 as $item | \. + $item | [$item, \. * 2],
|
|
3573
|
+
3 as $item | \. + $item | [$item, \. * 2]
|
|
3574
|
+
.
|
|
3575
|
+
.fi
|
|
3576
|
+
.
|
|
3577
|
+
.IP "" 0
|
|
2944
3578
|
.
|
|
2945
3579
|
.P
|
|
2946
|
-
|
|
3580
|
+
When \fBEXTRACT\fR is omitted, the identity filter is used\. That is, it outputs the intermediate values as they are\.
|
|
2947
3581
|
.
|
|
2948
3582
|
.IP "" 4
|
|
2949
3583
|
.
|
|
2950
3584
|
.nf
|
|
2951
3585
|
|
|
2952
|
-
jq \'
|
|
2953
|
-
[1,2,3,4,
|
|
2954
|
-
=>
|
|
3586
|
+
jq \'foreach \.[] as $item (0; \. + $item)\'
|
|
3587
|
+
[1,2,3,4,5]
|
|
3588
|
+
=> 1, 3, 6, 10, 15
|
|
3589
|
+
|
|
3590
|
+
jq \'foreach \.[] as $item (0; \. + $item; [$item, \. * 2])\'
|
|
3591
|
+
[1,2,3,4,5]
|
|
3592
|
+
=> [1,2], [2,6], [3,12], [4,20], [5,30]
|
|
3593
|
+
|
|
3594
|
+
jq \'foreach \.[] as $item (0; \. + 1; {index: \., $item})\'
|
|
3595
|
+
["foo", "bar", "baz"]
|
|
3596
|
+
=> {"index":1,"item":"foo"}, {"index":2,"item":"bar"}, {"index":3,"item":"baz"}
|
|
2955
3597
|
.
|
|
2956
3598
|
.fi
|
|
2957
3599
|
.
|
|
@@ -2990,13 +3632,13 @@ def repeat(exp):
|
|
|
2990
3632
|
Some jq operators and functions are actually generators in that they can produce zero, one, or more values for each input, just as one might expect in other programming languages that have generators\. For example, \fB\.[]\fR generates all the values in its input (which must be an array or an object), \fBrange(0; 10)\fR generates the integers between 0 and 10, and so on\.
|
|
2991
3633
|
.
|
|
2992
3634
|
.P
|
|
2993
|
-
Even the comma operator is a generator, generating first the values generated by the expression to the left of the comma, then
|
|
3635
|
+
Even the comma operator is a generator, generating first the values generated by the expression to the left of the comma, then the values generated by the expression on the right of the comma\.
|
|
2994
3636
|
.
|
|
2995
3637
|
.P
|
|
2996
3638
|
The \fBempty\fR builtin is the generator that produces zero outputs\. The \fBempty\fR builtin backtracks to the preceding generator expression\.
|
|
2997
3639
|
.
|
|
2998
3640
|
.P
|
|
2999
|
-
All jq functions can be generators just by using builtin generators\. It is also possible to
|
|
3641
|
+
All jq functions can be generators just by using builtin generators\. It is also possible to construct new generators using only recursion and the comma operator\. If recursive calls are "in tail position" then the generator will be efficient\. In the example below the recursive call by \fB_range\fR to itself is in tail position\. The example shows off three advanced topics: tail recursion, generator construction, and sub\-functions\.
|
|
3000
3642
|
.
|
|
3001
3643
|
.IP "" 4
|
|
3002
3644
|
.
|
|
@@ -3024,7 +3666,7 @@ Besides simple arithmetic operators such as \fB+\fR, jq also has most standard m
|
|
|
3024
3666
|
Availability of standard math functions depends on the availability of the corresponding math functions in your operating system and C math library\. Unavailable math functions will be defined but will raise an error\.
|
|
3025
3667
|
.
|
|
3026
3668
|
.P
|
|
3027
|
-
One\-input C math functions: \fBacos\fR \fBacosh\fR \fBasin\fR \fBasinh\fR \fBatan\fR \fBatanh\fR \fBcbrt\fR \fBceil\fR \fBcos\fR \fBcosh\fR \fBerf\fR \fBerfc\fR \fBexp\fR \fBexp10\fR \fBexp2\fR \fBexpm1\fR \fBfabs\fR \fBfloor\fR \fBgamma\fR \fBj0\fR \fBj1\fR \fBlgamma\fR \fBlog\fR \fBlog10\fR \fBlog1p\fR \fBlog2\fR \fBlogb\fR \fBnearbyint\fR \
|
|
3669
|
+
One\-input C math functions: \fBacos\fR \fBacosh\fR \fBasin\fR \fBasinh\fR \fBatan\fR \fBatanh\fR \fBcbrt\fR \fBceil\fR \fBcos\fR \fBcosh\fR \fBerf\fR \fBerfc\fR \fBexp\fR \fBexp10\fR \fBexp2\fR \fBexpm1\fR \fBfabs\fR \fBfloor\fR \fBgamma\fR \fBj0\fR \fBj1\fR \fBlgamma\fR \fBlog\fR \fBlog10\fR \fBlog1p\fR \fBlog2\fR \fBlogb\fR \fBnearbyint\fR \fBrint\fR \fBround\fR \fBsignificand\fR \fBsin\fR \fBsinh\fR \fBsqrt\fR \fBtan\fR \fBtanh\fR \fBtgamma\fR \fBtrunc\fR \fBy0\fR \fBy1\fR\.
|
|
3028
3670
|
.
|
|
3029
3671
|
.P
|
|
3030
3672
|
Two\-input C math functions: \fBatan2\fR \fBcopysign\fR \fBdrem\fR \fBfdim\fR \fBfmax\fR \fBfmin\fR \fBfmod\fR \fBfrexp\fR \fBhypot\fR \fBjn\fR \fBldexp\fR \fBmodf\fR \fBnextafter\fR \fBnexttoward\fR \fBpow\fR \fBremainder\fR \fBscalb\fR \fBscalbln\fR \fByn\fR\.
|
|
@@ -3036,7 +3678,7 @@ Three\-input C math functions: \fBfma\fR\.
|
|
|
3036
3678
|
See your system\'s manual for more information on each of these\.
|
|
3037
3679
|
.
|
|
3038
3680
|
.SH "I/O"
|
|
3039
|
-
At this time jq has minimal support for I/O, mostly in the form of control over when inputs are read\. Two builtins functions are provided for this, \fBinput\fR and \fBinputs\fR, that read from the same sources (e\.g\., \fBstdin\fR, files named on the command\-line) as jq itself\. These two builtins, and jq\'s own reading actions, can be interleaved with each other\.
|
|
3681
|
+
At this time jq has minimal support for I/O, mostly in the form of control over when inputs are read\. Two builtins functions are provided for this, \fBinput\fR and \fBinputs\fR, that read from the same sources (e\.g\., \fBstdin\fR, files named on the command\-line) as jq itself\. These two builtins, and jq\'s own reading actions, can be interleaved with each other\. They are commonly used in combination with the null input option \fB\-n\fR to prevent one input from being read implicitly\.
|
|
3040
3682
|
.
|
|
3041
3683
|
.P
|
|
3042
3684
|
Two builtins provide minimal output capabilities, \fBdebug\fR, and \fBstderr\fR\. (Recall that a jq program\'s output values are always output as JSON texts on \fBstdout\fR\.) The \fBdebug\fR builtin can have application\-specific behavior, such as for executables that use the libjq C API but aren\'t the jq executable itself\. The \fBstderr\fR builtin outputs its input in raw mode to stder with no additional decoration, not even a newline\.
|
|
@@ -3047,14 +3689,83 @@ Most jq builtins are referentially transparent, and yield constant and repeatabl
|
|
|
3047
3689
|
.SS "input"
|
|
3048
3690
|
Outputs one new input\.
|
|
3049
3691
|
.
|
|
3692
|
+
.P
|
|
3693
|
+
Note that when using \fBinput\fR it is generally be necessary to invoke jq with the \fB\-n\fR command\-line option, otherwise the first entity will be lost\.
|
|
3694
|
+
.
|
|
3695
|
+
.IP "" 4
|
|
3696
|
+
.
|
|
3697
|
+
.nf
|
|
3698
|
+
|
|
3699
|
+
echo 1 2 3 4 | jq \'[\., input]\' # [1,2] [3,4]
|
|
3700
|
+
.
|
|
3701
|
+
.fi
|
|
3702
|
+
.
|
|
3703
|
+
.IP "" 0
|
|
3704
|
+
.
|
|
3050
3705
|
.SS "inputs"
|
|
3051
3706
|
Outputs all remaining inputs, one by one\.
|
|
3052
3707
|
.
|
|
3053
3708
|
.P
|
|
3054
|
-
This is primarily useful for reductions over a program\'s inputs\.
|
|
3709
|
+
This is primarily useful for reductions over a program\'s inputs\. Note that when using \fBinputs\fR it is generally necessary to invoke jq with the \fB\-n\fR command\-line option, otherwise the first entity will be lost\.
|
|
3710
|
+
.
|
|
3711
|
+
.IP "" 4
|
|
3712
|
+
.
|
|
3713
|
+
.nf
|
|
3714
|
+
|
|
3715
|
+
echo 1 2 3 | jq \-n \'reduce inputs as $i (0; \. + $i)\' # 6
|
|
3055
3716
|
.
|
|
3056
|
-
.
|
|
3057
|
-
|
|
3717
|
+
.fi
|
|
3718
|
+
.
|
|
3719
|
+
.IP "" 0
|
|
3720
|
+
.
|
|
3721
|
+
.SS "debug, debug(msgs)"
|
|
3722
|
+
These two filters are like \fB\.\fR but have as a side\-effect the production of one or more messages on stderr\.
|
|
3723
|
+
.
|
|
3724
|
+
.P
|
|
3725
|
+
The message produced by the \fBdebug\fR filter has the form
|
|
3726
|
+
.
|
|
3727
|
+
.IP "" 4
|
|
3728
|
+
.
|
|
3729
|
+
.nf
|
|
3730
|
+
|
|
3731
|
+
["DEBUG:",<input\-value>]
|
|
3732
|
+
.
|
|
3733
|
+
.fi
|
|
3734
|
+
.
|
|
3735
|
+
.IP "" 0
|
|
3736
|
+
.
|
|
3737
|
+
.P
|
|
3738
|
+
where \fB<input\-value>\fR is a compact rendition of the input value\. This format may change in the future\.
|
|
3739
|
+
.
|
|
3740
|
+
.P
|
|
3741
|
+
The \fBdebug(msgs)\fR filter is defined as \fB(msgs | debug | empty), \.\fR thus allowing great flexibility in the content of the message, while also allowing multi\-line debugging statements to be created\.
|
|
3742
|
+
.
|
|
3743
|
+
.P
|
|
3744
|
+
For example, the expression:
|
|
3745
|
+
.
|
|
3746
|
+
.IP "" 4
|
|
3747
|
+
.
|
|
3748
|
+
.nf
|
|
3749
|
+
|
|
3750
|
+
1 as $x | 2 | debug("Entering function foo with $x == \e($x)", \.) | (\.+1)
|
|
3751
|
+
.
|
|
3752
|
+
.fi
|
|
3753
|
+
.
|
|
3754
|
+
.IP "" 0
|
|
3755
|
+
.
|
|
3756
|
+
.P
|
|
3757
|
+
would produce the value 3 but with the following two lines being written to stderr:
|
|
3758
|
+
.
|
|
3759
|
+
.IP "" 4
|
|
3760
|
+
.
|
|
3761
|
+
.nf
|
|
3762
|
+
|
|
3763
|
+
["DEBUG:","Entering function foo with $x == 1"]
|
|
3764
|
+
["DEBUG:",2]
|
|
3765
|
+
.
|
|
3766
|
+
.fi
|
|
3767
|
+
.
|
|
3768
|
+
.IP "" 0
|
|
3058
3769
|
.
|
|
3059
3770
|
.SS "stderr"
|
|
3060
3771
|
Prints its input in raw and compact mode to stderr with no additional decoration, not even a newline\.
|
|
@@ -3078,7 +3789,7 @@ Several builtins are provided to make handling streams easier\.
|
|
|
3078
3789
|
The examples below use the streamed form of \fB[0,[1]]\fR, which is \fB[[0],0],[[1,0],1],[[1,0]],[[1]]\fR\.
|
|
3079
3790
|
.
|
|
3080
3791
|
.P
|
|
3081
|
-
Streaming forms include \fB[<path>, <leaf\-value>]\fR (to indicate any scalar value, empty array, or empty object), and \fB[<path>]\fR (to indicate the end of an array or object)\. Future versions of jq run with \fB\-\-stream\fR and \fB
|
|
3792
|
+
Streaming forms include \fB[<path>, <leaf\-value>]\fR (to indicate any scalar value, empty array, or empty object), and \fB[<path>]\fR (to indicate the end of an array or object)\. Future versions of jq run with \fB\-\-stream\fR and \fB\-\-seq\fR may output additional forms such as \fB["error message"]\fR when an input text fails to parse\.
|
|
3082
3793
|
.
|
|
3083
3794
|
.SS "truncate_stream(stream_expression)"
|
|
3084
3795
|
Consumes a number as input and truncates the corresponding number of path elements from the left of the outputs of the given streaming expression\.
|
|
@@ -3087,9 +3798,9 @@ Consumes a number as input and truncates the corresponding number of path elemen
|
|
|
3087
3798
|
.
|
|
3088
3799
|
.nf
|
|
3089
3800
|
|
|
3090
|
-
jq \'
|
|
3801
|
+
jq \'truncate_stream([[0],1],[[1,0],2],[[1,0]],[[1]])\'
|
|
3091
3802
|
1
|
|
3092
|
-
=> [[
|
|
3803
|
+
=> [[0],2], [[0]]
|
|
3093
3804
|
.
|
|
3094
3805
|
.fi
|
|
3095
3806
|
.
|
|
@@ -3129,13 +3840,13 @@ jq \'\. as $dot|fromstream($dot|tostream)|\.==$dot\'
|
|
|
3129
3840
|
Assignment works a little differently in jq than in most programming languages\. jq doesn\'t distinguish between references to and copies of something \- two objects or arrays are either equal or not equal, without any further notion of being "the same object" or "not the same object"\.
|
|
3130
3841
|
.
|
|
3131
3842
|
.P
|
|
3132
|
-
If an object has two fields which are arrays, \fB\.foo\fR and \fB\.bar\fR, and you append something to \fB\.foo\fR, then \fB\.bar\fR will not get bigger, even if you\'ve previously set \fB\.bar = \.foo\fR\. If you\'re used to programming in languages like Python, Java, Ruby,
|
|
3843
|
+
If an object has two fields which are arrays, \fB\.foo\fR and \fB\.bar\fR, and you append something to \fB\.foo\fR, then \fB\.bar\fR will not get bigger, even if you\'ve previously set \fB\.bar = \.foo\fR\. If you\'re used to programming in languages like Python, Java, Ruby, JavaScript, etc\. then you can think of it as though jq does a full deep copy of every object before it does the assignment (for performance it doesn\'t actually do that, but that\'s the general idea)\.
|
|
3133
3844
|
.
|
|
3134
3845
|
.P
|
|
3135
3846
|
This means that it\'s impossible to build circular values in jq (such as an array whose first element is itself)\. This is quite intentional, and ensures that anything a jq program can produce can be represented in JSON\.
|
|
3136
3847
|
.
|
|
3137
3848
|
.P
|
|
3138
|
-
All the assignment operators in jq have path expressions on the left\-hand side (LHS)\. The right\-hand side (RHS)
|
|
3849
|
+
All the assignment operators in jq have path expressions on the left\-hand side (LHS)\. The right\-hand side (RHS) provides values to set to the paths named by the LHS path expressions\.
|
|
3139
3850
|
.
|
|
3140
3851
|
.P
|
|
3141
3852
|
Values in jq are always immutable\. Internally, assignment works by using a reduction to compute new, replacement values for \fB\.\fR that have had all the desired assignments applied to \fB\.\fR, then outputting the modified value\. This might be made clear by this example: \fB{a:{b:{c:1}}} | (\.a\.b|=3), \.\fR\. This will output \fB{"a":{"b":3}}\fR and \fB{"a":{"b":{"c":1}}}\fR because the last sub\-expression, \fB\.\fR, sees the original value, not the modified value\.
|
|
@@ -3150,13 +3861,13 @@ Note that the LHS of assignment operators refers to a value in \fB\.\fR\. Thus \
|
|
|
3150
3861
|
Note too that \fB\.a,\.b=0\fR does not set \fB\.a\fR and \fB\.b\fR, but \fB(\.a,\.b)=0\fR sets both\.
|
|
3151
3862
|
.
|
|
3152
3863
|
.SS "Update\-assignment: |="
|
|
3153
|
-
This is the "update" operator \
|
|
3864
|
+
This is the "update" operator \fB|=\fR\. It takes a filter on the right\-hand side and works out the new value for the property of \fB\.\fR being assigned to by running the old value through this expression\. For instance, \fB(\.foo, \.bar) |= \.+1\fR will build an object with the \fBfoo\fR field set to the input\'s \fBfoo\fR plus 1, and the \fBbar\fR field set to the input\'s \fBbar\fR plus 1\.
|
|
3154
3865
|
.
|
|
3155
3866
|
.P
|
|
3156
3867
|
The left\-hand side can be any general path expression; see \fBpath()\fR\.
|
|
3157
3868
|
.
|
|
3158
3869
|
.P
|
|
3159
|
-
Note that the left\-hand side of \
|
|
3870
|
+
Note that the left\-hand side of \fB|=\fR refers to a value in \fB\.\fR\. Thus \fB$var\.foo |= \. + 1\fR won\'t work as expected (\fB$var\.foo\fR is not a valid or useful path expression in \fB\.\fR); use \fB$var | \.foo |= \. + 1\fR instead\.
|
|
3160
3871
|
.
|
|
3161
3872
|
.P
|
|
3162
3873
|
If the right\-hand side outputs no values (i\.e\., \fBempty\fR), then the left\-hand side path will be deleted, as with \fBdel(path)\fR\.
|
|
@@ -3192,40 +3903,66 @@ jq \'\.foo += 1\'
|
|
|
3192
3903
|
.IP "" 0
|
|
3193
3904
|
.
|
|
3194
3905
|
.SS "Plain assignment: ="
|
|
3195
|
-
This is the plain assignment operator\. Unlike the others, the input to the right\-hand
|
|
3906
|
+
This is the plain assignment operator\. Unlike the others, the input to the right\-hand side (RHS) is the same as the input to the left\-hand side (LHS) rather than the value at the LHS path, and all values output by the RHS will be used (as shown below)\.
|
|
3196
3907
|
.
|
|
3197
3908
|
.P
|
|
3198
|
-
If the RHS of \
|
|
3909
|
+
If the RHS of \fB=\fR produces multiple values, then for each such value jq will set the paths on the left\-hand side to the value and then it will output the modified \fB\.\fR\. For example, \fB(\.a,\.b) = range(2)\fR outputs \fB{"a":0,"b":0}\fR, then \fB{"a":1,"b":1}\fR\. The "update" assignment forms (see above) do not do this\.
|
|
3199
3910
|
.
|
|
3200
3911
|
.P
|
|
3201
|
-
This example should show the difference between \
|
|
3912
|
+
This example should show the difference between \fB=\fR and \fB|=\fR:
|
|
3202
3913
|
.
|
|
3203
3914
|
.P
|
|
3204
|
-
Provide input \
|
|
3915
|
+
Provide input \fB{"a": {"b": 10}, "b": 20}\fR to the programs
|
|
3205
3916
|
.
|
|
3206
|
-
.
|
|
3207
|
-
\&\.a = \.b
|
|
3917
|
+
.IP "" 4
|
|
3208
3918
|
.
|
|
3209
|
-
.
|
|
3210
|
-
|
|
3919
|
+
.nf
|
|
3920
|
+
|
|
3921
|
+
\&.a = \.b
|
|
3211
3922
|
.
|
|
3212
|
-
.
|
|
3213
|
-
The former will set the "a" field of the input to the "b" field of the input, and produce the output {"a": 20, "b": 20}\. The latter will set the "a" field of the input to the "a" field\'s "b" field, producing {"a": 10, "b": 20}\.
|
|
3923
|
+
.fi
|
|
3214
3924
|
.
|
|
3215
|
-
.
|
|
3216
|
-
Another example of the difference between \'=\' and \'|=\':
|
|
3925
|
+
.IP "" 0
|
|
3217
3926
|
.
|
|
3218
3927
|
.P
|
|
3219
|
-
|
|
3928
|
+
and
|
|
3220
3929
|
.
|
|
3221
|
-
.
|
|
3222
|
-
outputs \'{"a":0,"b":0}\', \'{"a":1,"b":1}\', and \'{"a":2,"b":2}\', while
|
|
3930
|
+
.IP "" 4
|
|
3223
3931
|
.
|
|
3224
|
-
.
|
|
3225
|
-
|
|
3932
|
+
.nf
|
|
3933
|
+
|
|
3934
|
+
\&.a |= \.b
|
|
3935
|
+
.
|
|
3936
|
+
.fi
|
|
3937
|
+
.
|
|
3938
|
+
.IP "" 0
|
|
3226
3939
|
.
|
|
3227
3940
|
.P
|
|
3228
|
-
|
|
3941
|
+
The former will set the \fBa\fR field of the input to the \fBb\fR field of the input, and produce the output \fB{"a": 20, "b": 20}\fR\. The latter will set the \fBa\fR field of the input to the \fBa\fR field\'s \fBb\fR field, producing \fB{"a": 10, "b": 20}\fR\.
|
|
3942
|
+
.
|
|
3943
|
+
.IP "" 4
|
|
3944
|
+
.
|
|
3945
|
+
.nf
|
|
3946
|
+
|
|
3947
|
+
jq \'\.a = \.b\'
|
|
3948
|
+
{"a": {"b": 10}, "b": 20}
|
|
3949
|
+
=> {"a":20,"b":20}
|
|
3950
|
+
|
|
3951
|
+
jq \'\.a |= \.b\'
|
|
3952
|
+
{"a": {"b": 10}, "b": 20}
|
|
3953
|
+
=> {"a":10,"b":20}
|
|
3954
|
+
|
|
3955
|
+
jq \'(\.a, \.b) = range(3)\'
|
|
3956
|
+
null
|
|
3957
|
+
=> {"a":0,"b":0}, {"a":1,"b":1}, {"a":2,"b":2}
|
|
3958
|
+
|
|
3959
|
+
jq \'(\.a, \.b) |= range(3)\'
|
|
3960
|
+
null
|
|
3961
|
+
=> {"a":0,"b":0}
|
|
3962
|
+
.
|
|
3963
|
+
.fi
|
|
3964
|
+
.
|
|
3965
|
+
.IP "" 0
|
|
3229
3966
|
.
|
|
3230
3967
|
.SS "Complex assignments"
|
|
3231
3968
|
Lots more things are allowed on the left\-hand side of a jq assignment than in most languages\. We\'ve already seen simple field accesses on the left hand side, and it\'s no surprise that array accesses work just as well:
|
|
@@ -3234,7 +3971,7 @@ Lots more things are allowed on the left\-hand side of a jq assignment than in m
|
|
|
3234
3971
|
.
|
|
3235
3972
|
.nf
|
|
3236
3973
|
|
|
3237
|
-
|
|
3974
|
+
\&.posts[0]\.title = "JQ Manual"
|
|
3238
3975
|
.
|
|
3239
3976
|
.fi
|
|
3240
3977
|
.
|
|
@@ -3247,7 +3984,7 @@ What may come as a surprise is that the expression on the left may produce multi
|
|
|
3247
3984
|
.
|
|
3248
3985
|
.nf
|
|
3249
3986
|
|
|
3250
|
-
|
|
3987
|
+
\&.posts[]\.comments |= \. + ["this is great"]
|
|
3251
3988
|
.
|
|
3252
3989
|
.fi
|
|
3253
3990
|
.
|
|
@@ -3266,7 +4003,7 @@ This is a very powerful operation\. Suppose we wanted to add a comment to blog p
|
|
|
3266
4003
|
.
|
|
3267
4004
|
.nf
|
|
3268
4005
|
|
|
3269
|
-
|
|
4006
|
+
\&.posts[] | select(\.author == "stedolan")
|
|
3270
4007
|
.
|
|
3271
4008
|
.fi
|
|
3272
4009
|
.
|
|
@@ -3286,6 +4023,74 @@ The paths provided by this operation point to each of the posts that "stedolan"
|
|
|
3286
4023
|
.
|
|
3287
4024
|
.IP "" 0
|
|
3288
4025
|
.
|
|
4026
|
+
.SH "COMMENTS"
|
|
4027
|
+
You can write comments in your jq filters using \fB#\fR\.
|
|
4028
|
+
.
|
|
4029
|
+
.P
|
|
4030
|
+
A \fB#\fR character (not part of a string) starts a comment\. All characters from \fB#\fR to the end of the line are ignored\.
|
|
4031
|
+
.
|
|
4032
|
+
.P
|
|
4033
|
+
If the end of the line is preceded by an odd number of backslash characters, the following line is also considered part of the comment and is ignored\.
|
|
4034
|
+
.
|
|
4035
|
+
.P
|
|
4036
|
+
For example, the following code outputs \fB[1,3,4,7]\fR
|
|
4037
|
+
.
|
|
4038
|
+
.IP "" 4
|
|
4039
|
+
.
|
|
4040
|
+
.nf
|
|
4041
|
+
|
|
4042
|
+
[
|
|
4043
|
+
1,
|
|
4044
|
+
# foo \e
|
|
4045
|
+
2,
|
|
4046
|
+
# bar \e\e
|
|
4047
|
+
3,
|
|
4048
|
+
4, # baz \e\e\e
|
|
4049
|
+
5, \e
|
|
4050
|
+
6,
|
|
4051
|
+
7
|
|
4052
|
+
# comment \e
|
|
4053
|
+
comment \e
|
|
4054
|
+
comment
|
|
4055
|
+
]
|
|
4056
|
+
.
|
|
4057
|
+
.fi
|
|
4058
|
+
.
|
|
4059
|
+
.IP "" 0
|
|
4060
|
+
.
|
|
4061
|
+
.P
|
|
4062
|
+
Backslash continuing the comment on the next line can be useful when writing the "shebang" for a jq script:
|
|
4063
|
+
.
|
|
4064
|
+
.IP "" 4
|
|
4065
|
+
.
|
|
4066
|
+
.nf
|
|
4067
|
+
|
|
4068
|
+
#!/bin/sh \-\-
|
|
4069
|
+
# total \- Output the sum of the given arguments (or stdin)
|
|
4070
|
+
# usage: total [numbers\.\.\.]
|
|
4071
|
+
# \e
|
|
4072
|
+
exec jq \-\-args \-MRnf \-\- "$0" "$@"
|
|
4073
|
+
|
|
4074
|
+
$ARGS\.positional |
|
|
4075
|
+
reduce (
|
|
4076
|
+
if \. == []
|
|
4077
|
+
then inputs
|
|
4078
|
+
else \.[]
|
|
4079
|
+
end |
|
|
4080
|
+
\. as $dot |
|
|
4081
|
+
try tonumber catch false |
|
|
4082
|
+
if not or isnan then
|
|
4083
|
+
@json "total: Invalid number \e($dot)\.\en" | halt_error(1)
|
|
4084
|
+
end
|
|
4085
|
+
) as $n (0; \. + $n)
|
|
4086
|
+
.
|
|
4087
|
+
.fi
|
|
4088
|
+
.
|
|
4089
|
+
.IP "" 0
|
|
4090
|
+
.
|
|
4091
|
+
.P
|
|
4092
|
+
The \fBexec\fR line is considered a comment by jq, so it is ignored\. But it is not ignored by \fBsh\fR, since in \fBsh\fR a backslash at the end of the line does not continue the comment\. With this trick, when the script is invoked as \fBtotal 1 2\fR, \fB/bin/sh \-\- /path/to/total 1 2\fR will be run, and \fBsh\fR will then run \fBexec jq \-\-args \-MRnf \-\- /path/to/total 1 2\fR replacing itself with a \fBjq\fR interpreter invoked with the specified options (\fB\-M\fR, \fB\-R\fR, \fB\-n\fR, \fB\-\-args\fR), that evaluates the current file (\fB$0\fR), with the arguments (\fB$@\fR) that were passed to \fBsh\fR\.
|
|
4093
|
+
.
|
|
3289
4094
|
.SH "MODULES"
|
|
3290
4095
|
jq has a library/module system\. Modules are files whose names end in \fB\.jq\fR\.
|
|
3291
4096
|
.
|
|
@@ -3293,16 +4098,16 @@ jq has a library/module system\. Modules are files whose names end in \fB\.jq\fR
|
|
|
3293
4098
|
Modules imported by a program are searched for in a default search path (see below)\. The \fBimport\fR and \fBinclude\fR directives allow the importer to alter this path\.
|
|
3294
4099
|
.
|
|
3295
4100
|
.P
|
|
3296
|
-
Paths in the
|
|
4101
|
+
Paths in the search path are subject to various substitutions\.
|
|
3297
4102
|
.
|
|
3298
4103
|
.P
|
|
3299
|
-
For paths starting with
|
|
4104
|
+
For paths starting with \fB~/\fR, the user\'s home directory is substituted for \fB~\fR\.
|
|
3300
4105
|
.
|
|
3301
4106
|
.P
|
|
3302
|
-
For paths starting with
|
|
4107
|
+
For paths starting with \fB$ORIGIN/\fR, the directory where the jq executable is located is substituted for \fB$ORIGIN\fR\.
|
|
3303
4108
|
.
|
|
3304
4109
|
.P
|
|
3305
|
-
For paths starting with
|
|
4110
|
+
For paths starting with \fB\./\fR or paths that are \fB\.\fR, the path of the including file is substituted for \fB\.\fR\. For top\-level programs given on the command\-line, the current directory is used\.
|
|
3306
4111
|
.
|
|
3307
4112
|
.P
|
|
3308
4113
|
Import directives can optionally specify a search path to which the default is appended\.
|
|
@@ -3314,49 +4119,49 @@ The default search path is the search path given to the \fB\-L\fR command\-line
|
|
|
3314
4119
|
Null and empty string path elements terminate search path processing\.
|
|
3315
4120
|
.
|
|
3316
4121
|
.P
|
|
3317
|
-
A dependency with relative path
|
|
4122
|
+
A dependency with relative path \fBfoo/bar\fR would be searched for in \fBfoo/bar\.jq\fR and \fBfoo/bar/bar\.jq\fR in the given search path\. This is intended to allow modules to be placed in a directory along with, for example, version control files, README files, and so on, but also to allow for single\-file modules\.
|
|
3318
4123
|
.
|
|
3319
4124
|
.P
|
|
3320
|
-
Consecutive components with the same name are not allowed to avoid ambiguities (e\.g\.,
|
|
4125
|
+
Consecutive components with the same name are not allowed to avoid ambiguities (e\.g\., \fBfoo/foo\fR)\.
|
|
3321
4126
|
.
|
|
3322
4127
|
.P
|
|
3323
4128
|
For example, with \fB\-L$HOME/\.jq\fR a module \fBfoo\fR can be found in \fB$HOME/\.jq/foo\.jq\fR and \fB$HOME/\.jq/foo/foo\.jq\fR\.
|
|
3324
4129
|
.
|
|
3325
4130
|
.P
|
|
3326
|
-
If
|
|
4131
|
+
If \fB\.jq\fR exists in the user\'s home directory, and is a file (not a directory), it is automatically sourced into the main program\.
|
|
3327
4132
|
.
|
|
3328
4133
|
.SS "import RelativePathString as NAME [<metadata>];"
|
|
3329
|
-
Imports a module found at the given path relative to a directory in a search path\. A
|
|
4134
|
+
Imports a module found at the given path relative to a directory in a search path\. A \fB\.jq\fR suffix will be added to the relative path string\. The module\'s symbols are prefixed with \fBNAME::\fR\.
|
|
3330
4135
|
.
|
|
3331
4136
|
.P
|
|
3332
|
-
The optional metadata must be a constant jq expression\. It should be an object with keys like
|
|
4137
|
+
The optional metadata must be a constant jq expression\. It should be an object with keys like \fBhomepage\fR and so on\. At this time jq only uses the \fBsearch\fR key/value of the metadata\. The metadata is also made available to users via the \fBmodulemeta\fR builtin\.
|
|
3333
4138
|
.
|
|
3334
4139
|
.P
|
|
3335
|
-
The
|
|
4140
|
+
The \fBsearch\fR key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top\-level search path\.
|
|
3336
4141
|
.
|
|
3337
4142
|
.SS "include RelativePathString [<metadata>];"
|
|
3338
|
-
Imports a module found at the given path relative to a directory in a search path as if it were included in place\. A
|
|
4143
|
+
Imports a module found at the given path relative to a directory in a search path as if it were included in place\. A \fB\.jq\fR suffix will be added to the relative path string\. The module\'s symbols are imported into the caller\'s namespace as if the module\'s content had been included directly\.
|
|
3339
4144
|
.
|
|
3340
4145
|
.P
|
|
3341
|
-
The optional metadata must be a constant jq expression\. It should be an object with keys like
|
|
4146
|
+
The optional metadata must be a constant jq expression\. It should be an object with keys like \fBhomepage\fR and so on\. At this time jq only uses the \fBsearch\fR key/value of the metadata\. The metadata is also made available to users via the \fBmodulemeta\fR builtin\.
|
|
3342
4147
|
.
|
|
3343
4148
|
.SS "import RelativePathString as $NAME [<metadata>];"
|
|
3344
|
-
Imports a JSON file found at the given path relative to a directory in a search path\. A
|
|
4149
|
+
Imports a JSON file found at the given path relative to a directory in a search path\. A \fB\.json\fR suffix will be added to the relative path string\. The file\'s data will be available as \fB$NAME::NAME\fR\.
|
|
3345
4150
|
.
|
|
3346
4151
|
.P
|
|
3347
|
-
The optional metadata must be a constant jq expression\. It should be an object with keys like
|
|
4152
|
+
The optional metadata must be a constant jq expression\. It should be an object with keys like \fBhomepage\fR and so on\. At this time jq only uses the \fBsearch\fR key/value of the metadata\. The metadata is also made available to users via the \fBmodulemeta\fR builtin\.
|
|
3348
4153
|
.
|
|
3349
4154
|
.P
|
|
3350
|
-
The
|
|
4155
|
+
The \fBsearch\fR key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top\-level search path\.
|
|
3351
4156
|
.
|
|
3352
4157
|
.SS "module <metadata>;"
|
|
3353
4158
|
This directive is entirely optional\. It\'s not required for proper operation\. It serves only the purpose of providing metadata that can be read with the \fBmodulemeta\fR builtin\.
|
|
3354
4159
|
.
|
|
3355
4160
|
.P
|
|
3356
|
-
The metadata must be a constant jq expression\. It should be an object with keys like
|
|
4161
|
+
The metadata must be a constant jq expression\. It should be an object with keys like \fBhomepage\fR\. At this time jq doesn\'t use this metadata, but it is made available to users via the \fBmodulemeta\fR builtin\.
|
|
3357
4162
|
.
|
|
3358
4163
|
.SS "modulemeta"
|
|
3359
|
-
Takes a module name as input and outputs the module\'s metadata as an object, with the module\'s imports (including metadata) as an array value for the
|
|
4164
|
+
Takes a module name as input and outputs the module\'s metadata as an object, with the module\'s imports (including metadata) as an array value for the \fBdeps\fR key and the module\'s defined functions as an array value for the \fBdefs\fR key\.
|
|
3360
4165
|
.
|
|
3361
4166
|
.P
|
|
3362
4167
|
Programs can use this to query a module\'s metadata, which they could then use to, for example, search for, download, and install missing dependencies\.
|
|
@@ -3385,10 +4190,13 @@ color for arrays
|
|
|
3385
4190
|
.IP "\(bu" 4
|
|
3386
4191
|
color for objects
|
|
3387
4192
|
.
|
|
4193
|
+
.IP "\(bu" 4
|
|
4194
|
+
color for object keys
|
|
4195
|
+
.
|
|
3388
4196
|
.IP "" 0
|
|
3389
4197
|
.
|
|
3390
4198
|
.P
|
|
3391
|
-
The default color scheme is the same as setting \
|
|
4199
|
+
The default color scheme is the same as setting \fBJQ_COLORS="0;90:0;39:0;39:0;39:0;32:1;39:1;39:1;34"\fR\.
|
|
3392
4200
|
.
|
|
3393
4201
|
.P
|
|
3394
4202
|
This is not a manual for VT100/ANSI escapes\. However, each of these color specifications should consist of two numbers separated by a semi\-colon, where the first number is one of these:
|
|
@@ -3449,7 +4257,7 @@ Presumably\. Report them or discuss them at:
|
|
|
3449
4257
|
.
|
|
3450
4258
|
.nf
|
|
3451
4259
|
|
|
3452
|
-
https://github\.com/
|
|
4260
|
+
https://github\.com/jqlang/jq/issues
|
|
3453
4261
|
.
|
|
3454
4262
|
.fi
|
|
3455
4263
|
.
|