@port-labs/jq-node-bindings 0.0.13 → 0.0.15-dev1
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 +41 -19
- 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/lib/index.js +3 -0
- package/lib/jq.js +15 -1
- package/lib/templateAsync.js +137 -0
- package/package.json +7 -7
- 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
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
headline: jq Manual (development version)
|
|
3
3
|
|
|
4
|
-
history: |
|
|
5
|
-
|
|
6
|
-
*For released versions, see [jq 1.5](/jq/manual/v1.5),
|
|
7
|
-
[jq 1.4](/jq/manual/v1.4) or [jq 1.3](/jq/manual/v1.3).*
|
|
8
|
-
|
|
9
4
|
body: |
|
|
10
5
|
|
|
11
6
|
A jq program is a "filter": it takes an input, and produces an
|
|
@@ -65,7 +60,7 @@ manpage_epilogue: |
|
|
|
65
60
|
|
|
66
61
|
Presumably. Report them or discuss them at:
|
|
67
62
|
|
|
68
|
-
https://github.com/
|
|
63
|
+
https://github.com/jqlang/jq/issues
|
|
69
64
|
|
|
70
65
|
## AUTHOR
|
|
71
66
|
|
|
@@ -78,67 +73,61 @@ sections:
|
|
|
78
73
|
jq filters run on a stream of JSON data. The input to jq is
|
|
79
74
|
parsed as a sequence of whitespace-separated JSON values which
|
|
80
75
|
are passed through the provided filter one at a time. The
|
|
81
|
-
output(s) of the filter are written to standard
|
|
82
|
-
sequence of
|
|
76
|
+
output(s) of the filter are written to standard output, as a
|
|
77
|
+
sequence of newline-separated JSON data.
|
|
78
|
+
|
|
79
|
+
The simplest and most common filter (or jq program) is `.`,
|
|
80
|
+
which is the identity operator, copying the inputs of the jq
|
|
81
|
+
processor to the output stream. Because the default behavior of
|
|
82
|
+
the jq processor is to read JSON texts from the input stream,
|
|
83
|
+
and to pretty-print outputs, the `.` program's main use is to
|
|
84
|
+
validate and pretty-print the inputs. The jq programming
|
|
85
|
+
language is quite rich and allows for much more than just
|
|
86
|
+
validation and pretty-printing.
|
|
83
87
|
|
|
84
88
|
Note: it is important to mind the shell's quoting rules. As a
|
|
85
89
|
general rule it's best to always quote (with single-quote
|
|
86
|
-
characters) the jq program, as too many characters with special
|
|
90
|
+
characters on Unix shells) the jq program, as too many characters with special
|
|
87
91
|
meaning to jq are also shell meta-characters. For example, `jq
|
|
88
92
|
"foo"` will fail on most Unix shells because that will be the same
|
|
89
93
|
as `jq foo`, which will generally fail because `foo is not
|
|
90
94
|
defined`. When using the Windows command shell (cmd.exe) it's
|
|
91
95
|
best to use double quotes around your jq program when given on the
|
|
92
96
|
command-line (instead of the `-f program-file` option), but then
|
|
93
|
-
double-quotes in the jq program need backslash escaping.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
* `--version`:
|
|
99
|
-
|
|
100
|
-
Output the jq version and exit with zero.
|
|
101
|
-
|
|
102
|
-
* `--seq`:
|
|
103
|
-
|
|
104
|
-
Use the `application/json-seq` MIME type scheme for separating
|
|
105
|
-
JSON texts in jq's input and output. This means that an ASCII
|
|
106
|
-
RS (record separator) character is printed before each value on
|
|
107
|
-
output and an ASCII LF (line feed) is printed after every
|
|
108
|
-
output. Input JSON texts that fail to parse are ignored (but
|
|
109
|
-
warned about), discarding all subsequent input until the next
|
|
110
|
-
RS. This mode also parses the output of jq without the `--seq`
|
|
111
|
-
option.
|
|
97
|
+
double-quotes in the jq program need backslash escaping. When using
|
|
98
|
+
the Powershell (`powershell.exe`) or the Powershell Core
|
|
99
|
+
(`pwsh`/`pwsh.exe`), use single-quote characters around the jq
|
|
100
|
+
program and backslash-escaped double-quotes (`\"`) inside the jq
|
|
101
|
+
program.
|
|
112
102
|
|
|
113
|
-
*
|
|
103
|
+
* Unix shells: `jq '.["foo"]'`
|
|
104
|
+
* Powershell: `jq '.[\"foo\"]'`
|
|
105
|
+
* Windows command shell: `jq ".[\"foo\"]"`
|
|
114
106
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
For example, `"a"` becomes `[[],"a"]`, and `[[],"a",["b"]]`
|
|
118
|
-
becomes `[[0],[]]`, `[[1],"a"]`, and `[[1,0],"b"]`.
|
|
107
|
+
Note: jq allows user-defined functions, but every jq program
|
|
108
|
+
must have a top-level expression.
|
|
119
109
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
to reduce large inputs incrementally.
|
|
110
|
+
You can affect how jq reads and writes its input and output
|
|
111
|
+
using some command-line options:
|
|
123
112
|
|
|
124
|
-
* `--
|
|
113
|
+
* `--null-input` / `-n`:
|
|
125
114
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
115
|
+
Don't read any input at all. Instead, the filter is run once
|
|
116
|
+
using `null` as the input. This is useful when using jq as a
|
|
117
|
+
simple calculator or to construct JSON data from scratch.
|
|
129
118
|
|
|
130
|
-
* `--raw-input
|
|
119
|
+
* `--raw-input` / `-R`:
|
|
131
120
|
|
|
132
121
|
Don't parse the input as JSON. Instead, each line of text is
|
|
133
122
|
passed to the filter as a string. If combined with `--slurp`,
|
|
134
123
|
then the entire input is passed to the filter as a single long
|
|
135
124
|
string.
|
|
136
125
|
|
|
137
|
-
* `--
|
|
126
|
+
* `--slurp` / `-s`:
|
|
138
127
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
128
|
+
Instead of running the filter for each JSON object in the
|
|
129
|
+
input, read the entire input stream into a large array and run
|
|
130
|
+
the filter just once.
|
|
142
131
|
|
|
143
132
|
* `--compact-output` / `-c`:
|
|
144
133
|
|
|
@@ -146,75 +135,104 @@ sections:
|
|
|
146
135
|
will result in more compact output by instead putting each
|
|
147
136
|
JSON object on a single line.
|
|
148
137
|
|
|
149
|
-
* `--
|
|
138
|
+
* `--raw-output` / `-r`:
|
|
150
139
|
|
|
151
|
-
|
|
140
|
+
With this option, if the filter's result is a string then it
|
|
141
|
+
will be written directly to standard output rather than being
|
|
142
|
+
formatted as a JSON string with quotes. This can be useful for
|
|
143
|
+
making jq filters talk to non-JSON-based systems.
|
|
152
144
|
|
|
153
|
-
* `--
|
|
145
|
+
* `--raw-output0`:
|
|
146
|
+
|
|
147
|
+
Like `-r` but jq will print NUL instead of newline after each output.
|
|
148
|
+
This can be useful when the values being output can contain newlines.
|
|
149
|
+
When the output value contains NUL, jq exits with non-zero code.
|
|
150
|
+
|
|
151
|
+
* `--join-output` / `-j`:
|
|
152
|
+
|
|
153
|
+
Like `-r` but jq won't print a newline after each output.
|
|
154
|
+
|
|
155
|
+
* `--ascii-output` / `-a`:
|
|
156
|
+
|
|
157
|
+
jq usually outputs non-ASCII Unicode codepoints as UTF-8, even
|
|
158
|
+
if the input specified them as escape sequences (like
|
|
159
|
+
"\u03bc"). Using this option, you can force jq to produce pure
|
|
160
|
+
ASCII output with every non-ASCII character replaced with the
|
|
161
|
+
equivalent escape sequence.
|
|
154
162
|
|
|
155
|
-
|
|
163
|
+
* `--sort-keys` / `-S`:
|
|
164
|
+
|
|
165
|
+
Output the fields of each object with the keys in sorted order.
|
|
156
166
|
|
|
157
167
|
* `--color-output` / `-C` and `--monochrome-output` / `-M`:
|
|
158
168
|
|
|
159
169
|
By default, jq outputs colored JSON if writing to a
|
|
160
170
|
terminal. You can force it to produce color even if writing to
|
|
161
171
|
a pipe or a file using `-C`, and disable color with `-M`.
|
|
172
|
+
When the `NO_COLOR` environment variable is not empty, jq disables
|
|
173
|
+
colored output by default, but you can enable it by `-C`.
|
|
162
174
|
|
|
163
175
|
Colors can be configured with the `JQ_COLORS` environment
|
|
164
176
|
variable (see below).
|
|
165
177
|
|
|
166
|
-
* `--
|
|
178
|
+
* `--tab`:
|
|
167
179
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
ASCII output with every non-ASCII character replaced with the
|
|
172
|
-
equivalent escape sequence.
|
|
180
|
+
Use a tab for each indentation level instead of two spaces.
|
|
181
|
+
|
|
182
|
+
* `--indent n`:
|
|
173
183
|
|
|
174
|
-
|
|
184
|
+
Use the given number of spaces (no more than 7) for indentation.
|
|
185
|
+
|
|
186
|
+
* `--unbuffered`:
|
|
175
187
|
|
|
176
188
|
Flush the output after each JSON object is printed (useful if
|
|
177
189
|
you're piping a slow data source into jq and piping jq's
|
|
178
190
|
output elsewhere).
|
|
179
191
|
|
|
180
|
-
* `--
|
|
192
|
+
* `--stream`:
|
|
181
193
|
|
|
182
|
-
|
|
194
|
+
Parse the input in streaming fashion, outputting arrays of path
|
|
195
|
+
and leaf values (scalars and empty arrays or empty objects).
|
|
196
|
+
For example, `"a"` becomes `[[],"a"]`, and `[[],"a",["b"]]`
|
|
197
|
+
becomes `[[0],[]]`, `[[1],"a"]`, and `[[2,0],"b"]`.
|
|
183
198
|
|
|
184
|
-
|
|
199
|
+
This is useful for processing very large inputs. Use this in
|
|
200
|
+
conjunction with filtering and the `reduce` and `foreach` syntax
|
|
201
|
+
to reduce large inputs incrementally.
|
|
185
202
|
|
|
186
|
-
|
|
187
|
-
will be written directly to standard output rather than being
|
|
188
|
-
formatted as a JSON string with quotes. This can be useful for
|
|
189
|
-
making jq filters talk to non-JSON-based systems.
|
|
203
|
+
* `--stream-errors`:
|
|
190
204
|
|
|
191
|
-
|
|
205
|
+
Like `--stream`, but invalid JSON inputs yield array values
|
|
206
|
+
where the first element is the error and the second is a path.
|
|
207
|
+
For example, `["a",n]` produces `["Invalid literal at line 1,
|
|
208
|
+
column 7",[1]]`.
|
|
192
209
|
|
|
193
|
-
|
|
210
|
+
Implies `--stream`. Invalid JSON inputs produce no error values
|
|
211
|
+
when `--stream` without `--stream-errors`.
|
|
212
|
+
|
|
213
|
+
* `--seq`:
|
|
214
|
+
|
|
215
|
+
Use the `application/json-seq` MIME type scheme for separating
|
|
216
|
+
JSON texts in jq's input and output. This means that an ASCII
|
|
217
|
+
RS (record separator) character is printed before each value on
|
|
218
|
+
output and an ASCII LF (line feed) is printed after every
|
|
219
|
+
output. Input JSON texts that fail to parse are ignored (but
|
|
220
|
+
warned about), discarding all subsequent input until the next
|
|
221
|
+
RS. This mode also parses the output of jq without the `--seq`
|
|
222
|
+
option.
|
|
194
223
|
|
|
195
|
-
* `-f
|
|
224
|
+
* `-f` / `--from-file`:
|
|
196
225
|
|
|
197
|
-
Read filter from
|
|
198
|
-
awk's -f option.
|
|
226
|
+
Read the filter from a file rather than from a command line,
|
|
227
|
+
like awk's -f option. This changes the filter argument to be
|
|
228
|
+
interpreted as a filename, instead of the source of a program.
|
|
199
229
|
|
|
200
|
-
* `-
|
|
230
|
+
* `-L directory` / `--library-path directory`:
|
|
201
231
|
|
|
202
232
|
Prepend `directory` to the search list for modules. If this
|
|
203
233
|
option is used then no builtin search list is used. See the
|
|
204
234
|
section on modules below.
|
|
205
235
|
|
|
206
|
-
* `-e` / `--exit-status`:
|
|
207
|
-
|
|
208
|
-
Sets the exit status of jq to 0 if the last output values was
|
|
209
|
-
neither `false` nor `null`, 1 if the last output value was
|
|
210
|
-
either `false` or `null`, or 4 if no valid result was ever
|
|
211
|
-
produced. Normally jq exits with 2 if there was any usage
|
|
212
|
-
problem or system error, 3 if there was a jq program compile
|
|
213
|
-
error, or 0 if the jq program ran.
|
|
214
|
-
|
|
215
|
-
Another way to set the exit status is with the `halt_error`
|
|
216
|
-
builtin function.
|
|
217
|
-
|
|
218
236
|
* `--arg name value`:
|
|
219
237
|
|
|
220
238
|
This option passes a value to the jq program as a predefined
|
|
@@ -224,7 +242,8 @@ sections:
|
|
|
224
242
|
bind `$foo` to `"123"`.
|
|
225
243
|
|
|
226
244
|
Named arguments are also available to the jq program as
|
|
227
|
-
`$ARGS.named`.
|
|
245
|
+
`$ARGS.named`. When the name is not a valid identifier, this is
|
|
246
|
+
the only way to access it.
|
|
228
247
|
|
|
229
248
|
* `--argjson name JSON-text`:
|
|
230
249
|
|
|
@@ -244,17 +263,9 @@ sections:
|
|
|
244
263
|
|
|
245
264
|
This option reads in the named file and binds its contents to the given
|
|
246
265
|
global variable. If you run jq with `--rawfile foo bar`, then `$foo` is
|
|
247
|
-
available in the program and has a string whose contents are to the
|
|
266
|
+
available in the program and has a string whose contents are to the texts
|
|
248
267
|
in the file named `bar`.
|
|
249
268
|
|
|
250
|
-
* `--argfile variable-name filename`:
|
|
251
|
-
|
|
252
|
-
Do not use. Use `--slurpfile` instead.
|
|
253
|
-
|
|
254
|
-
(This option is like `--slurpfile`, but when the file has just
|
|
255
|
-
one text, then that is used, else an array of texts is used as
|
|
256
|
-
in `--slurpfile`.)
|
|
257
|
-
|
|
258
269
|
* `--args`:
|
|
259
270
|
|
|
260
271
|
Remaining arguments are positional string arguments. These are
|
|
@@ -265,6 +276,43 @@ sections:
|
|
|
265
276
|
Remaining arguments are positional JSON text arguments. These
|
|
266
277
|
are available to the jq program as `$ARGS.positional[]`.
|
|
267
278
|
|
|
279
|
+
* `--exit-status` / `-e`:
|
|
280
|
+
|
|
281
|
+
Sets the exit status of jq to 0 if the last output value was
|
|
282
|
+
neither `false` nor `null`, 1 if the last output value was
|
|
283
|
+
either `false` or `null`, or 4 if no valid result was ever
|
|
284
|
+
produced. Normally jq exits with 2 if there was any usage
|
|
285
|
+
problem or system error, 3 if there was a jq program compile
|
|
286
|
+
error, or 0 if the jq program ran.
|
|
287
|
+
|
|
288
|
+
Another way to set the exit status is with the `halt_error`
|
|
289
|
+
builtin function.
|
|
290
|
+
|
|
291
|
+
* `--binary` / `-b`:
|
|
292
|
+
|
|
293
|
+
Windows users using WSL, MSYS2, or Cygwin, should use this option
|
|
294
|
+
when using a native jq.exe, otherwise jq will turn newlines (LFs)
|
|
295
|
+
into carriage-return-then-newline (CRLF).
|
|
296
|
+
|
|
297
|
+
* `--version` / `-V`:
|
|
298
|
+
|
|
299
|
+
Output the jq version and exit with zero.
|
|
300
|
+
|
|
301
|
+
* `--build-configuration`:
|
|
302
|
+
|
|
303
|
+
Output the build configuration of jq and exit with zero.
|
|
304
|
+
This output has no supported format or structure and may change
|
|
305
|
+
without notice in future releases.
|
|
306
|
+
|
|
307
|
+
* `--help` / `-h`:
|
|
308
|
+
|
|
309
|
+
Output the jq help and exit with zero.
|
|
310
|
+
|
|
311
|
+
* `--`:
|
|
312
|
+
|
|
313
|
+
Terminates argument processing. Remaining arguments are not
|
|
314
|
+
interpreted as options.
|
|
315
|
+
|
|
268
316
|
* `--run-tests [filename]`:
|
|
269
317
|
|
|
270
318
|
Runs the tests in the given file or standard input. This must
|
|
@@ -273,7 +321,7 @@ sections:
|
|
|
273
321
|
program lines followed by one input line, as many lines of
|
|
274
322
|
output as are expected (one per output), and a terminating empty
|
|
275
323
|
line. Compilation failure tests start with a line containing
|
|
276
|
-
only
|
|
324
|
+
only `%%FAIL`, then a line containing the program to compile,
|
|
277
325
|
then a line containing an error message to compare to the
|
|
278
326
|
actual.
|
|
279
327
|
|
|
@@ -284,80 +332,149 @@ sections:
|
|
|
284
332
|
- title: "Identity: `.`"
|
|
285
333
|
body: |
|
|
286
334
|
|
|
287
|
-
The absolute simplest filter is `.` . This
|
|
288
|
-
|
|
289
|
-
|
|
335
|
+
The absolute simplest filter is `.` . This filter takes its
|
|
336
|
+
input and produces the same value as output. That is, this
|
|
337
|
+
is the identity operator.
|
|
338
|
+
|
|
339
|
+
Since jq by default pretty-prints all output, a trivial
|
|
340
|
+
program consisting of nothing but `.` can be used to format
|
|
341
|
+
JSON output from, say, `curl`.
|
|
342
|
+
|
|
343
|
+
Although the identity filter never modifies the value of its
|
|
344
|
+
input, jq processing can sometimes make it appear as though
|
|
345
|
+
it does. For example, using the current implementation of
|
|
346
|
+
jq, we would see that the expression:
|
|
347
|
+
|
|
348
|
+
1E1234567890 | .
|
|
349
|
+
|
|
350
|
+
produces `1.7976931348623157e+308` on at least one platform.
|
|
351
|
+
This is because, in the process of parsing the number, this
|
|
352
|
+
particular version of jq has converted it to an IEEE754
|
|
353
|
+
double-precision representation, losing precision.
|
|
354
|
+
|
|
355
|
+
The way in which jq handles numbers has changed over time
|
|
356
|
+
and further changes are likely within the parameters set by
|
|
357
|
+
the relevant JSON standards. Moreover, build configuration
|
|
358
|
+
options can alter how jq processes numbers.
|
|
359
|
+
|
|
360
|
+
The following remarks are therefore offered with the
|
|
361
|
+
understanding that they are intended to be descriptive of the
|
|
362
|
+
current version of jq and should not be interpreted as being
|
|
363
|
+
prescriptive:
|
|
364
|
+
|
|
365
|
+
(1) Any arithmetic operation on a number that has not
|
|
366
|
+
already been converted to an IEEE754 double precision
|
|
367
|
+
representation will trigger a conversion to the IEEE754
|
|
368
|
+
representation.
|
|
369
|
+
|
|
370
|
+
(2) jq will attempt to maintain the original decimal
|
|
371
|
+
precision of number literals (if the `--disable-decnum`
|
|
372
|
+
build configuration option was not used), but in expressions
|
|
373
|
+
such `1E1234567890`, precision will be lost if the exponent
|
|
374
|
+
is too large.
|
|
290
375
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
376
|
+
(3) In jq programs, a leading minus sign will trigger the
|
|
377
|
+
conversion of the number to an IEEE754 representation.
|
|
378
|
+
|
|
379
|
+
(4) Comparisons are carried out using the untruncated
|
|
380
|
+
big decimal representation of numbers if available, as
|
|
381
|
+
illustrated in one of the following examples.
|
|
382
|
+
|
|
383
|
+
The examples below use the builtin function `have_decnum` in
|
|
384
|
+
order to demonstrate the expected effects of using / not
|
|
385
|
+
using the `--disable-decnum` build configuration option, and
|
|
386
|
+
also to allow automated tests derived from these examples to
|
|
387
|
+
pass regardless of whether that option is used.
|
|
294
388
|
|
|
295
389
|
examples:
|
|
296
390
|
- program: '.'
|
|
297
391
|
input: '"Hello, world!"'
|
|
298
392
|
output: ['"Hello, world!"']
|
|
299
393
|
|
|
394
|
+
- program: '.'
|
|
395
|
+
input: '0.12345678901234567890123456789'
|
|
396
|
+
output: ['0.12345678901234567890123456789']
|
|
397
|
+
|
|
398
|
+
- program: '[., tojson] | . == if have_decnum then [12345678909876543212345,"12345678909876543212345"] else [12345678909876543000000,"12345678909876543000000"] end'
|
|
399
|
+
input: '12345678909876543212345'
|
|
400
|
+
output: ['true']
|
|
401
|
+
|
|
402
|
+
- program: '. < 0.12345678901234567890123456788'
|
|
403
|
+
input: '0.12345678901234567890123456789'
|
|
404
|
+
output: ['false']
|
|
405
|
+
|
|
406
|
+
- program: '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'
|
|
407
|
+
input: '[1, 1.000, 1.0, 100e-2]'
|
|
408
|
+
output: ['true']
|
|
409
|
+
|
|
410
|
+
- program: '. as $big | [$big, $big + 1] | map(. > 10000000000000000000000000000000) | . == if have_decnum then [true, false] else [false, false] end'
|
|
411
|
+
input: '10000000000000000000000000000001'
|
|
412
|
+
output: ['true']
|
|
413
|
+
|
|
300
414
|
- title: "Object Identifier-Index: `.foo`, `.foo.bar`"
|
|
301
415
|
body: |
|
|
302
416
|
|
|
303
|
-
The simplest *useful* filter
|
|
304
|
-
JSON object (aka dictionary or hash) as input,
|
|
305
|
-
the value at the key "foo", or null
|
|
417
|
+
The simplest *useful* filter has the form `.foo`. When given a
|
|
418
|
+
JSON object (aka dictionary or hash) as input, `.foo` produces
|
|
419
|
+
the value at the key "foo" if the key is present, or null otherwise.
|
|
306
420
|
|
|
307
|
-
A filter of the form `.foo.bar` is equivalent to `.foo
|
|
421
|
+
A filter of the form `.foo.bar` is equivalent to `.foo | .bar`.
|
|
308
422
|
|
|
309
|
-
|
|
423
|
+
The `.foo` syntax only works for simple, identifier-like keys, that
|
|
310
424
|
is, keys that are all made of alphanumeric characters and
|
|
311
425
|
underscore, and which do not start with a digit.
|
|
312
426
|
|
|
313
|
-
If the key contains special characters
|
|
314
|
-
it with double quotes like this:
|
|
427
|
+
If the key contains special characters or starts with a digit,
|
|
428
|
+
you need to surround it with double quotes like this:
|
|
429
|
+
`."foo$"`, or else `.["foo$"]`.
|
|
315
430
|
|
|
316
431
|
For example `.["foo::bar"]` and `.["foo.bar"]` work while
|
|
317
|
-
`.foo::bar` does not
|
|
432
|
+
`.foo::bar` does not.
|
|
318
433
|
|
|
319
434
|
examples:
|
|
320
435
|
- program: '.foo'
|
|
321
436
|
input: '{"foo": 42, "bar": "less interesting data"}'
|
|
322
|
-
output: [42]
|
|
437
|
+
output: ['42']
|
|
438
|
+
|
|
323
439
|
- program: '.foo'
|
|
324
440
|
input: '{"notfoo": true, "alsonotfoo": false}'
|
|
325
441
|
output: ['null']
|
|
442
|
+
|
|
326
443
|
- program: '.["foo"]'
|
|
327
444
|
input: '{"foo": 42}'
|
|
328
|
-
output: [42]
|
|
445
|
+
output: ['42']
|
|
329
446
|
|
|
330
447
|
- title: "Optional Object Identifier-Index: `.foo?`"
|
|
331
448
|
body: |
|
|
332
449
|
|
|
333
|
-
Just like `.foo`, but does not output
|
|
334
|
-
|
|
450
|
+
Just like `.foo`, but does not output an error when `.` is not an
|
|
451
|
+
object.
|
|
335
452
|
|
|
336
453
|
examples:
|
|
337
454
|
- program: '.foo?'
|
|
338
455
|
input: '{"foo": 42, "bar": "less interesting data"}'
|
|
339
|
-
output: [42]
|
|
456
|
+
output: ['42']
|
|
340
457
|
- program: '.foo?'
|
|
341
458
|
input: '{"notfoo": true, "alsonotfoo": false}'
|
|
342
459
|
output: ['null']
|
|
343
460
|
- program: '.["foo"]?'
|
|
344
461
|
input: '{"foo": 42}'
|
|
345
|
-
output: [42]
|
|
462
|
+
output: ['42']
|
|
346
463
|
- program: '[.foo?]'
|
|
347
464
|
input: '[1,2]'
|
|
348
465
|
output: ['[]']
|
|
349
466
|
|
|
350
|
-
- title: "
|
|
467
|
+
- title: "Object Index: `.[<string>]`"
|
|
351
468
|
body: |
|
|
352
469
|
|
|
353
470
|
You can also look up fields of an object using syntax like
|
|
354
|
-
`.["foo"]` (
|
|
471
|
+
`.["foo"]` (`.foo` above is a shorthand version of this, but
|
|
355
472
|
only for identifier-like strings).
|
|
356
473
|
|
|
357
|
-
- title: "Array Index: `.[
|
|
474
|
+
- title: "Array Index: `.[<number>]`"
|
|
358
475
|
body: |
|
|
359
476
|
|
|
360
|
-
When the index value is an integer, `.[<
|
|
477
|
+
When the index value is an integer, `.[<number>]` can index
|
|
361
478
|
arrays. Arrays are zero-based, so `.[2]` returns the third
|
|
362
479
|
element.
|
|
363
480
|
|
|
@@ -377,16 +494,17 @@ sections:
|
|
|
377
494
|
input: '[1,2,3]'
|
|
378
495
|
output: ['2']
|
|
379
496
|
|
|
380
|
-
- title: "Array/String Slice: `.[
|
|
497
|
+
- title: "Array/String Slice: `.[<number>:<number>]`"
|
|
381
498
|
body: |
|
|
382
499
|
|
|
383
|
-
The `.[
|
|
384
|
-
array or substring of a string. The array
|
|
385
|
-
`.[10:15]` will be of length 5, containing the
|
|
386
|
-
index 10 (inclusive) to index 15 (exclusive).
|
|
387
|
-
be negative (in which case it counts
|
|
388
|
-
the array), or omitted (in which
|
|
389
|
-
or end of the array).
|
|
500
|
+
The `.[<number>:<number>]` syntax can be used to return a
|
|
501
|
+
subarray of an array or substring of a string. The array
|
|
502
|
+
returned by `.[10:15]` will be of length 5, containing the
|
|
503
|
+
elements from index 10 (inclusive) to index 15 (exclusive).
|
|
504
|
+
Either index may be negative (in which case it counts
|
|
505
|
+
backwards from the end of the array), or omitted (in which
|
|
506
|
+
case it refers to the start or end of the array).
|
|
507
|
+
Indices are zero-based.
|
|
390
508
|
|
|
391
509
|
examples:
|
|
392
510
|
- program: '.[2:4]'
|
|
@@ -412,11 +530,14 @@ sections:
|
|
|
412
530
|
entirely, it will return *all* of the elements of an
|
|
413
531
|
array. Running `.[]` with the input `[1,2,3]` will produce the
|
|
414
532
|
numbers as three separate results, rather than as a single
|
|
415
|
-
array.
|
|
533
|
+
array. A filter of the form `.foo[]` is equivalent to
|
|
534
|
+
`.foo | .[]`.
|
|
416
535
|
|
|
417
536
|
You can also use this on an object, and it will return all
|
|
418
537
|
the values of the object.
|
|
419
538
|
|
|
539
|
+
Note that the iterator operator is a generator of values.
|
|
540
|
+
|
|
420
541
|
examples:
|
|
421
542
|
- program: '.[]'
|
|
422
543
|
input: '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]'
|
|
@@ -428,6 +549,10 @@ sections:
|
|
|
428
549
|
input: '[]'
|
|
429
550
|
output: []
|
|
430
551
|
|
|
552
|
+
- program: '.foo[]'
|
|
553
|
+
input: '{"foo":[1,2,3]}'
|
|
554
|
+
output: ['1','2','3']
|
|
555
|
+
|
|
431
556
|
- program: '.[]'
|
|
432
557
|
input: '{"a": 1, "b": 1}'
|
|
433
558
|
output: ['1', '1']
|
|
@@ -436,7 +561,8 @@ sections:
|
|
|
436
561
|
body: |
|
|
437
562
|
|
|
438
563
|
Like `.[]`, but no errors will be output if . is not an array
|
|
439
|
-
or object.
|
|
564
|
+
or object. A filter of the form `.foo[]?` is equivalent to
|
|
565
|
+
`.foo | .[]?`.
|
|
440
566
|
|
|
441
567
|
- title: "Comma: `,`"
|
|
442
568
|
body: |
|
|
@@ -449,6 +575,8 @@ sections:
|
|
|
449
575
|
.bar`, produces both the "foo" fields and "bar" fields as
|
|
450
576
|
separate outputs.
|
|
451
577
|
|
|
578
|
+
The `,` operator is one way to construct generators.
|
|
579
|
+
|
|
452
580
|
examples:
|
|
453
581
|
- program: '.foo, .bar'
|
|
454
582
|
input: '{"foo": 42, "bar": "something else", "baz": true}'
|
|
@@ -467,13 +595,13 @@ sections:
|
|
|
467
595
|
|
|
468
596
|
The | operator combines two filters by feeding the output(s) of
|
|
469
597
|
the one on the left into the input of the one on the right. It's
|
|
470
|
-
|
|
471
|
-
that.
|
|
598
|
+
similar to the Unix shell's pipe, if you're used to that.
|
|
472
599
|
|
|
473
600
|
If the one on the left produces multiple results, the one on
|
|
474
601
|
the right will be run for each of those results. So, the
|
|
475
602
|
expression `.[] | .foo` retrieves the "foo" field of each
|
|
476
|
-
element of the input array.
|
|
603
|
+
element of the input array. This is a cartesian product,
|
|
604
|
+
which can be surprising.
|
|
477
605
|
|
|
478
606
|
Note that `.a.b.c` is the same as `.a | .b | .c`.
|
|
479
607
|
|
|
@@ -496,7 +624,7 @@ sections:
|
|
|
496
624
|
examples:
|
|
497
625
|
- program: '(. + 2) * 5'
|
|
498
626
|
input: '1'
|
|
499
|
-
output: [15]
|
|
627
|
+
output: ['15']
|
|
500
628
|
|
|
501
629
|
- title: Types and Values
|
|
502
630
|
body: |
|
|
@@ -506,11 +634,21 @@ sections:
|
|
|
506
634
|
hashes with only string keys), and "null".
|
|
507
635
|
|
|
508
636
|
Booleans, null, strings and numbers are written the same way as
|
|
509
|
-
in
|
|
637
|
+
in JSON. Just like everything else in jq, these simple
|
|
510
638
|
values take an input and produce an output - `42` is a valid jq
|
|
511
639
|
expression that takes an input, ignores it, and returns 42
|
|
512
640
|
instead.
|
|
513
641
|
|
|
642
|
+
Numbers in jq are internally represented by their IEEE754 double
|
|
643
|
+
precision approximation. Any arithmetic operation with numbers,
|
|
644
|
+
whether they are literals or results of previous filters, will
|
|
645
|
+
produce a double precision floating point result.
|
|
646
|
+
|
|
647
|
+
However, when parsing a literal jq will store the original literal
|
|
648
|
+
string. If no mutation is applied to this value then it will make
|
|
649
|
+
to the output in its original form, even if conversion to double
|
|
650
|
+
would result in a loss.
|
|
651
|
+
|
|
514
652
|
entries:
|
|
515
653
|
- title: "Array construction: `[]`"
|
|
516
654
|
body: |
|
|
@@ -548,13 +686,16 @@ sections:
|
|
|
548
686
|
dictionaries or hashes), as in: `{"a": 42, "b": 17}`.
|
|
549
687
|
|
|
550
688
|
If the keys are "identifier-like", then the quotes can be left
|
|
551
|
-
off, as in `{a:42, b:17}`.
|
|
552
|
-
|
|
689
|
+
off, as in `{a:42, b:17}`. Variable references as key
|
|
690
|
+
expressions use the value of the variable as the key. Key
|
|
691
|
+
expressions other than constant literals, identifiers, or
|
|
692
|
+
variable references, need to be parenthesized, e.g.,
|
|
693
|
+
`{("a"+"b"):59}`.
|
|
553
694
|
|
|
554
|
-
The value can be any expression (although you may need to
|
|
555
|
-
|
|
556
|
-
applied to the {} expression's input (remember, all
|
|
557
|
-
have an input and an output).
|
|
695
|
+
The value can be any expression (although you may need to wrap
|
|
696
|
+
it in parentheses if, for example, it contains colons), which
|
|
697
|
+
gets applied to the {} expression's input (remember, all
|
|
698
|
+
filters have an input and an output).
|
|
558
699
|
|
|
559
700
|
{foo: .bar}
|
|
560
701
|
|
|
@@ -592,6 +733,16 @@ sections:
|
|
|
592
733
|
|
|
593
734
|
{"stedolan": ["JQ Primer", "More JQ"]}
|
|
594
735
|
|
|
736
|
+
Variable references as keys use the value of the variable as
|
|
737
|
+
the key. Without a value then the variable's name becomes the
|
|
738
|
+
key and its value becomes the value,
|
|
739
|
+
|
|
740
|
+
"f o o" as $foo | "b a r" as $bar | {$foo, $bar:$foo}
|
|
741
|
+
|
|
742
|
+
produces
|
|
743
|
+
|
|
744
|
+
{"foo":"f o o","b a r":"f o o"}
|
|
745
|
+
|
|
595
746
|
examples:
|
|
596
747
|
- program: '{user, title: .titles[]}'
|
|
597
748
|
input: '{"user":"stedolan","titles":["JQ Primer", "More JQ"]}'
|
|
@@ -608,27 +759,39 @@ sections:
|
|
|
608
759
|
Recursively descends `.`, producing every value. This is the
|
|
609
760
|
same as the zero-argument `recurse` builtin (see below). This
|
|
610
761
|
is intended to resemble the XPath `//` operator. Note that
|
|
611
|
-
`..a` does not work; use
|
|
612
|
-
below we use
|
|
762
|
+
`..a` does not work; use `.. | .a` instead. In the example
|
|
763
|
+
below we use `.. | .a?` to find all the values of object keys
|
|
613
764
|
"a" in any object found "below" `.`.
|
|
614
765
|
|
|
615
766
|
This is particularly useful in conjunction with `path(EXP)`
|
|
616
767
|
(also see below) and the `?` operator.
|
|
617
768
|
|
|
618
769
|
examples:
|
|
619
|
-
- program: '
|
|
770
|
+
- program: '.. | .a?'
|
|
620
771
|
input: '[[{"a":1}]]'
|
|
621
772
|
output: ['1']
|
|
622
773
|
|
|
623
774
|
- title: Builtin operators and functions
|
|
624
775
|
body: |
|
|
625
776
|
|
|
626
|
-
Some jq
|
|
777
|
+
Some jq operators (for instance, `+`) do different things
|
|
627
778
|
depending on the type of their arguments (arrays, numbers,
|
|
628
779
|
etc.). However, jq never does implicit type conversions. If you
|
|
629
780
|
try to add a string to an object you'll get an error message and
|
|
630
781
|
no result.
|
|
631
782
|
|
|
783
|
+
Please note that all numbers are converted to IEEE754 double precision
|
|
784
|
+
floating point representation. Arithmetic and logical operators are working
|
|
785
|
+
with these converted doubles. Results of all such operations are also limited
|
|
786
|
+
to the double precision.
|
|
787
|
+
|
|
788
|
+
The only exception to this behaviour of number is a snapshot of original number
|
|
789
|
+
literal. When a number which originally was provided as a literal is never
|
|
790
|
+
mutated until the end of the program then it is printed to the output in its
|
|
791
|
+
original literal form. This also includes cases when the original literal
|
|
792
|
+
would be truncated when converted to the IEEE754 double precision floating point
|
|
793
|
+
number.
|
|
794
|
+
|
|
632
795
|
entries:
|
|
633
796
|
- title: "Addition: `+`"
|
|
634
797
|
body: |
|
|
@@ -644,10 +807,10 @@ sections:
|
|
|
644
807
|
- **Strings** are added by being joined into a larger string.
|
|
645
808
|
|
|
646
809
|
- **Objects** are added by merging, that is, inserting all
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
810
|
+
the key-value pairs from both objects into a single
|
|
811
|
+
combined object. If both objects contain a value for the
|
|
812
|
+
same key, the object on the right of the `+` wins. (For
|
|
813
|
+
recursive merge use the `*` operator.)
|
|
651
814
|
|
|
652
815
|
`null` can be added to any value, and returns the other
|
|
653
816
|
value unchanged.
|
|
@@ -684,14 +847,14 @@ sections:
|
|
|
684
847
|
input: '["xml", "yaml", "json"]'
|
|
685
848
|
output: ['["json"]']
|
|
686
849
|
|
|
687
|
-
- title: "Multiplication, division, modulo: `*`, `/`,
|
|
850
|
+
- title: "Multiplication, division, modulo: `*`, `/`, `%`"
|
|
688
851
|
body: |
|
|
689
852
|
|
|
690
853
|
These infix operators behave as expected when given two numbers.
|
|
691
854
|
Division by zero raises an error. `x % y` computes x modulo y.
|
|
692
855
|
|
|
693
856
|
Multiplying a string by a number produces the concatenation of
|
|
694
|
-
that string that many times. `"x" * 0` produces
|
|
857
|
+
that string that many times. `"x" * 0` produces `""`.
|
|
695
858
|
|
|
696
859
|
Dividing a string by another splits the first using the second
|
|
697
860
|
as separators.
|
|
@@ -703,8 +866,8 @@ sections:
|
|
|
703
866
|
|
|
704
867
|
examples:
|
|
705
868
|
- program: '10 / . * 3'
|
|
706
|
-
input: 5
|
|
707
|
-
output: [6]
|
|
869
|
+
input: '5'
|
|
870
|
+
output: ['6']
|
|
708
871
|
- program: '. / ", "'
|
|
709
872
|
input: '"a, b,c,d, e"'
|
|
710
873
|
output: ['["a","b,c,d","e"]']
|
|
@@ -715,6 +878,21 @@ sections:
|
|
|
715
878
|
input: '[1,0,-1]'
|
|
716
879
|
output: ['1', '-1']
|
|
717
880
|
|
|
881
|
+
- title: "`abs`"
|
|
882
|
+
body: |
|
|
883
|
+
|
|
884
|
+
The builtin function `abs` is defined naively as: `if . < 0 then - . else . end`.
|
|
885
|
+
|
|
886
|
+
For numeric input, this is the absolute value. See the
|
|
887
|
+
section on the identity filter for the implications of this
|
|
888
|
+
definition for numeric input.
|
|
889
|
+
|
|
890
|
+
To compute the absolute value of a number as a floating point number, you may wish use `fabs`.
|
|
891
|
+
|
|
892
|
+
examples:
|
|
893
|
+
- program: 'map(abs)'
|
|
894
|
+
input: '[-10, -1.1, -1e-1]'
|
|
895
|
+
output: ['[10,1.1,1e-1]']
|
|
718
896
|
|
|
719
897
|
- title: "`length`"
|
|
720
898
|
body: |
|
|
@@ -726,16 +904,20 @@ sections:
|
|
|
726
904
|
codepoints it contains (which will be the same as its
|
|
727
905
|
JSON-encoded length in bytes if it's pure ASCII).
|
|
728
906
|
|
|
907
|
+
- The length of a **number** is its absolute value.
|
|
908
|
+
|
|
729
909
|
- The length of an **array** is the number of elements.
|
|
730
910
|
|
|
731
911
|
- The length of an **object** is the number of key-value pairs.
|
|
732
912
|
|
|
733
913
|
- The length of **null** is zero.
|
|
734
914
|
|
|
915
|
+
- It is an error to use `length` on a **boolean**.
|
|
916
|
+
|
|
735
917
|
examples:
|
|
736
918
|
- program: '.[] | length'
|
|
737
|
-
input: '[[1,2], "string", {"a":2}, null]'
|
|
738
|
-
output: [2, 6, 1, 0]
|
|
919
|
+
input: '[[1,2], "string", {"a":2}, null, -5]'
|
|
920
|
+
output: ['2', '6', '1', '0', '5']
|
|
739
921
|
|
|
740
922
|
|
|
741
923
|
- title: "`utf8bytelength`"
|
|
@@ -747,7 +929,7 @@ sections:
|
|
|
747
929
|
examples:
|
|
748
930
|
- program: 'utf8bytelength'
|
|
749
931
|
input: '"\u03bc"'
|
|
750
|
-
output: [2]
|
|
932
|
+
output: ['2']
|
|
751
933
|
|
|
752
934
|
- title: "`keys`, `keys_unsorted`"
|
|
753
935
|
body: |
|
|
@@ -811,18 +993,51 @@ sections:
|
|
|
811
993
|
input: '[2, 0]'
|
|
812
994
|
output: ['[false, true]']
|
|
813
995
|
|
|
814
|
-
- title: "`map(
|
|
996
|
+
- title: "`map(f)`, `map_values(f)`"
|
|
815
997
|
body: |
|
|
816
998
|
|
|
817
|
-
For any filter `
|
|
818
|
-
|
|
819
|
-
|
|
999
|
+
For any filter `f`, `map(f)` and `map_values(f)` apply `f`
|
|
1000
|
+
to each of the values in the input array or object, that is,
|
|
1001
|
+
to the values of `.[]`.
|
|
1002
|
+
|
|
1003
|
+
In the absence of errors, `map(f)` always outputs an array
|
|
1004
|
+
whereas `map_values(f)` outputs an array if given an array,
|
|
1005
|
+
or an object if given an object.
|
|
1006
|
+
|
|
1007
|
+
When the input to `map_values(f)` is an object, the output
|
|
1008
|
+
object has the same keys as the input object except for
|
|
1009
|
+
those keys whose values when piped to `f` produce no values
|
|
1010
|
+
at all.
|
|
1011
|
+
|
|
1012
|
+
The key difference between `map(f)` and `map_values(f)` is
|
|
1013
|
+
that the former simply forms an array from all the values of
|
|
1014
|
+
`($x|f)` for each value, $x, in the input array or object,
|
|
1015
|
+
but `map_values(f)` only uses `first($x|f)`.
|
|
1016
|
+
|
|
1017
|
+
Specifically, for object inputs, `map_values(f)` constructs
|
|
1018
|
+
the output object by examining in turn the value of
|
|
1019
|
+
`first(.[$k]|f)` for each key, $k, of the input. If this
|
|
1020
|
+
expression produces no values, then the corresponding key
|
|
1021
|
+
will be dropped; otherwise, the output object will have that
|
|
1022
|
+
value at the key, $k.
|
|
1023
|
+
|
|
1024
|
+
Here are some examples to clarify the behavior of `map` and
|
|
1025
|
+
`map_values` when applied to arrays. These examples assume the
|
|
1026
|
+
input is `[1]` in all cases:
|
|
820
1027
|
|
|
821
|
-
|
|
822
|
-
|
|
1028
|
+
map(.+1) #=> [2]
|
|
1029
|
+
map(., .) #=> [1,1]
|
|
1030
|
+
map(empty) #=> []
|
|
1031
|
+
|
|
1032
|
+
map_values(.+1) #=> [2]
|
|
1033
|
+
map_values(., .) #=> [1]
|
|
1034
|
+
map_values(empty) #=> []
|
|
1035
|
+
|
|
1036
|
+
`map(f)` is equivalent to `[.[] | f]` and
|
|
1037
|
+
`map_values(f)` is equivalent to `.[] |= f`.
|
|
1038
|
+
|
|
1039
|
+
In fact, these are their implementations.
|
|
823
1040
|
|
|
824
|
-
`map(x)` is equivalent to `[.[] | x]`. In fact, this is how
|
|
825
|
-
it's defined. Similarly, `map_values(x)` is defined as `.[] |= x`.
|
|
826
1041
|
|
|
827
1042
|
examples:
|
|
828
1043
|
- program: 'map(.+1)'
|
|
@@ -833,6 +1048,34 @@ sections:
|
|
|
833
1048
|
input: '{"a": 1, "b": 2, "c": 3}'
|
|
834
1049
|
output: ['{"a": 2, "b": 3, "c": 4}']
|
|
835
1050
|
|
|
1051
|
+
- program: 'map(., .)'
|
|
1052
|
+
input: '[1,2]'
|
|
1053
|
+
output: ['[1,1,2,2]']
|
|
1054
|
+
|
|
1055
|
+
- program: 'map_values(. // empty)'
|
|
1056
|
+
input: '{"a": null, "b": true, "c": false}'
|
|
1057
|
+
output: ['{"b":true}']
|
|
1058
|
+
|
|
1059
|
+
|
|
1060
|
+
- title: "`pick(pathexps)`"
|
|
1061
|
+
body: |
|
|
1062
|
+
|
|
1063
|
+
Emit the projection of the input object or array defined by the
|
|
1064
|
+
specified sequence of path expressions, such that if `p` is any
|
|
1065
|
+
one of these specifications, then `(. | p)` will evaluate to the
|
|
1066
|
+
same value as `(. | pick(pathexps) | p)`. For arrays, negative
|
|
1067
|
+
indices and `.[m:n]` specifications should not be used.
|
|
1068
|
+
|
|
1069
|
+
examples:
|
|
1070
|
+
- program: 'pick(.a, .b.c, .x)'
|
|
1071
|
+
input: '{"a": 1, "b": {"c": 2, "d": 3}, "e": 4}'
|
|
1072
|
+
output: ['{"a":1,"b":{"c":2},"x":null}']
|
|
1073
|
+
|
|
1074
|
+
- program: 'pick(.[2], .[0], .[0])'
|
|
1075
|
+
input: '[1,2,3,4]'
|
|
1076
|
+
output: ['[1,null,3]']
|
|
1077
|
+
|
|
1078
|
+
|
|
836
1079
|
- title: "`path(path_expression)`"
|
|
837
1080
|
body: |
|
|
838
1081
|
|
|
@@ -912,7 +1155,7 @@ sections:
|
|
|
912
1155
|
- title: "`delpaths(PATHS)`"
|
|
913
1156
|
body: |
|
|
914
1157
|
|
|
915
|
-
The builtin function `delpaths`
|
|
1158
|
+
The builtin function `delpaths` deletes the `PATHS` in `.`.
|
|
916
1159
|
`PATHS` must be an array of paths, where each path is an array
|
|
917
1160
|
of strings and numbers.
|
|
918
1161
|
|
|
@@ -921,7 +1164,7 @@ sections:
|
|
|
921
1164
|
input: '{"a":{"b":1},"x":{"y":2}}'
|
|
922
1165
|
output: ['{"a":{},"x":{"y":2}}']
|
|
923
1166
|
|
|
924
|
-
- title: "`to_entries`, `from_entries`, `with_entries`"
|
|
1167
|
+
- title: "`to_entries`, `from_entries`, `with_entries(f)`"
|
|
925
1168
|
body: |
|
|
926
1169
|
|
|
927
1170
|
These functions convert between an object and an array of
|
|
@@ -929,11 +1172,11 @@ sections:
|
|
|
929
1172
|
for each `k: v` entry in the input, the output array
|
|
930
1173
|
includes `{"key": k, "value": v}`.
|
|
931
1174
|
|
|
932
|
-
`from_entries` does the opposite conversion, and
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1175
|
+
`from_entries` does the opposite conversion, and `with_entries(f)`
|
|
1176
|
+
is a shorthand for `to_entries | map(f) | from_entries`, useful for
|
|
1177
|
+
doing some operation to all keys and values of an object.
|
|
1178
|
+
`from_entries` accepts `"key"`, `"Key"`, `"name"`, `"Name"`,
|
|
1179
|
+
`"value"`, and `"Value"` as keys.
|
|
937
1180
|
|
|
938
1181
|
examples:
|
|
939
1182
|
- program: 'to_entries'
|
|
@@ -950,8 +1193,8 @@ sections:
|
|
|
950
1193
|
- title: "`select(boolean_expression)`"
|
|
951
1194
|
body: |
|
|
952
1195
|
|
|
953
|
-
The function `select(
|
|
954
|
-
`
|
|
1196
|
+
The function `select(f)` produces its input unchanged if
|
|
1197
|
+
`f` returns true for that input, and produces no output
|
|
955
1198
|
otherwise.
|
|
956
1199
|
|
|
957
1200
|
It's useful for filtering lists: `[1,2,3] | map(select(. >= 2))`
|
|
@@ -989,17 +1232,26 @@ sections:
|
|
|
989
1232
|
examples:
|
|
990
1233
|
- program: '1, empty, 2'
|
|
991
1234
|
input: 'null'
|
|
992
|
-
output: [1, 2]
|
|
1235
|
+
output: ['1', '2']
|
|
993
1236
|
- program: '[1,2,empty,3]'
|
|
994
1237
|
input: 'null'
|
|
995
1238
|
output: ['[1,2,3]']
|
|
996
1239
|
|
|
997
|
-
- title: "`error(message)`"
|
|
1240
|
+
- title: "`error`, `error(message)`"
|
|
998
1241
|
body: |
|
|
999
1242
|
|
|
1000
|
-
Produces an error
|
|
1001
|
-
|
|
1002
|
-
|
|
1243
|
+
Produces an error with the input value, or with the message
|
|
1244
|
+
given as the argument. Errors can be caught with try/catch;
|
|
1245
|
+
see below.
|
|
1246
|
+
|
|
1247
|
+
examples:
|
|
1248
|
+
- program: 'try error catch .'
|
|
1249
|
+
input: '"error message"'
|
|
1250
|
+
output: ['"error message"']
|
|
1251
|
+
|
|
1252
|
+
- program: 'try error("invalid value: \(.)") catch .'
|
|
1253
|
+
input: '42'
|
|
1254
|
+
output: ['"invalid value: 42"']
|
|
1003
1255
|
|
|
1004
1256
|
- title: "`halt`"
|
|
1005
1257
|
body: |
|
|
@@ -1017,7 +1269,7 @@ sections:
|
|
|
1017
1269
|
The given `exit_code` (defaulting to `5`) will be jq's exit
|
|
1018
1270
|
status.
|
|
1019
1271
|
|
|
1020
|
-
For example, `"Error:
|
|
1272
|
+
For example, `"Error: something went wrong\n"|halt_error(1)`.
|
|
1021
1273
|
|
|
1022
1274
|
- title: "`$__loc__`"
|
|
1023
1275
|
body: |
|
|
@@ -1031,29 +1283,26 @@ sections:
|
|
|
1031
1283
|
input: 'null'
|
|
1032
1284
|
output: ['"{\"file\":\"<top-level>\",\"line\":1}"']
|
|
1033
1285
|
|
|
1034
|
-
- title: "`paths`, `paths(node_filter)
|
|
1286
|
+
- title: "`paths`, `paths(node_filter)`"
|
|
1035
1287
|
body: |
|
|
1036
1288
|
|
|
1037
1289
|
`paths` outputs the paths to all the elements in its input
|
|
1038
1290
|
(except it does not output the empty list, representing .
|
|
1039
1291
|
itself).
|
|
1040
1292
|
|
|
1041
|
-
`paths(f)` outputs the paths to any values for which `f` is true
|
|
1042
|
-
That is, `paths(
|
|
1293
|
+
`paths(f)` outputs the paths to any values for which `f` is `true`.
|
|
1294
|
+
That is, `paths(type == "number")` outputs the paths to all numeric
|
|
1043
1295
|
values.
|
|
1044
1296
|
|
|
1045
|
-
`leaf_paths` is an alias of `paths(scalars)`; `leaf_paths` is
|
|
1046
|
-
*deprecated* and will be removed in the next major release.
|
|
1047
|
-
|
|
1048
1297
|
examples:
|
|
1049
1298
|
- program: '[paths]'
|
|
1050
1299
|
input: '[1,[[],{"a":2}]]'
|
|
1051
1300
|
output: ['[[0],[1],[1,0],[1,1],[1,1,"a"]]']
|
|
1052
|
-
- program: '[paths(
|
|
1301
|
+
- program: '[paths(type == "number")]'
|
|
1053
1302
|
input: '[1,[[],{"a":2}]]'
|
|
1054
1303
|
output: ['[[0],[1,1,"a"]]']
|
|
1055
1304
|
|
|
1056
|
-
- title: "`add`"
|
|
1305
|
+
- title: "`add`, `add(generator)`"
|
|
1057
1306
|
body: |
|
|
1058
1307
|
|
|
1059
1308
|
The filter `add` takes as input an array, and produces as
|
|
@@ -1064,16 +1313,22 @@ sections:
|
|
|
1064
1313
|
|
|
1065
1314
|
If the input is an empty array, `add` returns `null`.
|
|
1066
1315
|
|
|
1316
|
+
`add(generator)` operates on the given generator rather than
|
|
1317
|
+
the input.
|
|
1318
|
+
|
|
1067
1319
|
examples:
|
|
1068
1320
|
- program: add
|
|
1069
1321
|
input: '["a","b","c"]'
|
|
1070
1322
|
output: ['"abc"']
|
|
1071
1323
|
- program: add
|
|
1072
1324
|
input: '[1, 2, 3]'
|
|
1073
|
-
output: [6]
|
|
1325
|
+
output: ['6']
|
|
1074
1326
|
- program: add
|
|
1075
1327
|
input: '[]'
|
|
1076
1328
|
output: ["null"]
|
|
1329
|
+
- program: add(.[].a)
|
|
1330
|
+
input: '[{"a":3}, {"a":5}, {"b":6}]'
|
|
1331
|
+
output: ['8']
|
|
1077
1332
|
|
|
1078
1333
|
- title: "`any`, `any(condition)`, `any(generator; condition)`"
|
|
1079
1334
|
body: |
|
|
@@ -1152,12 +1407,12 @@ sections:
|
|
|
1152
1407
|
input: '[{"foo": "bar"}, [{"foo": "baz"}]]'
|
|
1153
1408
|
output: ['[{"foo": "bar"}, {"foo": "baz"}]']
|
|
1154
1409
|
|
|
1155
|
-
- title: "`range(upto)`, `range(from;upto)
|
|
1410
|
+
- title: "`range(upto)`, `range(from; upto)`, `range(from; upto; by)`"
|
|
1156
1411
|
body: |
|
|
1157
1412
|
|
|
1158
|
-
The `range` function produces a range of numbers. `range(4;10)`
|
|
1413
|
+
The `range` function produces a range of numbers. `range(4; 10)`
|
|
1159
1414
|
produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers
|
|
1160
|
-
are produced as separate outputs. Use `[range(4;10)]` to get a range as
|
|
1415
|
+
are produced as separate outputs. Use `[range(4; 10)]` to get a range as
|
|
1161
1416
|
an array.
|
|
1162
1417
|
|
|
1163
1418
|
The one argument form generates numbers from 0 to the given
|
|
@@ -1170,22 +1425,22 @@ sections:
|
|
|
1170
1425
|
with an increment of `by`.
|
|
1171
1426
|
|
|
1172
1427
|
examples:
|
|
1173
|
-
- program: 'range(2;4)'
|
|
1428
|
+
- program: 'range(2; 4)'
|
|
1174
1429
|
input: 'null'
|
|
1175
1430
|
output: ['2', '3']
|
|
1176
|
-
- program: '[range(2;4)]'
|
|
1431
|
+
- program: '[range(2; 4)]'
|
|
1177
1432
|
input: 'null'
|
|
1178
1433
|
output: ['[2,3]']
|
|
1179
1434
|
- program: '[range(4)]'
|
|
1180
1435
|
input: 'null'
|
|
1181
1436
|
output: ['[0,1,2,3]']
|
|
1182
|
-
- program: '[range(0;10;3)]'
|
|
1437
|
+
- program: '[range(0; 10; 3)]'
|
|
1183
1438
|
input: 'null'
|
|
1184
1439
|
output: ['[0,3,6,9]']
|
|
1185
|
-
- program: '[range(0;10
|
|
1440
|
+
- program: '[range(0; 10; -1)]'
|
|
1186
1441
|
input: 'null'
|
|
1187
1442
|
output: ['[]']
|
|
1188
|
-
- program: '[range(0
|
|
1443
|
+
- program: '[range(0; -5; -1)]'
|
|
1189
1444
|
input: 'null'
|
|
1190
1445
|
output: ['[0,-1,-2,-3,-4]']
|
|
1191
1446
|
|
|
@@ -1219,7 +1474,7 @@ sections:
|
|
|
1219
1474
|
examples:
|
|
1220
1475
|
- program: '.[] | tonumber'
|
|
1221
1476
|
input: '[1, "1"]'
|
|
1222
|
-
output: [1, 1]
|
|
1477
|
+
output: ['1', '1']
|
|
1223
1478
|
|
|
1224
1479
|
- title: "`tostring`"
|
|
1225
1480
|
body: |
|
|
@@ -1269,7 +1524,7 @@ sections:
|
|
|
1269
1524
|
input: 'null'
|
|
1270
1525
|
output: ['"number"', '"number"']
|
|
1271
1526
|
|
|
1272
|
-
- title: "`sort
|
|
1527
|
+
- title: "`sort`, `sort_by(path_expression)`"
|
|
1273
1528
|
body: |
|
|
1274
1529
|
|
|
1275
1530
|
The `sort` functions sorts its input, which must be an
|
|
@@ -1288,19 +1543,25 @@ sections:
|
|
|
1288
1543
|
sorted order), and if their keys are equal then the values
|
|
1289
1544
|
are compared key by key.
|
|
1290
1545
|
|
|
1291
|
-
`
|
|
1292
|
-
object, or by applying any jq filter.
|
|
1293
|
-
|
|
1294
|
-
`
|
|
1295
|
-
|
|
1546
|
+
`sort_by` may be used to sort by a particular field of an
|
|
1547
|
+
object, or by applying any jq filter. `sort_by(f)` compares
|
|
1548
|
+
two elements by comparing the result of `f` on each element.
|
|
1549
|
+
When `f` produces multiple values, it firstly compares the
|
|
1550
|
+
first values, and the second values if the first values are
|
|
1551
|
+
equal, and so on.
|
|
1296
1552
|
|
|
1297
1553
|
examples:
|
|
1298
1554
|
- program: 'sort'
|
|
1299
1555
|
input: '[8,3,null,6]'
|
|
1300
1556
|
output: ['[null,3,6,8]']
|
|
1557
|
+
|
|
1301
1558
|
- program: 'sort_by(.foo)'
|
|
1302
|
-
input: '[{"foo":4, "bar":10}, {"foo":3, "bar":
|
|
1303
|
-
output: ['[{"foo":2, "bar":1}, {"foo":3, "bar":
|
|
1559
|
+
input: '[{"foo":4, "bar":10}, {"foo":3, "bar":10}, {"foo":2, "bar":1}]'
|
|
1560
|
+
output: ['[{"foo":2, "bar":1}, {"foo":3, "bar":10}, {"foo":4, "bar":10}]']
|
|
1561
|
+
|
|
1562
|
+
- program: 'sort_by(.foo, .bar)'
|
|
1563
|
+
input: '[{"foo":4, "bar":10}, {"foo":3, "bar":20}, {"foo":2, "bar":1}, {"foo":3, "bar":10}]'
|
|
1564
|
+
output: ['[{"foo":2, "bar":1}, {"foo":3, "bar":10}, {"foo":3, "bar":20}, {"foo":4, "bar":10}]']
|
|
1304
1565
|
|
|
1305
1566
|
- title: "`group_by(path_expression)`"
|
|
1306
1567
|
body: |
|
|
@@ -1427,9 +1688,21 @@ sections:
|
|
|
1427
1688
|
- program: 'index(", ")'
|
|
1428
1689
|
input: '"a,b, cd, efg, hijk"'
|
|
1429
1690
|
output: ['3']
|
|
1691
|
+
- program: 'index(1)'
|
|
1692
|
+
input: '[0,1,2,1,3,1,4]'
|
|
1693
|
+
output: ['1']
|
|
1694
|
+
- program: 'index([1,2])'
|
|
1695
|
+
input: '[0,1,2,3,1,4,2,5,1,2,6,7]'
|
|
1696
|
+
output: ['1']
|
|
1430
1697
|
- program: 'rindex(", ")'
|
|
1431
1698
|
input: '"a,b, cd, efg, hijk"'
|
|
1432
1699
|
output: ['12']
|
|
1700
|
+
- program: 'rindex(1)'
|
|
1701
|
+
input: '[0,1,2,1,3,1,4]'
|
|
1702
|
+
output: ['5']
|
|
1703
|
+
- program: 'rindex([1,2])'
|
|
1704
|
+
input: '[0,1,2,3,1,4,2,5,1,2,6,7]'
|
|
1705
|
+
output: ['8']
|
|
1433
1706
|
|
|
1434
1707
|
- title: "`inside`"
|
|
1435
1708
|
body: |
|
|
@@ -1512,6 +1785,25 @@ sections:
|
|
|
1512
1785
|
input: '["fo", "foo", "barfoo", "foobar", "foob"]'
|
|
1513
1786
|
output: ['["fo","","bar","foobar","foob"]']
|
|
1514
1787
|
|
|
1788
|
+
- title: "`trim`, `ltrim`, `rtrim`"
|
|
1789
|
+
body: |
|
|
1790
|
+
|
|
1791
|
+
`trim` trims both leading and trailing whitespace.
|
|
1792
|
+
|
|
1793
|
+
`ltrim` trims only leading (left side) whitespace.
|
|
1794
|
+
|
|
1795
|
+
`rtrim` trims only trailing (right side) whitespace.
|
|
1796
|
+
|
|
1797
|
+
Whitespace characters are the usual `" "`, `"\n"` `"\t"`, `"\r"`
|
|
1798
|
+
and also all characters in the Unicode character database with the
|
|
1799
|
+
whitespace property. Note that what considers whitespace might
|
|
1800
|
+
change in the future.
|
|
1801
|
+
|
|
1802
|
+
examples:
|
|
1803
|
+
- program: 'trim, ltrim, rtrim'
|
|
1804
|
+
input: '" abc "'
|
|
1805
|
+
output: ['"abc"', '"abc "', '" abc"']
|
|
1806
|
+
|
|
1515
1807
|
- title: "`explode`"
|
|
1516
1808
|
body: |
|
|
1517
1809
|
|
|
@@ -1538,6 +1830,9 @@ sections:
|
|
|
1538
1830
|
|
|
1539
1831
|
Splits an input string on the separator argument.
|
|
1540
1832
|
|
|
1833
|
+
`split` can also split on regex matches when called with
|
|
1834
|
+
two arguments (see the regular expressions section below).
|
|
1835
|
+
|
|
1541
1836
|
examples:
|
|
1542
1837
|
- program: 'split(", ")'
|
|
1543
1838
|
input: '"a, b,c,d, e, "'
|
|
@@ -1569,10 +1864,10 @@ sections:
|
|
|
1569
1864
|
Emit a copy of the input string with its alphabetic characters (a-z and A-Z)
|
|
1570
1865
|
converted to the specified case.
|
|
1571
1866
|
|
|
1572
|
-
|
|
1867
|
+
examples:
|
|
1573
1868
|
- program: 'ascii_upcase'
|
|
1574
1869
|
input: '"useful but not for é"'
|
|
1575
|
-
output: '"USEFUL BUT NOT FOR é"'
|
|
1870
|
+
output: ['"USEFUL BUT NOT FOR é"']
|
|
1576
1871
|
|
|
1577
1872
|
- title: "`while(cond; update)`"
|
|
1578
1873
|
body: |
|
|
@@ -1590,6 +1885,22 @@ sections:
|
|
|
1590
1885
|
input: '1'
|
|
1591
1886
|
output: ['[1,2,4,8,16,32,64]']
|
|
1592
1887
|
|
|
1888
|
+
- title: "`repeat(exp)`"
|
|
1889
|
+
body: |
|
|
1890
|
+
|
|
1891
|
+
The `repeat(exp)` function allows you to repeatedly
|
|
1892
|
+
apply expression `exp` to `.` until an error is raised.
|
|
1893
|
+
|
|
1894
|
+
Note that `repeat(exp)` is internally defined as a
|
|
1895
|
+
recursive jq function. Recursive calls within `repeat` will
|
|
1896
|
+
not consume additional memory if `exp` produces at most one
|
|
1897
|
+
output for each input. See advanced topics below.
|
|
1898
|
+
|
|
1899
|
+
examples:
|
|
1900
|
+
- program: '[repeat(.*2, error)?]'
|
|
1901
|
+
input: '1'
|
|
1902
|
+
output: ['[2]']
|
|
1903
|
+
|
|
1593
1904
|
- title: "`until(cond; next)`"
|
|
1594
1905
|
body: |
|
|
1595
1906
|
|
|
@@ -1609,7 +1920,7 @@ sections:
|
|
|
1609
1920
|
output: ['24']
|
|
1610
1921
|
|
|
1611
1922
|
|
|
1612
|
-
- title: "`recurse(f)`, `recurse`, `recurse(f; condition)
|
|
1923
|
+
- title: "`recurse(f)`, `recurse`, `recurse(f; condition)`"
|
|
1613
1924
|
body: |
|
|
1614
1925
|
|
|
1615
1926
|
The `recurse(f)` function allows you to search through a
|
|
@@ -1634,7 +1945,7 @@ sections:
|
|
|
1634
1945
|
When called without an argument, `recurse` is equivalent to
|
|
1635
1946
|
`recurse(.[]?)`.
|
|
1636
1947
|
|
|
1637
|
-
`recurse(f)` is identical to `recurse(f;
|
|
1948
|
+
`recurse(f)` is identical to `recurse(f; true)` and can be
|
|
1638
1949
|
used without concerns about recursion depth.
|
|
1639
1950
|
|
|
1640
1951
|
`recurse(f; condition)` is a generator which begins by
|
|
@@ -1643,10 +1954,6 @@ sections:
|
|
|
1643
1954
|
to generate all the integers, at least in principle, one
|
|
1644
1955
|
could write `recurse(.+1; true)`.
|
|
1645
1956
|
|
|
1646
|
-
For legacy reasons, `recurse_down` exists as an alias to
|
|
1647
|
-
calling `recurse` without arguments. This alias is considered
|
|
1648
|
-
*deprecated* and will be removed in the next major release.
|
|
1649
|
-
|
|
1650
1957
|
The recursive calls in `recurse` will not consume additional
|
|
1651
1958
|
memory whenever `f` produces at most a single output for each
|
|
1652
1959
|
input.
|
|
@@ -1669,11 +1976,8 @@ sections:
|
|
|
1669
1976
|
- '1'
|
|
1670
1977
|
|
|
1671
1978
|
- program: 'recurse(. * .; . < 20)'
|
|
1672
|
-
input: 2
|
|
1673
|
-
output:
|
|
1674
|
-
- 2
|
|
1675
|
-
- 4
|
|
1676
|
-
- 16
|
|
1979
|
+
input: '2'
|
|
1980
|
+
output: ['2', '4', '16']
|
|
1677
1981
|
|
|
1678
1982
|
- title: "`walk(f)`"
|
|
1679
1983
|
body: |
|
|
@@ -1701,6 +2005,32 @@ sections:
|
|
|
1701
2005
|
output:
|
|
1702
2006
|
- '[{"a":{"b":2}}]'
|
|
1703
2007
|
|
|
2008
|
+
- title: "`have_literal_numbers`"
|
|
2009
|
+
body: |
|
|
2010
|
+
|
|
2011
|
+
This builtin returns true if jq's build configuration
|
|
2012
|
+
includes support for preservation of input number literals.
|
|
2013
|
+
|
|
2014
|
+
- title: "`have_decnum`"
|
|
2015
|
+
body: |
|
|
2016
|
+
|
|
2017
|
+
This builtin returns true if jq was built with "decnum",
|
|
2018
|
+
which is the current literal number preserving numeric
|
|
2019
|
+
backend implementation for jq.
|
|
2020
|
+
|
|
2021
|
+
- title: "`$JQ_BUILD_CONFIGURATION`"
|
|
2022
|
+
body: |
|
|
2023
|
+
|
|
2024
|
+
This builtin binding shows the jq executable's build
|
|
2025
|
+
configuration. Its value has no particular format, but
|
|
2026
|
+
it can be expected to be at least the `./configure`
|
|
2027
|
+
command-line arguments, and may be enriched in the
|
|
2028
|
+
future to include the version strings for the build
|
|
2029
|
+
tooling used.
|
|
2030
|
+
|
|
2031
|
+
Note that this can be overridden in the command-line
|
|
2032
|
+
with `--arg` and related options.
|
|
2033
|
+
|
|
1704
2034
|
- title: "`$ENV`, `env`"
|
|
1705
2035
|
body: |
|
|
1706
2036
|
|
|
@@ -1735,13 +2065,13 @@ sections:
|
|
|
1735
2065
|
- title: "`bsearch(x)`"
|
|
1736
2066
|
body: |
|
|
1737
2067
|
|
|
1738
|
-
bsearch(x) conducts a binary search for x in the input
|
|
2068
|
+
`bsearch(x)` conducts a binary search for x in the input
|
|
1739
2069
|
array. If the input is sorted and contains x, then
|
|
1740
|
-
bsearch(x) will return its index in the array; otherwise, if
|
|
2070
|
+
`bsearch(x)` will return its index in the array; otherwise, if
|
|
1741
2071
|
the array is sorted, it will return (-1 - ix) where ix is an
|
|
1742
2072
|
insertion point such that the array would still be sorted
|
|
1743
2073
|
after the insertion of x at ix. If the array is not sorted,
|
|
1744
|
-
bsearch(x) will return an integer that is probably of no
|
|
2074
|
+
`bsearch(x)` will return an integer that is probably of no
|
|
1745
2075
|
interest.
|
|
1746
2076
|
|
|
1747
2077
|
examples:
|
|
@@ -1755,7 +2085,7 @@ sections:
|
|
|
1755
2085
|
input: '[1,2,3]'
|
|
1756
2086
|
output: ['[1,2,3,4]']
|
|
1757
2087
|
|
|
1758
|
-
- title: "String interpolation
|
|
2088
|
+
- title: "String interpolation: `\\(exp)`"
|
|
1759
2089
|
body: |
|
|
1760
2090
|
|
|
1761
2091
|
Inside a string, you can put an expression inside parens
|
|
@@ -1771,9 +2101,9 @@ sections:
|
|
|
1771
2101
|
body: |
|
|
1772
2102
|
|
|
1773
2103
|
The `tojson` and `fromjson` builtins dump values as JSON texts
|
|
1774
|
-
or parse JSON texts into values, respectively. The tojson
|
|
1775
|
-
builtin differs from tostring in that tostring returns strings
|
|
1776
|
-
unmodified, while tojson encodes strings as JSON strings.
|
|
2104
|
+
or parse JSON texts into values, respectively. The `tojson`
|
|
2105
|
+
builtin differs from `tostring` in that `tostring` returns strings
|
|
2106
|
+
unmodified, while `tojson` encodes strings as JSON strings.
|
|
1777
2107
|
|
|
1778
2108
|
examples:
|
|
1779
2109
|
- program: '[.[]|tostring]'
|
|
@@ -1813,6 +2143,11 @@ sections:
|
|
|
1813
2143
|
Applies percent-encoding, by mapping all reserved URI
|
|
1814
2144
|
characters to a `%XX` sequence.
|
|
1815
2145
|
|
|
2146
|
+
* `@urid`:
|
|
2147
|
+
|
|
2148
|
+
The inverse of `@uri`, applies percent-decoding, by mapping
|
|
2149
|
+
all `%XX` sequences to their corresponding URI characters.
|
|
2150
|
+
|
|
1816
2151
|
* `@csv`:
|
|
1817
2152
|
|
|
1818
2153
|
The input must be an array, and it is rendered as CSV
|
|
@@ -1865,10 +2200,6 @@ sections:
|
|
|
1865
2200
|
input: '"This works if x < y"'
|
|
1866
2201
|
output: ['"This works if x < y"']
|
|
1867
2202
|
|
|
1868
|
-
# - program: '@html "<span>Anonymous said: \(.)</span>"'
|
|
1869
|
-
# input: '"<script>alert(\"lol hax\");</script>"'
|
|
1870
|
-
# output: ["<span>Anonymous said: <script>alert("lol hax");</script></span>"]
|
|
1871
|
-
|
|
1872
2203
|
- program: '@sh "echo \(.)"'
|
|
1873
2204
|
input: "\"O'Hara's Ale\""
|
|
1874
2205
|
output: ["\"echo 'O'\\\\''Hara'\\\\''s Ale'\""]
|
|
@@ -1913,7 +2244,7 @@ sections:
|
|
|
1913
2244
|
|
|
1914
2245
|
The `gmtime` builtin consumes a number of seconds since the
|
|
1915
2246
|
Unix epoch and outputs a "broken down time" representation of
|
|
1916
|
-
|
|
2247
|
+
Greenwich Mean Time as an array of numbers representing
|
|
1917
2248
|
(in this order): the year, the month (zero-based), the day of
|
|
1918
2249
|
the month (one-based), the hour of the day, the minute of the
|
|
1919
2250
|
hour, the second of the minute, the day of the week, and the
|
|
@@ -1929,7 +2260,7 @@ sections:
|
|
|
1929
2260
|
|
|
1930
2261
|
The `strptime(fmt)` builtin parses input strings matching the
|
|
1931
2262
|
`fmt` argument. The output is in the "broken down time"
|
|
1932
|
-
representation consumed by `
|
|
2263
|
+
representation consumed by `mktime` and output by `gmtime`.
|
|
1933
2264
|
|
|
1934
2265
|
The `strftime(fmt)` builtin formats a time (GMT) with the
|
|
1935
2266
|
given format. The `strflocaltime` does the same, but using
|
|
@@ -1961,40 +2292,40 @@ sections:
|
|
|
1961
2292
|
|
|
1962
2293
|
jq provides a few SQL-style operators.
|
|
1963
2294
|
|
|
1964
|
-
|
|
2295
|
+
* INDEX(stream; index_expression):
|
|
1965
2296
|
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
2297
|
+
This builtin produces an object whose keys are computed by
|
|
2298
|
+
the given index expression applied to each value from the
|
|
2299
|
+
given stream.
|
|
1969
2300
|
|
|
1970
|
-
|
|
2301
|
+
* JOIN($idx; stream; idx_expr; join_expr):
|
|
1971
2302
|
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
2303
|
+
This builtin joins the values from the given stream to the
|
|
2304
|
+
given index. The index's keys are computed by applying the
|
|
2305
|
+
given index expression to each value from the given stream.
|
|
2306
|
+
An array of the value in the stream and the corresponding
|
|
2307
|
+
value from the index is fed to the given join expression to
|
|
2308
|
+
produce each result.
|
|
1978
2309
|
|
|
1979
|
-
|
|
2310
|
+
* JOIN($idx; stream; idx_expr):
|
|
1980
2311
|
|
|
1981
|
-
|
|
2312
|
+
Same as `JOIN($idx; stream; idx_expr; .)`.
|
|
1982
2313
|
|
|
1983
|
-
|
|
2314
|
+
* JOIN($idx; idx_expr):
|
|
1984
2315
|
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
2316
|
+
This builtin joins the input `.` to the given index, applying
|
|
2317
|
+
the given index expression to `.` to compute the index key.
|
|
2318
|
+
The join operation is as described above.
|
|
1988
2319
|
|
|
1989
|
-
|
|
2320
|
+
* IN(s):
|
|
1990
2321
|
|
|
1991
|
-
|
|
1992
|
-
|
|
2322
|
+
This builtin outputs `true` if `.` appears in the given
|
|
2323
|
+
stream, otherwise it outputs `false`.
|
|
1993
2324
|
|
|
1994
|
-
|
|
2325
|
+
* IN(source; s):
|
|
1995
2326
|
|
|
1996
|
-
|
|
1997
|
-
|
|
2327
|
+
This builtin outputs `true` if any value in the source stream
|
|
2328
|
+
appears in the second stream, otherwise it outputs `false`.
|
|
1998
2329
|
|
|
1999
2330
|
- title: "`builtins`"
|
|
2000
2331
|
body: |
|
|
@@ -2009,34 +2340,45 @@ sections:
|
|
|
2009
2340
|
- title: "`==`, `!=`"
|
|
2010
2341
|
body: |
|
|
2011
2342
|
|
|
2012
|
-
The expression 'a == b' will produce 'true' if the
|
|
2013
|
-
are equal (that is, if they represent equivalent JSON
|
|
2343
|
+
The expression 'a == b' will produce 'true' if the results of evaluating
|
|
2344
|
+
a and b are equal (that is, if they represent equivalent JSON values) and
|
|
2014
2345
|
'false' otherwise. In particular, strings are never considered equal
|
|
2015
|
-
to numbers.
|
|
2016
|
-
|
|
2017
|
-
|
|
2346
|
+
to numbers. In checking for the equality of JSON objects, the ordering of keys
|
|
2347
|
+
is irrelevant. If you're coming from JavaScript, please note that jq's `==` is like
|
|
2348
|
+
JavaScript's `===`, the "strict equality" operator.
|
|
2018
2349
|
|
|
2019
2350
|
!= is "not equal", and 'a != b' returns the opposite value of 'a == b'
|
|
2020
2351
|
|
|
2021
2352
|
examples:
|
|
2353
|
+
- program: '. == false'
|
|
2354
|
+
input: 'null'
|
|
2355
|
+
output: ['false']
|
|
2356
|
+
|
|
2357
|
+
- program: '. == {"b": {"d": (4 + 1e-20), "c": 3}, "a":1}'
|
|
2358
|
+
input: '{"a":1, "b": {"c": 3, "d": 4}}'
|
|
2359
|
+
output: ['true']
|
|
2360
|
+
|
|
2022
2361
|
- program: '.[] == 1'
|
|
2023
2362
|
input: '[1, 1.0, "1", "banana"]'
|
|
2024
2363
|
output: ['true', 'true', 'false', 'false']
|
|
2025
2364
|
|
|
2026
|
-
- title: if-then-else
|
|
2365
|
+
- title: if-then-else-end
|
|
2027
2366
|
body: |
|
|
2028
2367
|
|
|
2029
2368
|
`if A then B else C end` will act the same as `B` if `A`
|
|
2030
2369
|
produces a value other than false or null, but act the same
|
|
2031
2370
|
as `C` otherwise.
|
|
2032
2371
|
|
|
2372
|
+
`if A then B end` is the same as `if A then B else . end`.
|
|
2373
|
+
That is, the `else` branch is optional, and if absent is the
|
|
2374
|
+
same as `.`. This also applies to `elif` with absent ending `else` branch.
|
|
2375
|
+
|
|
2033
2376
|
Checking for false or null is a simpler notion of
|
|
2034
|
-
"truthiness" than is found in
|
|
2377
|
+
"truthiness" than is found in JavaScript or Python, but it
|
|
2035
2378
|
means that you'll sometimes have to be more explicit about
|
|
2036
|
-
the condition you want
|
|
2037
|
-
string is empty using `if .name then A else B end
|
|
2038
|
-
need something
|
|
2039
|
-
B end` instead.
|
|
2379
|
+
the condition you want. You can't test whether, e.g. a
|
|
2380
|
+
string is empty using `if .name then A else B end`; you'll
|
|
2381
|
+
need something like `if .name == "" then A else B end` instead.
|
|
2040
2382
|
|
|
2041
2383
|
If the condition `A` produces multiple results, then `B` is evaluated
|
|
2042
2384
|
once for each result that is not false or null, and `C` is evaluated
|
|
@@ -2053,10 +2395,10 @@ sections:
|
|
|
2053
2395
|
else
|
|
2054
2396
|
"many"
|
|
2055
2397
|
end
|
|
2056
|
-
input: 2
|
|
2398
|
+
input: '2'
|
|
2057
2399
|
output: ['"many"']
|
|
2058
2400
|
|
|
2059
|
-
- title: "
|
|
2401
|
+
- title: "`>`, `>=`, `<=`, `<`"
|
|
2060
2402
|
body: |
|
|
2061
2403
|
|
|
2062
2404
|
The comparison operators `>`, `>=`, `<=`, `<` return whether
|
|
@@ -2068,15 +2410,16 @@ sections:
|
|
|
2068
2410
|
|
|
2069
2411
|
examples:
|
|
2070
2412
|
- program: '. < 5'
|
|
2071
|
-
input: 2
|
|
2413
|
+
input: '2'
|
|
2072
2414
|
output: ['true']
|
|
2073
2415
|
|
|
2074
|
-
- title: and
|
|
2416
|
+
- title: "`and`, `or`, `not`"
|
|
2075
2417
|
body: |
|
|
2076
2418
|
|
|
2077
|
-
jq supports the normal Boolean operators and
|
|
2078
|
-
same standard of truth as if expressions -
|
|
2079
|
-
considered "false values", and
|
|
2419
|
+
jq supports the normal Boolean operators `and`, `or`, `not`.
|
|
2420
|
+
They have the same standard of truth as if expressions -
|
|
2421
|
+
`false` and `null` are considered "false values", and
|
|
2422
|
+
anything else is a "true value".
|
|
2080
2423
|
|
|
2081
2424
|
If an operand of one of these operators produces multiple
|
|
2082
2425
|
results, the operator itself will produce a result for each input.
|
|
@@ -2086,12 +2429,12 @@ sections:
|
|
|
2086
2429
|
rather than with special syntax, as in `.foo and .bar |
|
|
2087
2430
|
not`.
|
|
2088
2431
|
|
|
2089
|
-
These three only produce the values
|
|
2432
|
+
These three only produce the values `true` and `false`, and
|
|
2090
2433
|
so are only useful for genuine Boolean operations, rather
|
|
2091
2434
|
than the common Perl/Python/Ruby idiom of
|
|
2092
2435
|
"value_that_may_be_null or default". If you want to use this
|
|
2093
2436
|
form of "or", picking between two values rather than
|
|
2094
|
-
evaluating a condition, see the
|
|
2437
|
+
evaluating a condition, see the `//` operator below.
|
|
2095
2438
|
|
|
2096
2439
|
examples:
|
|
2097
2440
|
- program: '42 and "a string"'
|
|
@@ -2100,9 +2443,6 @@ sections:
|
|
|
2100
2443
|
- program: '(true, false) or false'
|
|
2101
2444
|
input: 'null'
|
|
2102
2445
|
output: ['true', 'false']
|
|
2103
|
-
# - program: '(true, false) and (true, false)'
|
|
2104
|
-
# input: 'null'
|
|
2105
|
-
# output: ['true', 'false', 'false', 'false']
|
|
2106
2446
|
- program: '(true, true) and (true, false)'
|
|
2107
2447
|
input: 'null'
|
|
2108
2448
|
output: ['true', 'false', 'true', 'false']
|
|
@@ -2113,9 +2453,16 @@ sections:
|
|
|
2113
2453
|
- title: "Alternative operator: `//`"
|
|
2114
2454
|
body: |
|
|
2115
2455
|
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2456
|
+
The `//` operator produces all the values of its left-hand
|
|
2457
|
+
side that are neither `false` nor `null`. If the
|
|
2458
|
+
left-hand side produces no values other than `false` or
|
|
2459
|
+
`null`, then `//` produces all the values of its right-hand
|
|
2460
|
+
side.
|
|
2461
|
+
|
|
2462
|
+
A filter of the form `a // b` produces all the results of
|
|
2463
|
+
`a` that are not `false` or `null`. If `a` produces no
|
|
2464
|
+
results, or no results other than `false` or `null`, then `a
|
|
2465
|
+
// b` produces the results of `b`.
|
|
2119
2466
|
|
|
2120
2467
|
This is useful for providing defaults: `.foo // 1` will
|
|
2121
2468
|
evaluate to `1` if there's no `.foo` element in the
|
|
@@ -2123,13 +2470,36 @@ sections:
|
|
|
2123
2470
|
(jq's `or` operator is reserved for strictly Boolean
|
|
2124
2471
|
operations).
|
|
2125
2472
|
|
|
2126
|
-
|
|
2473
|
+
Note: `some_generator // defaults_here` is not the same
|
|
2474
|
+
as `some_generator | . // defaults_here`. The latter will
|
|
2475
|
+
produce default values for all non-`false`, non-`null`
|
|
2476
|
+
values of the left-hand side, while the former will not.
|
|
2477
|
+
Precedence rules can make this confusing. For example, in
|
|
2478
|
+
`false, 1 // 2` the left-hand side of `//` is `1`, not
|
|
2479
|
+
`false, 1` -- `false, 1 // 2` parses the same way as `false,
|
|
2480
|
+
(1 // 2)`. In `(false, null, 1) | . // 42` the left-hand
|
|
2481
|
+
side of `//` is `.`, which always produces just one value,
|
|
2482
|
+
while in `(false, null, 1) // 42` the left-hand side is a
|
|
2483
|
+
generator of three values, and since it produces a
|
|
2484
|
+
value other `false` and `null`, the default `42` is not
|
|
2485
|
+
produced.
|
|
2486
|
+
|
|
2487
|
+
examples:
|
|
2488
|
+
- program: 'empty // 42'
|
|
2489
|
+
input: 'null'
|
|
2490
|
+
output: ['42']
|
|
2127
2491
|
- program: '.foo // 42'
|
|
2128
2492
|
input: '{"foo": 19}'
|
|
2129
|
-
output: [19]
|
|
2493
|
+
output: ['19']
|
|
2130
2494
|
- program: '.foo // 42'
|
|
2131
2495
|
input: '{}'
|
|
2132
|
-
output: [42]
|
|
2496
|
+
output: ['42']
|
|
2497
|
+
- program: '(false, null, 1) // 42'
|
|
2498
|
+
input: 'null'
|
|
2499
|
+
output: ['1']
|
|
2500
|
+
- program: '(false, null, 1) | . // 42'
|
|
2501
|
+
input: 'null'
|
|
2502
|
+
output: ['42', '42', '1']
|
|
2133
2503
|
|
|
2134
2504
|
- title: try-catch
|
|
2135
2505
|
body: |
|
|
@@ -2164,14 +2534,14 @@ sections:
|
|
|
2164
2534
|
# Repeat an expression until it raises "break" as an
|
|
2165
2535
|
# error, then stop repeating without re-raising the error.
|
|
2166
2536
|
# But if the error caught is not "break" then re-raise it.
|
|
2167
|
-
try repeat(exp) catch .=="break" then empty else error
|
|
2537
|
+
try repeat(exp) catch if .=="break" then empty else error
|
|
2168
2538
|
|
|
2169
2539
|
jq has a syntax for named lexical labels to "break" or "go (back) to":
|
|
2170
2540
|
|
|
2171
2541
|
label $out | ... break $out ...
|
|
2172
2542
|
|
|
2173
2543
|
The `break $label_name` expression will cause the program to
|
|
2174
|
-
|
|
2544
|
+
act as though the nearest (to the left) `label $label_name`
|
|
2175
2545
|
produced `empty`.
|
|
2176
2546
|
|
|
2177
2547
|
The relationship between the `break` and corresponding `label`
|
|
@@ -2193,51 +2563,62 @@ sections:
|
|
|
2193
2563
|
The `?` operator, used as `EXP?`, is shorthand for `try EXP`.
|
|
2194
2564
|
|
|
2195
2565
|
examples:
|
|
2196
|
-
- program: '[.[]|
|
|
2566
|
+
- program: '[.[] | .a?]'
|
|
2197
2567
|
input: '[{}, true, {"a":1}]'
|
|
2198
2568
|
output: ['[null, 1]']
|
|
2569
|
+
- program: '[.[] | tonumber?]'
|
|
2570
|
+
input: '["1", "invalid", "3", 4]'
|
|
2571
|
+
output: ['[1, 3, 4]']
|
|
2199
2572
|
|
|
2200
|
-
|
|
2201
|
-
- title: Regular expressions (PCRE)
|
|
2573
|
+
- title: Regular expressions
|
|
2202
2574
|
body: |
|
|
2203
2575
|
|
|
2204
|
-
jq uses the
|
|
2205
|
-
|
|
2206
|
-
|
|
2576
|
+
jq uses the
|
|
2577
|
+
[Oniguruma regular expression library](https://github.com/kkos/oniguruma/blob/master/doc/RE),
|
|
2578
|
+
as do PHP, TextMate, Sublime Text, etc, so the
|
|
2579
|
+
description here will focus on jq specifics.
|
|
2580
|
+
|
|
2581
|
+
Oniguruma supports several flavors of regular expression, so it is important to know
|
|
2582
|
+
that jq uses the ["Perl NG" (Perl with named groups)](https://github.com/kkos/oniguruma/blob/master/doc/SYNTAX.md) flavor.
|
|
2207
2583
|
|
|
2208
2584
|
The jq regex filters are defined so that they can be used using
|
|
2209
2585
|
one of these patterns:
|
|
2210
2586
|
|
|
2211
|
-
STRING | FILTER(
|
|
2212
|
-
STRING | FILTER(
|
|
2213
|
-
STRING | FILTER(
|
|
2214
|
-
STRING | FILTER(
|
|
2587
|
+
STRING | FILTER(REGEX)
|
|
2588
|
+
STRING | FILTER(REGEX; FLAGS)
|
|
2589
|
+
STRING | FILTER([REGEX])
|
|
2590
|
+
STRING | FILTER([REGEX, FLAGS])
|
|
2215
2591
|
|
|
2216
2592
|
where:
|
|
2217
|
-
|
|
2218
|
-
* REGEX,
|
|
2593
|
+
|
|
2594
|
+
* STRING, REGEX, and FLAGS are jq strings and subject to jq string interpolation;
|
|
2595
|
+
* REGEX, after string interpolation, should be a valid regular expression;
|
|
2219
2596
|
* FILTER is one of `test`, `match`, or `capture`, as described below.
|
|
2220
2597
|
|
|
2598
|
+
Since REGEX must evaluate to a JSON string, some characters that are needed
|
|
2599
|
+
to form a regular expression must be escaped. For example, the regular expression
|
|
2600
|
+
`\s` signifying a whitespace character would be written as `"\\s"`.
|
|
2601
|
+
|
|
2221
2602
|
FLAGS is a string consisting of one of more of the supported flags:
|
|
2222
2603
|
|
|
2223
2604
|
* `g` - Global search (find all matches, not just the first)
|
|
2224
2605
|
* `i` - Case insensitive search
|
|
2225
|
-
* `m` - Multi line mode (
|
|
2606
|
+
* `m` - Multi line mode (`.` will match newlines)
|
|
2226
2607
|
* `n` - Ignore empty matches
|
|
2227
2608
|
* `p` - Both s and m modes are enabled
|
|
2228
|
-
* `s` - Single line mode (
|
|
2609
|
+
* `s` - Single line mode (`^` -> `\A`, `$` -> `\Z`)
|
|
2229
2610
|
* `l` - Find longest possible matches
|
|
2230
2611
|
* `x` - Extended regex format (ignore whitespace and comments)
|
|
2231
2612
|
|
|
2232
|
-
To match whitespace
|
|
2613
|
+
To match a whitespace with the `x` flag, use `\s`, e.g.
|
|
2233
2614
|
|
|
2234
|
-
|
|
2615
|
+
jq -n '"a b" | test("a\\sb"; "x")'
|
|
2235
2616
|
|
|
2236
2617
|
Note that certain flags may also be specified within REGEX, e.g.
|
|
2237
2618
|
|
|
2238
|
-
|
|
2619
|
+
jq -n '("test", "TEst", "teST", "TEST") | test("(?i)te(?-i)st")'
|
|
2239
2620
|
|
|
2240
|
-
evaluates to: true
|
|
2621
|
+
evaluates to: `true`, `true`, `false`, `false`.
|
|
2241
2622
|
|
|
2242
2623
|
entries:
|
|
2243
2624
|
- title: "`test(val)`, `test(regex; flags)`"
|
|
@@ -2296,7 +2677,7 @@ sections:
|
|
|
2296
2677
|
|
|
2297
2678
|
- program: '[ match("."; "g")] | length'
|
|
2298
2679
|
input: '"abc"'
|
|
2299
|
-
output: [3]
|
|
2680
|
+
output: ['3']
|
|
2300
2681
|
|
|
2301
2682
|
|
|
2302
2683
|
- title: "`capture(val)`, `capture(regex; flags)`"
|
|
@@ -2320,24 +2701,23 @@ sections:
|
|
|
2320
2701
|
To capture all the matches for each input string, use the idiom
|
|
2321
2702
|
`[ expr ]`, e.g. `[ scan(regex) ]`.
|
|
2322
2703
|
|
|
2323
|
-
|
|
2704
|
+
examples:
|
|
2324
2705
|
- program: 'scan("c")'
|
|
2325
2706
|
input: '"abcdefabc"'
|
|
2326
2707
|
output: ['"c"', '"c"']
|
|
2327
2708
|
|
|
2328
|
-
- program: 'scan("b")'
|
|
2329
|
-
input: ("", "")
|
|
2330
|
-
output: ['[]', '[]']
|
|
2331
|
-
|
|
2332
2709
|
- title: "`split(regex; flags)`"
|
|
2333
2710
|
body: |
|
|
2334
2711
|
|
|
2335
|
-
|
|
2712
|
+
Splits an input string on each regex match.
|
|
2713
|
+
|
|
2714
|
+
For backwards compatibility, when called with a single argument,
|
|
2715
|
+
`split` splits on a string, not a regex.
|
|
2336
2716
|
|
|
2337
|
-
|
|
2717
|
+
examples:
|
|
2338
2718
|
- program: 'split(", *"; null)'
|
|
2339
2719
|
input: '"ab,cd, ef"'
|
|
2340
|
-
output: ['"ab","cd","ef"']
|
|
2720
|
+
output: ['["ab","cd","ef"]']
|
|
2341
2721
|
|
|
2342
2722
|
|
|
2343
2723
|
- title: "`splits(regex)`, `splits(regex; flags)`"
|
|
@@ -2346,37 +2726,47 @@ sections:
|
|
|
2346
2726
|
These provide the same results as their `split` counterparts,
|
|
2347
2727
|
but as a stream instead of an array.
|
|
2348
2728
|
|
|
2349
|
-
|
|
2729
|
+
examples:
|
|
2350
2730
|
- program: 'splits(", *")'
|
|
2351
|
-
input: '
|
|
2352
|
-
output: ['"ab"',
|
|
2731
|
+
input: '"ab,cd, ef, gh"'
|
|
2732
|
+
output: ['"ab"','"cd"','"ef"','"gh"']
|
|
2353
2733
|
|
|
2354
|
-
- title: "`sub(regex; tostring)
|
|
2734
|
+
- title: "`sub(regex; tostring)`, `sub(regex; tostring; flags)`"
|
|
2355
2735
|
body: |
|
|
2356
2736
|
|
|
2357
|
-
Emit the string obtained by replacing the first match of
|
|
2358
|
-
input string with `tostring`, after
|
|
2359
|
-
be a jq string
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2737
|
+
Emit the string obtained by replacing the first match of
|
|
2738
|
+
regex in the input string with `tostring`, after
|
|
2739
|
+
interpolation. `tostring` should be a jq string or a stream
|
|
2740
|
+
of such strings, each of which may contain references to
|
|
2741
|
+
named captures. The named captures are, in effect, presented
|
|
2742
|
+
as a JSON object (as constructed by `capture`) to
|
|
2743
|
+
`tostring`, so a reference to a captured variable named "x"
|
|
2744
|
+
would take the form: `"\(.x)"`.
|
|
2363
2745
|
|
|
2364
|
-
|
|
2365
|
-
- program: 'sub("
|
|
2366
|
-
input: '"
|
|
2367
|
-
output: '"
|
|
2746
|
+
examples:
|
|
2747
|
+
- program: 'sub("[^a-z]*(?<x>[a-z]+)"; "Z\(.x)"; "g")'
|
|
2748
|
+
input: '"123abc456def"'
|
|
2749
|
+
output: ['"ZabcZdef"']
|
|
2368
2750
|
|
|
2751
|
+
- program: '[sub("(?<a>.)"; "\(.a|ascii_upcase)", "\(.a|ascii_downcase)")]'
|
|
2752
|
+
input: '"aB"'
|
|
2753
|
+
output: ['["AB","aB"]']
|
|
2369
2754
|
|
|
2370
|
-
- title: "`gsub(regex;
|
|
2755
|
+
- title: "`gsub(regex; tostring)`, `gsub(regex; tostring; flags)`"
|
|
2371
2756
|
body: |
|
|
2372
2757
|
|
|
2373
2758
|
`gsub` is like `sub` but all the non-overlapping occurrences of the regex are
|
|
2374
|
-
replaced by
|
|
2759
|
+
replaced by `tostring`, after interpolation. If the second argument is a stream
|
|
2760
|
+
of jq strings, then `gsub` will produce a corresponding stream of JSON strings.
|
|
2375
2761
|
|
|
2376
|
-
|
|
2762
|
+
examples:
|
|
2377
2763
|
- program: 'gsub("(?<x>.)[^a]*"; "+\(.x)-")'
|
|
2378
2764
|
input: '"Abcabc"'
|
|
2379
|
-
output: '"+A-+a-"'
|
|
2765
|
+
output: ['"+A-+a-"']
|
|
2766
|
+
|
|
2767
|
+
- program: '[gsub("p"; "a", "b")]'
|
|
2768
|
+
input: '"p"'
|
|
2769
|
+
output: ['["a","b"]']
|
|
2380
2770
|
|
|
2381
2771
|
|
|
2382
2772
|
- title: Advanced features
|
|
@@ -2393,7 +2783,7 @@ sections:
|
|
|
2393
2783
|
|
|
2394
2784
|
It is also possible to define functions in jq, although this is
|
|
2395
2785
|
is a feature whose biggest use is defining jq's standard library
|
|
2396
|
-
(many jq functions such as `map` and `
|
|
2786
|
+
(many jq functions such as `map` and `select` are in fact written
|
|
2397
2787
|
in jq).
|
|
2398
2788
|
|
|
2399
2789
|
jq has reduction operators, which are very powerful but a bit
|
|
@@ -2443,7 +2833,7 @@ sections:
|
|
|
2443
2833
|
fields, and another object which is used to map author usernames to
|
|
2444
2834
|
real names. Our input looks like:
|
|
2445
2835
|
|
|
2446
|
-
{"posts": [{"title": "
|
|
2836
|
+
{"posts": [{"title": "First post", "author": "anon"},
|
|
2447
2837
|
{"title": "A well-written article", "author": "person1"}],
|
|
2448
2838
|
"realnames": {"anon": "Anonymous Coward",
|
|
2449
2839
|
"person1": "Person McPherson"}}
|
|
@@ -2451,7 +2841,7 @@ sections:
|
|
|
2451
2841
|
We want to produce the posts with the author field containing a real
|
|
2452
2842
|
name, as in:
|
|
2453
2843
|
|
|
2454
|
-
{"title": "
|
|
2844
|
+
{"title": "First post", "author": "Anonymous Coward"}
|
|
2455
2845
|
{"title": "A well-written article", "author": "Person McPherson"}
|
|
2456
2846
|
|
|
2457
2847
|
We use a variable, $names, to store the realnames object, so that we
|
|
@@ -2465,7 +2855,7 @@ sections:
|
|
|
2465
2855
|
foreach loop.
|
|
2466
2856
|
|
|
2467
2857
|
Just as `{foo}` is a handy way of writing `{foo: .foo}`, so
|
|
2468
|
-
`{$foo}` is a handy way of writing `{foo
|
|
2858
|
+
`{$foo}` is a handy way of writing `{foo: $foo}`.
|
|
2469
2859
|
|
|
2470
2860
|
Multiple variables may be declared using a single `as` expression by
|
|
2471
2861
|
providing a pattern that matches the structure of the input
|
|
@@ -2512,7 +2902,7 @@ sections:
|
|
|
2512
2902
|
|
|
2513
2903
|
- title: 'Destructuring Alternative Operator: `?//`'
|
|
2514
2904
|
body: |
|
|
2515
|
-
|
|
2905
|
+
|
|
2516
2906
|
The destructuring alternative operator provides a concise mechanism
|
|
2517
2907
|
for destructuring an input that can take one of several forms.
|
|
2518
2908
|
|
|
@@ -2521,10 +2911,10 @@ sections:
|
|
|
2521
2911
|
the first event for each resource. The API (having been clumsily
|
|
2522
2912
|
converted from XML) will only wrap the events in an array if the resource
|
|
2523
2913
|
has multiple events:
|
|
2524
|
-
|
|
2914
|
+
|
|
2525
2915
|
{"resources": [{"id": 1, "kind": "widget", "events": {"action": "create", "user_id": 1, "ts": 13}},
|
|
2526
2916
|
{"id": 2, "kind": "widget", "events": [{"action": "create", "user_id": 1, "ts": 14}, {"action": "destroy", "user_id": 1, "ts": 15}]}]}
|
|
2527
|
-
|
|
2917
|
+
|
|
2528
2918
|
We can use the destructuring alternative operator to handle this structural change simply:
|
|
2529
2919
|
|
|
2530
2920
|
.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}
|
|
@@ -2626,34 +3016,11 @@ sections:
|
|
|
2626
3016
|
|
|
2627
3017
|
For example, in the following expression there is a binding
|
|
2628
3018
|
which is visible "to the right" of it, `... | .*3 as
|
|
2629
|
-
$times_three | [.
|
|
3019
|
+
$times_three | [. + $times_three] | ...`, but not "to the
|
|
2630
3020
|
left". Consider this expression now, `... | (.*3 as
|
|
2631
|
-
$times_three | [
|
|
3021
|
+
$times_three | [. + $times_three]) | ...`: here the binding
|
|
2632
3022
|
`$times_three` is _not_ visible past the closing parenthesis.
|
|
2633
3023
|
|
|
2634
|
-
- title: Reduce
|
|
2635
|
-
body: |
|
|
2636
|
-
|
|
2637
|
-
The `reduce` syntax in jq allows you to combine all of the
|
|
2638
|
-
results of an expression by accumulating them into a single
|
|
2639
|
-
answer. As an example, we'll pass `[3,2,1]` to this expression:
|
|
2640
|
-
|
|
2641
|
-
reduce .[] as $item (0; . + $item)
|
|
2642
|
-
|
|
2643
|
-
For each result that `.[]` produces, `. + $item` is run to
|
|
2644
|
-
accumulate a running total, starting from 0. In this
|
|
2645
|
-
example, `.[]` produces the results 3, 2, and 1, so the
|
|
2646
|
-
effect is similar to running something like this:
|
|
2647
|
-
|
|
2648
|
-
0 | (3 as $item | . + $item) |
|
|
2649
|
-
(2 as $item | . + $item) |
|
|
2650
|
-
(1 as $item | . + $item)
|
|
2651
|
-
|
|
2652
|
-
examples:
|
|
2653
|
-
- program: 'reduce .[] as $item (0; . + $item)'
|
|
2654
|
-
input: '[10,2,5,3]'
|
|
2655
|
-
output: ['20']
|
|
2656
|
-
|
|
2657
3024
|
- title: "`isempty(exp)`"
|
|
2658
3025
|
body: |
|
|
2659
3026
|
|
|
@@ -2664,31 +3031,50 @@ sections:
|
|
|
2664
3031
|
input: 'null'
|
|
2665
3032
|
output: ['true']
|
|
2666
3033
|
|
|
2667
|
-
|
|
3034
|
+
- program: 'isempty(.[])'
|
|
3035
|
+
input: '[]'
|
|
3036
|
+
output: ['true']
|
|
3037
|
+
|
|
3038
|
+
- program: 'isempty(.[])'
|
|
3039
|
+
input: '[1,2,3]'
|
|
3040
|
+
output: ['false']
|
|
3041
|
+
|
|
3042
|
+
- title: "`limit(n; expr)`"
|
|
2668
3043
|
body: |
|
|
2669
3044
|
|
|
2670
|
-
The `limit` function extracts up to `n` outputs from `
|
|
3045
|
+
The `limit` function extracts up to `n` outputs from `expr`.
|
|
2671
3046
|
|
|
2672
3047
|
examples:
|
|
2673
|
-
- program: '[limit(3
|
|
3048
|
+
- program: '[limit(3; .[])]'
|
|
2674
3049
|
input: '[0,1,2,3,4,5,6,7,8,9]'
|
|
2675
3050
|
output: ['[0,1,2]']
|
|
2676
3051
|
|
|
3052
|
+
- title: "`skip(n; expr)`"
|
|
3053
|
+
body: |
|
|
3054
|
+
|
|
3055
|
+
The `skip` function skips the first `n` outputs from `expr`.
|
|
3056
|
+
|
|
3057
|
+
examples:
|
|
3058
|
+
- program: '[skip(3; .[])]'
|
|
3059
|
+
input: '[0,1,2,3,4,5,6,7,8,9]'
|
|
3060
|
+
output: ['[3,4,5,6,7,8,9]']
|
|
3061
|
+
|
|
2677
3062
|
- title: "`first(expr)`, `last(expr)`, `nth(n; expr)`"
|
|
2678
3063
|
body: |
|
|
2679
3064
|
|
|
2680
3065
|
The `first(expr)` and `last(expr)` functions extract the first
|
|
2681
3066
|
and last values from `expr`, respectively.
|
|
2682
3067
|
|
|
2683
|
-
The `nth(n; expr)` function extracts the nth value output by
|
|
2684
|
-
|
|
2685
|
-
last(limit(n + 1; expr));`. Note that `nth(n; expr)` doesn't
|
|
2686
|
-
support negative values of `n`.
|
|
3068
|
+
The `nth(n; expr)` function extracts the nth value output by `expr`.
|
|
3069
|
+
Note that `nth(n; expr)` doesn't support negative values of `n`.
|
|
2687
3070
|
|
|
2688
3071
|
examples:
|
|
2689
|
-
- program: '[first(range(.)), last(range(.)), nth(
|
|
3072
|
+
- program: '[first(range(.)), last(range(.)), nth(5; range(.))]'
|
|
2690
3073
|
input: '10'
|
|
2691
3074
|
output: ['[0,9,5]']
|
|
3075
|
+
- program: '[first(empty), last(empty), nth(5; empty)]'
|
|
3076
|
+
input: 'null'
|
|
3077
|
+
output: ['[]']
|
|
2692
3078
|
|
|
2693
3079
|
- title: "`first`, `last`, `nth(n)`"
|
|
2694
3080
|
body: |
|
|
@@ -2703,32 +3089,79 @@ sections:
|
|
|
2703
3089
|
input: '10'
|
|
2704
3090
|
output: ['[0,9,5]']
|
|
2705
3091
|
|
|
3092
|
+
- title: "`reduce`"
|
|
3093
|
+
body: |
|
|
3094
|
+
|
|
3095
|
+
The `reduce` syntax allows you to combine all of the results of
|
|
3096
|
+
an expression by accumulating them into a single answer.
|
|
3097
|
+
The form is `reduce EXP as $var (INIT; UPDATE)`.
|
|
3098
|
+
As an example, we'll pass `[1,2,3]` to this expression:
|
|
3099
|
+
|
|
3100
|
+
reduce .[] as $item (0; . + $item)
|
|
3101
|
+
|
|
3102
|
+
For each result that `.[]` produces, `. + $item` is run to
|
|
3103
|
+
accumulate a running total, starting from 0 as the input value.
|
|
3104
|
+
In this example, `.[]` produces the results `1`, `2`, and `3`,
|
|
3105
|
+
so the effect is similar to running something like this:
|
|
3106
|
+
|
|
3107
|
+
0 | 1 as $item | . + $item |
|
|
3108
|
+
2 as $item | . + $item |
|
|
3109
|
+
3 as $item | . + $item
|
|
3110
|
+
|
|
3111
|
+
examples:
|
|
3112
|
+
- program: 'reduce .[] as $item (0; . + $item)'
|
|
3113
|
+
input: '[1,2,3,4,5]'
|
|
3114
|
+
output: ['15']
|
|
3115
|
+
|
|
3116
|
+
- program: 'reduce .[] as [$i,$j] (0; . + $i * $j)'
|
|
3117
|
+
input: '[[1,2],[3,4],[5,6]]'
|
|
3118
|
+
output: ['44']
|
|
3119
|
+
|
|
3120
|
+
- program: 'reduce .[] as {$x,$y} (null; .x += $x | .y += [$y])'
|
|
3121
|
+
input: '[{"x":"a","y":1},{"x":"b","y":2},{"x":"c","y":3}]'
|
|
3122
|
+
output: ['{"x":"abc","y":[1,2,3]}']
|
|
3123
|
+
|
|
2706
3124
|
- title: "`foreach`"
|
|
2707
3125
|
body: |
|
|
2708
3126
|
|
|
2709
3127
|
The `foreach` syntax is similar to `reduce`, but intended to
|
|
2710
3128
|
allow the construction of `limit` and reducers that produce
|
|
2711
|
-
intermediate results
|
|
3129
|
+
intermediate results.
|
|
2712
3130
|
|
|
2713
3131
|
The form is `foreach EXP as $var (INIT; UPDATE; EXTRACT)`.
|
|
2714
|
-
|
|
2715
|
-
value, then each output of `EXP` is bound to `$var`, `UPDATE`
|
|
2716
|
-
is evaluated for each output of `EXP` with the current state
|
|
2717
|
-
and with `$var` visible. Each value output by `UPDATE`
|
|
2718
|
-
replaces the previous state. Finally, `EXTRACT` is evaluated
|
|
2719
|
-
for each new state to extract an output of `foreach`.
|
|
3132
|
+
As an example, we'll pass `[1,2,3]` to this expression:
|
|
2720
3133
|
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
3134
|
+
foreach .[] as $item (0; . + $item; [$item, . * 2])
|
|
3135
|
+
|
|
3136
|
+
Like the `reduce` syntax, `. + $item` is run for each result
|
|
3137
|
+
that `.[]` produces, but `[$item, . * 2]` is run for each
|
|
3138
|
+
intermediate values. In this example, since the intermediate
|
|
3139
|
+
values are `1`, `3`, and `6`, the `foreach` expression produces
|
|
3140
|
+
`[1,2]`, `[2,6]`, and `[3,12]`. So the effect is similar
|
|
3141
|
+
to running something like this:
|
|
3142
|
+
|
|
3143
|
+
0 | 1 as $item | . + $item | [$item, . * 2],
|
|
3144
|
+
2 as $item | . + $item | [$item, . * 2],
|
|
3145
|
+
3 as $item | . + $item | [$item, . * 2]
|
|
3146
|
+
|
|
3147
|
+
When `EXTRACT` is omitted, the identity filter is used.
|
|
3148
|
+
That is, it outputs the intermediate values as they are.
|
|
2724
3149
|
|
|
2725
3150
|
examples:
|
|
2726
|
-
- program: '
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
3151
|
+
- program: 'foreach .[] as $item (0; . + $item)'
|
|
3152
|
+
input: '[1,2,3,4,5]'
|
|
3153
|
+
output: ['1','3','6','10','15']
|
|
3154
|
+
|
|
3155
|
+
- program: 'foreach .[] as $item (0; . + $item; [$item, . * 2])'
|
|
3156
|
+
input: '[1,2,3,4,5]'
|
|
3157
|
+
output: ['[1,2]','[2,6]','[3,12]','[4,20]','[5,30]']
|
|
3158
|
+
|
|
3159
|
+
- program: 'foreach .[] as $item (0; . + 1; {index: ., $item})'
|
|
3160
|
+
input: '["foo", "bar", "baz"]'
|
|
3161
|
+
output:
|
|
3162
|
+
- '{"index":1,"item":"foo"}'
|
|
3163
|
+
- '{"index":2,"item":"bar"}'
|
|
3164
|
+
- '{"index":3,"item":"baz"}'
|
|
2732
3165
|
|
|
2733
3166
|
- title: Recursion
|
|
2734
3167
|
body: |
|
|
@@ -2767,19 +3200,19 @@ sections:
|
|
|
2767
3200
|
array or an object), `range(0; 10)` generates the integers
|
|
2768
3201
|
between 0 and 10, and so on.
|
|
2769
3202
|
|
|
2770
|
-
Even the comma operator is a generator, generating first
|
|
2771
|
-
values generated by the expression to the left of the
|
|
2772
|
-
then
|
|
2773
|
-
|
|
3203
|
+
Even the comma operator is a generator, generating first
|
|
3204
|
+
the values generated by the expression to the left of the
|
|
3205
|
+
comma, then the values generated by the expression on the
|
|
3206
|
+
right of the comma.
|
|
2774
3207
|
|
|
2775
3208
|
The `empty` builtin is the generator that produces zero
|
|
2776
3209
|
outputs. The `empty` builtin backtracks to the preceding
|
|
2777
3210
|
generator expression.
|
|
2778
3211
|
|
|
2779
3212
|
All jq functions can be generators just by using builtin
|
|
2780
|
-
generators. It is also possible to
|
|
2781
|
-
using only recursion and the comma operator. If
|
|
2782
|
-
recursive
|
|
3213
|
+
generators. It is also possible to construct new generators
|
|
3214
|
+
using only recursion and the comma operator. If
|
|
3215
|
+
recursive calls are "in tail position" then the
|
|
2783
3216
|
generator will be efficient. In the example below the
|
|
2784
3217
|
recursive call by `_range` to itself is in tail position.
|
|
2785
3218
|
The example shows off three advanced topics: tail recursion,
|
|
@@ -2827,7 +3260,7 @@ sections:
|
|
|
2827
3260
|
One-input C math functions: `acos` `acosh` `asin` `asinh` `atan`
|
|
2828
3261
|
`atanh` `cbrt` `ceil` `cos` `cosh` `erf` `erfc` `exp` `exp10`
|
|
2829
3262
|
`exp2` `expm1` `fabs` `floor` `gamma` `j0` `j1` `lgamma` `log`
|
|
2830
|
-
`log10` `log1p` `log2` `logb` `nearbyint` `
|
|
3263
|
+
`log10` `log1p` `log2` `logb` `nearbyint` `rint` `round`
|
|
2831
3264
|
`significand` `sin` `sinh` `sqrt` `tan` `tanh` `tgamma` `trunc`
|
|
2832
3265
|
`y0` `y1`.
|
|
2833
3266
|
|
|
@@ -2847,11 +3280,13 @@ sections:
|
|
|
2847
3280
|
are provided for this, `input` and `inputs`, that read from the
|
|
2848
3281
|
same sources (e.g., `stdin`, files named on the command-line) as
|
|
2849
3282
|
jq itself. These two builtins, and jq's own reading actions, can
|
|
2850
|
-
be interleaved with each other.
|
|
3283
|
+
be interleaved with each other. They are commonly used in combination
|
|
3284
|
+
with the null input option `-n` to prevent one input from being read
|
|
3285
|
+
implicitly.
|
|
2851
3286
|
|
|
2852
3287
|
Two builtins provide minimal output capabilities, `debug`, and
|
|
2853
3288
|
`stderr`. (Recall that a jq program's output values are always
|
|
2854
|
-
output as JSON texts on `stdout`.)
|
|
3289
|
+
output as JSON texts on `stdout`.) The `debug` builtin can have
|
|
2855
3290
|
application-specific behavior, such as for executables that use
|
|
2856
3291
|
the libjq C API but aren't the jq executable itself. The `stderr`
|
|
2857
3292
|
builtin outputs its input in raw mode to stder with no additional
|
|
@@ -2867,21 +3302,50 @@ sections:
|
|
|
2867
3302
|
|
|
2868
3303
|
Outputs one new input.
|
|
2869
3304
|
|
|
3305
|
+
Note that when using `input` it is generally be necessary to
|
|
3306
|
+
invoke jq with the `-n` command-line option, otherwise
|
|
3307
|
+
the first entity will be lost.
|
|
3308
|
+
|
|
3309
|
+
echo 1 2 3 4 | jq '[., input]' # [1,2] [3,4]
|
|
3310
|
+
|
|
2870
3311
|
- title: "`inputs`"
|
|
2871
3312
|
body: |
|
|
2872
3313
|
|
|
2873
3314
|
Outputs all remaining inputs, one by one.
|
|
2874
3315
|
|
|
2875
3316
|
This is primarily useful for reductions over a program's
|
|
2876
|
-
inputs.
|
|
3317
|
+
inputs. Note that when using `inputs` it is generally necessary
|
|
3318
|
+
to invoke jq with the `-n` command-line option, otherwise
|
|
3319
|
+
the first entity will be lost.
|
|
3320
|
+
|
|
3321
|
+
echo 1 2 3 | jq -n 'reduce inputs as $i (0; . + $i)' # 6
|
|
2877
3322
|
|
|
2878
|
-
- title: "`debug`"
|
|
3323
|
+
- title: "`debug`, `debug(msgs)`"
|
|
2879
3324
|
body: |
|
|
2880
3325
|
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
3326
|
+
These two filters are like `.` but have as a side-effect the
|
|
3327
|
+
production of one or more messages on stderr.
|
|
3328
|
+
|
|
3329
|
+
The message produced by the `debug` filter has the form
|
|
3330
|
+
|
|
3331
|
+
["DEBUG:",<input-value>]
|
|
3332
|
+
|
|
3333
|
+
where `<input-value>` is a compact rendition of the input
|
|
3334
|
+
value. This format may change in the future.
|
|
3335
|
+
|
|
3336
|
+
The `debug(msgs)` filter is defined as `(msgs | debug | empty), .`
|
|
3337
|
+
thus allowing great flexibility in the content of the message,
|
|
3338
|
+
while also allowing multi-line debugging statements to be created.
|
|
3339
|
+
|
|
3340
|
+
For example, the expression:
|
|
3341
|
+
|
|
3342
|
+
1 as $x | 2 | debug("Entering function foo with $x == \($x)", .) | (.+1)
|
|
3343
|
+
|
|
3344
|
+
would produce the value 3 but with the following two lines
|
|
3345
|
+
being written to stderr:
|
|
3346
|
+
|
|
3347
|
+
["DEBUG:","Entering function foo with $x == 1"]
|
|
3348
|
+
["DEBUG:",2]
|
|
2885
3349
|
|
|
2886
3350
|
- title: "`stderr`"
|
|
2887
3351
|
body: |
|
|
@@ -2921,8 +3385,8 @@ sections:
|
|
|
2921
3385
|
Streaming forms include `[<path>, <leaf-value>]` (to indicate any
|
|
2922
3386
|
scalar value, empty array, or empty object), and `[<path>]` (to
|
|
2923
3387
|
indicate the end of an array or object). Future versions of jq
|
|
2924
|
-
run with `--stream` and
|
|
2925
|
-
`["error message"]` when an input text fails to parse.
|
|
3388
|
+
run with `--stream` and `--seq` may output additional forms such
|
|
3389
|
+
as `["error message"]` when an input text fails to parse.
|
|
2926
3390
|
|
|
2927
3391
|
entries:
|
|
2928
3392
|
- title: "`truncate_stream(stream_expression)`"
|
|
@@ -2933,9 +3397,9 @@ sections:
|
|
|
2933
3397
|
given streaming expression.
|
|
2934
3398
|
|
|
2935
3399
|
examples:
|
|
2936
|
-
- program: '
|
|
3400
|
+
- program: 'truncate_stream([[0],1],[[1,0],2],[[1,0]],[[1]])'
|
|
2937
3401
|
input: '1'
|
|
2938
|
-
output: ['[[
|
|
3402
|
+
output: ['[[0],2]', '[[0]]']
|
|
2939
3403
|
|
|
2940
3404
|
- title: "`fromstream(stream_expression)`"
|
|
2941
3405
|
body: |
|
|
@@ -2970,7 +3434,7 @@ sections:
|
|
|
2970
3434
|
and you append something to `.foo`, then `.bar` will not get
|
|
2971
3435
|
bigger, even if you've previously set `.bar = .foo`. If you're
|
|
2972
3436
|
used to programming in languages like Python, Java, Ruby,
|
|
2973
|
-
|
|
3437
|
+
JavaScript, etc. then you can think of it as though jq does a full
|
|
2974
3438
|
deep copy of every object before it does the assignment (for
|
|
2975
3439
|
performance it doesn't actually do that, but that's the general
|
|
2976
3440
|
idea).
|
|
@@ -3007,16 +3471,16 @@ sections:
|
|
|
3007
3471
|
entries:
|
|
3008
3472
|
- title: "Update-assignment: `|=`"
|
|
3009
3473
|
body: |
|
|
3010
|
-
This is the "update" operator
|
|
3474
|
+
This is the "update" operator `|=`. It takes a filter on the
|
|
3011
3475
|
right-hand side and works out the new value for the property
|
|
3012
3476
|
of `.` being assigned to by running the old value through this
|
|
3013
|
-
expression. For instance, (.foo, .bar) |= .+1 will build an
|
|
3014
|
-
object with the
|
|
3015
|
-
and the
|
|
3477
|
+
expression. For instance, `(.foo, .bar) |= .+1` will build an
|
|
3478
|
+
object with the `foo` field set to the input's `foo` plus 1,
|
|
3479
|
+
and the `bar` field set to the input's `bar` plus 1.
|
|
3016
3480
|
|
|
3017
3481
|
The left-hand side can be any general path expression; see `path()`.
|
|
3018
3482
|
|
|
3019
|
-
Note that the left-hand side of
|
|
3483
|
+
Note that the left-hand side of `|=` refers to a value in `.`.
|
|
3020
3484
|
Thus `$var.foo |= . + 1` won't work as expected (`$var.foo` is
|
|
3021
3485
|
not a valid or useful path expression in `.`); use `$var |
|
|
3022
3486
|
.foo |= . + 1` instead.
|
|
@@ -3049,41 +3513,52 @@ sections:
|
|
|
3049
3513
|
body: |
|
|
3050
3514
|
|
|
3051
3515
|
This is the plain assignment operator. Unlike the others, the
|
|
3052
|
-
input to the right-hand
|
|
3053
|
-
the left-hand
|
|
3516
|
+
input to the right-hand side (RHS) is the same as the input to
|
|
3517
|
+
the left-hand side (LHS) rather than the value at the LHS
|
|
3054
3518
|
path, and all values output by the RHS will be used (as shown
|
|
3055
3519
|
below).
|
|
3056
3520
|
|
|
3057
|
-
If the RHS of
|
|
3521
|
+
If the RHS of `=` produces multiple values, then for each such
|
|
3058
3522
|
value jq will set the paths on the left-hand side to the value
|
|
3059
3523
|
and then it will output the modified `.`. For example,
|
|
3060
|
-
`(.a,.b)=range(2)` outputs `{"a":0,"b":0}`, then
|
|
3524
|
+
`(.a,.b) = range(2)` outputs `{"a":0,"b":0}`, then
|
|
3061
3525
|
`{"a":1,"b":1}`. The "update" assignment forms (see above) do
|
|
3062
3526
|
not do this.
|
|
3063
3527
|
|
|
3064
|
-
This example should show the difference between
|
|
3528
|
+
This example should show the difference between `=` and `|=`:
|
|
3065
3529
|
|
|
3066
|
-
Provide input
|
|
3530
|
+
Provide input `{"a": {"b": 10}, "b": 20}` to the programs
|
|
3067
3531
|
|
|
3068
|
-
|
|
3532
|
+
.a = .b
|
|
3069
3533
|
|
|
3070
|
-
|
|
3534
|
+
and
|
|
3071
3535
|
|
|
3072
|
-
|
|
3073
|
-
field of the input, and produce the output {"a": 20, "b": 20}.
|
|
3074
|
-
The latter will set the "a" field of the input to the "a"
|
|
3075
|
-
field's "b" field, producing {"a": 10, "b": 20}.
|
|
3536
|
+
.a |= .b
|
|
3076
3537
|
|
|
3077
|
-
|
|
3538
|
+
The former will set the `a` field of the input to the `b`
|
|
3539
|
+
field of the input, and produce the output `{"a": 20, "b": 20}`.
|
|
3540
|
+
The latter will set the `a` field of the input to the `a`
|
|
3541
|
+
field's `b` field, producing `{"a": 10, "b": 20}`.
|
|
3078
3542
|
|
|
3079
|
-
|
|
3543
|
+
examples:
|
|
3544
|
+
- program: .a = .b
|
|
3545
|
+
input: '{"a": {"b": 10}, "b": 20}'
|
|
3546
|
+
output: ['{"a":20,"b":20}']
|
|
3080
3547
|
|
|
3081
|
-
|
|
3082
|
-
|
|
3548
|
+
- program: .a |= .b
|
|
3549
|
+
input: '{"a": {"b": 10}, "b": 20}'
|
|
3550
|
+
output: ['{"a":10,"b":20}']
|
|
3083
3551
|
|
|
3084
|
-
|
|
3552
|
+
- program: (.a, .b) = range(3)
|
|
3553
|
+
input: 'null'
|
|
3554
|
+
output:
|
|
3555
|
+
- '{"a":0,"b":0}'
|
|
3556
|
+
- '{"a":1,"b":1}'
|
|
3557
|
+
- '{"a":2,"b":2}'
|
|
3085
3558
|
|
|
3086
|
-
|
|
3559
|
+
- program: (.a, .b) |= range(3)
|
|
3560
|
+
input: 'null'
|
|
3561
|
+
output: ['{"a":0,"b":0}']
|
|
3087
3562
|
|
|
3088
3563
|
- title: Complex assignments
|
|
3089
3564
|
body: |
|
|
@@ -3125,6 +3600,68 @@ sections:
|
|
|
3125
3600
|
(.posts[] | select(.author == "stedolan") | .comments) |=
|
|
3126
3601
|
. + ["terrible."]
|
|
3127
3602
|
|
|
3603
|
+
- title: Comments
|
|
3604
|
+
|
|
3605
|
+
body: |
|
|
3606
|
+
|
|
3607
|
+
You can write comments in your jq filters using `#`.
|
|
3608
|
+
|
|
3609
|
+
A `#` character (not part of a string) starts a comment.
|
|
3610
|
+
All characters from `#` to the end of the line are ignored.
|
|
3611
|
+
|
|
3612
|
+
If the end of the line is preceded by an odd number of backslash
|
|
3613
|
+
characters, the following line is also considered part of the
|
|
3614
|
+
comment and is ignored.
|
|
3615
|
+
|
|
3616
|
+
For example, the following code outputs `[1,3,4,7]`
|
|
3617
|
+
|
|
3618
|
+
[
|
|
3619
|
+
1,
|
|
3620
|
+
# foo \
|
|
3621
|
+
2,
|
|
3622
|
+
# bar \\
|
|
3623
|
+
3,
|
|
3624
|
+
4, # baz \\\
|
|
3625
|
+
5, \
|
|
3626
|
+
6,
|
|
3627
|
+
7
|
|
3628
|
+
# comment \
|
|
3629
|
+
comment \
|
|
3630
|
+
comment
|
|
3631
|
+
]
|
|
3632
|
+
|
|
3633
|
+
Backslash continuing the comment on the next line can be useful
|
|
3634
|
+
when writing the "shebang" for a jq script:
|
|
3635
|
+
|
|
3636
|
+
#!/bin/sh --
|
|
3637
|
+
# total - Output the sum of the given arguments (or stdin)
|
|
3638
|
+
# usage: total [numbers...]
|
|
3639
|
+
# \
|
|
3640
|
+
exec jq --args -MRnf -- "$0" "$@"
|
|
3641
|
+
|
|
3642
|
+
$ARGS.positional |
|
|
3643
|
+
reduce (
|
|
3644
|
+
if . == []
|
|
3645
|
+
then inputs
|
|
3646
|
+
else .[]
|
|
3647
|
+
end |
|
|
3648
|
+
. as $dot |
|
|
3649
|
+
try tonumber catch false |
|
|
3650
|
+
if not or isnan then
|
|
3651
|
+
@json "total: Invalid number \($dot).\n" | halt_error(1)
|
|
3652
|
+
end
|
|
3653
|
+
) as $n (0; . + $n)
|
|
3654
|
+
|
|
3655
|
+
The `exec` line is considered a comment by jq, so it is ignored.
|
|
3656
|
+
But it is not ignored by `sh`, since in `sh` a backslash at the
|
|
3657
|
+
end of the line does not continue the comment.
|
|
3658
|
+
With this trick, when the script is invoked as `total 1 2`,
|
|
3659
|
+
`/bin/sh -- /path/to/total 1 2` will be run, and `sh` will then
|
|
3660
|
+
run `exec jq --args -MRnf -- /path/to/total 1 2` replacing itself
|
|
3661
|
+
with a `jq` interpreter invoked with the specified options (`-M`,
|
|
3662
|
+
`-R`, `-n`, `--args`), that evaluates the current file (`$0`),
|
|
3663
|
+
with the arguments (`$@`) that were passed to `sh`.
|
|
3664
|
+
|
|
3128
3665
|
- title: Modules
|
|
3129
3666
|
body: |
|
|
3130
3667
|
|
|
@@ -3135,16 +3672,16 @@ sections:
|
|
|
3135
3672
|
path (see below). The `import` and `include` directives allow the
|
|
3136
3673
|
importer to alter this path.
|
|
3137
3674
|
|
|
3138
|
-
Paths in the
|
|
3675
|
+
Paths in the search path are subject to various substitutions.
|
|
3139
3676
|
|
|
3140
|
-
For paths starting with
|
|
3141
|
-
substituted for
|
|
3677
|
+
For paths starting with `~/`, the user's home directory is
|
|
3678
|
+
substituted for `~`.
|
|
3142
3679
|
|
|
3143
|
-
For paths starting with
|
|
3144
|
-
is substituted for
|
|
3680
|
+
For paths starting with `$ORIGIN/`, the directory where the jq
|
|
3681
|
+
executable is located is substituted for `$ORIGIN`.
|
|
3145
3682
|
|
|
3146
|
-
For paths starting with
|
|
3147
|
-
the including file is substituted for
|
|
3683
|
+
For paths starting with `./` or paths that are `.`, the path of
|
|
3684
|
+
the including file is substituted for `.`. For top-level programs
|
|
3148
3685
|
given on the command-line, the current directory is used.
|
|
3149
3686
|
|
|
3150
3687
|
Import directives can optionally specify a search path to which
|
|
@@ -3157,36 +3694,37 @@ sections:
|
|
|
3157
3694
|
Null and empty string path elements terminate search path
|
|
3158
3695
|
processing.
|
|
3159
3696
|
|
|
3160
|
-
A dependency with relative path
|
|
3161
|
-
|
|
3697
|
+
A dependency with relative path `foo/bar` would be searched for in
|
|
3698
|
+
`foo/bar.jq` and `foo/bar/bar.jq` in the given search path. This
|
|
3162
3699
|
is intended to allow modules to be placed in a directory along
|
|
3163
3700
|
with, for example, version control files, README files, and so on,
|
|
3164
3701
|
but also to allow for single-file modules.
|
|
3165
3702
|
|
|
3166
3703
|
Consecutive components with the same name are not allowed to avoid
|
|
3167
|
-
ambiguities (e.g.,
|
|
3704
|
+
ambiguities (e.g., `foo/foo`).
|
|
3168
3705
|
|
|
3169
3706
|
For example, with `-L$HOME/.jq` a module `foo` can be found in
|
|
3170
3707
|
`$HOME/.jq/foo.jq` and `$HOME/.jq/foo/foo.jq`.
|
|
3171
3708
|
|
|
3172
|
-
If
|
|
3709
|
+
If `.jq` exists in the user's home directory, and is a file (not a
|
|
3710
|
+
directory), it is automatically sourced into the main program.
|
|
3173
3711
|
|
|
3174
3712
|
entries:
|
|
3175
3713
|
- title: "`import RelativePathString as NAME [<metadata>];`"
|
|
3176
3714
|
body: |
|
|
3177
3715
|
|
|
3178
3716
|
Imports a module found at the given path relative to a
|
|
3179
|
-
directory in a search path. A
|
|
3717
|
+
directory in a search path. A `.jq` suffix will be added to
|
|
3180
3718
|
the relative path string. The module's symbols are prefixed
|
|
3181
|
-
with
|
|
3719
|
+
with `NAME::`.
|
|
3182
3720
|
|
|
3183
3721
|
The optional metadata must be a constant jq expression. It
|
|
3184
|
-
should be an object with keys like
|
|
3185
|
-
this time jq only uses the
|
|
3722
|
+
should be an object with keys like `homepage` and so on. At
|
|
3723
|
+
this time jq only uses the `search` key/value of the metadata.
|
|
3186
3724
|
The metadata is also made available to users via the
|
|
3187
3725
|
`modulemeta` builtin.
|
|
3188
3726
|
|
|
3189
|
-
The
|
|
3727
|
+
The `search` key in the metadata, if present, should have a
|
|
3190
3728
|
string or array value (array of strings); this is the search
|
|
3191
3729
|
path to be prefixed to the top-level search path.
|
|
3192
3730
|
|
|
@@ -3195,13 +3733,13 @@ sections:
|
|
|
3195
3733
|
|
|
3196
3734
|
Imports a module found at the given path relative to a
|
|
3197
3735
|
directory in a search path as if it were included in place. A
|
|
3198
|
-
|
|
3736
|
+
`.jq` suffix will be added to the relative path string. The
|
|
3199
3737
|
module's symbols are imported into the caller's namespace as
|
|
3200
3738
|
if the module's content had been included directly.
|
|
3201
3739
|
|
|
3202
3740
|
The optional metadata must be a constant jq expression. It
|
|
3203
|
-
should be an object with keys like
|
|
3204
|
-
this time jq only uses the
|
|
3741
|
+
should be an object with keys like `homepage` and so on. At
|
|
3742
|
+
this time jq only uses the `search` key/value of the metadata.
|
|
3205
3743
|
The metadata is also made available to users via the
|
|
3206
3744
|
`modulemeta` builtin.
|
|
3207
3745
|
|
|
@@ -3209,17 +3747,17 @@ sections:
|
|
|
3209
3747
|
body: |
|
|
3210
3748
|
|
|
3211
3749
|
Imports a JSON file found at the given path relative to a
|
|
3212
|
-
directory in a search path. A
|
|
3750
|
+
directory in a search path. A `.json` suffix will be added to
|
|
3213
3751
|
the relative path string. The file's data will be available
|
|
3214
3752
|
as `$NAME::NAME`.
|
|
3215
3753
|
|
|
3216
3754
|
The optional metadata must be a constant jq expression. It
|
|
3217
|
-
should be an object with keys like
|
|
3218
|
-
this time jq only uses the
|
|
3755
|
+
should be an object with keys like `homepage` and so on. At
|
|
3756
|
+
this time jq only uses the `search` key/value of the metadata.
|
|
3219
3757
|
The metadata is also made available to users via the
|
|
3220
3758
|
`modulemeta` builtin.
|
|
3221
3759
|
|
|
3222
|
-
The
|
|
3760
|
+
The `search` key in the metadata, if present, should have a
|
|
3223
3761
|
string or array value (array of strings); this is the search
|
|
3224
3762
|
path to be prefixed to the top-level search path.
|
|
3225
3763
|
|
|
@@ -3231,7 +3769,7 @@ sections:
|
|
|
3231
3769
|
metadata that can be read with the `modulemeta` builtin.
|
|
3232
3770
|
|
|
3233
3771
|
The metadata must be a constant jq expression. It should be
|
|
3234
|
-
an object with keys like
|
|
3772
|
+
an object with keys like `homepage`. At this time jq doesn't
|
|
3235
3773
|
use this metadata, but it is made available to users via the
|
|
3236
3774
|
`modulemeta` builtin.
|
|
3237
3775
|
|
|
@@ -3240,7 +3778,8 @@ sections:
|
|
|
3240
3778
|
|
|
3241
3779
|
Takes a module name as input and outputs the module's metadata
|
|
3242
3780
|
as an object, with the module's imports (including metadata)
|
|
3243
|
-
as an array value for the
|
|
3781
|
+
as an array value for the `deps` key and the module's defined
|
|
3782
|
+
functions as an array value for the `defs` key.
|
|
3244
3783
|
|
|
3245
3784
|
Programs can use this to query a module's metadata, which they
|
|
3246
3785
|
could then use to, for example, search for, download, and
|
|
@@ -3260,9 +3799,10 @@ sections:
|
|
|
3260
3799
|
- color for strings
|
|
3261
3800
|
- color for arrays
|
|
3262
3801
|
- color for objects
|
|
3802
|
+
- color for object keys
|
|
3263
3803
|
|
|
3264
3804
|
The default color scheme is the same as setting
|
|
3265
|
-
`
|
|
3805
|
+
`JQ_COLORS="0;90:0;39:0;39:0;39:0;32:1;39:1;39:1;34"`.
|
|
3266
3806
|
|
|
3267
3807
|
This is not a manual for VT100/ANSI escapes. However, each of
|
|
3268
3808
|
these color specifications should consist of two numbers separated
|