@port-labs/jq-node-bindings 1.0.5 → 1.1.0-dev
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/.claude/settings.local.json +12 -0
- package/configure +6 -5
- package/deps/jq/.claude/settings.local.json +7 -0
- package/deps/jq/.gitattributes +1 -3
- package/deps/jq/AUTHORS +55 -1
- package/deps/jq/COPYING +40 -0
- package/deps/jq/Makefile.am +40 -36
- package/deps/jq/NEWS.md +277 -2
- package/deps/jq/README.md +23 -5
- package/deps/jq/compile-ios.sh +1 -1
- package/deps/jq/config/m4/check-math-func.m4 +2 -2
- package/deps/jq/config/m4/find-func-no-libs2.m4 +3 -3
- package/deps/jq/configure.ac +10 -18
- package/deps/jq/docs/Pipfile.lock +368 -313
- package/deps/jq/docs/README.md +3 -4
- package/deps/jq/docs/build_manpage.py +1 -1
- package/deps/jq/docs/build_mantests.py +1 -1
- package/deps/jq/docs/build_website.py +1 -8
- package/deps/jq/docs/content/download/default.yml +49 -9
- package/deps/jq/docs/content/index.yml +9 -0
- package/deps/jq/docs/content/manual/{manual.yml → dev/manual.yml} +218 -61
- package/deps/jq/docs/content/manual/v1.3/manual.yml +0 -5
- package/deps/jq/docs/content/manual/v1.4/manual.yml +0 -5
- package/deps/jq/docs/content/manual/v1.5/manual.yml +3 -8
- package/deps/jq/docs/content/manual/v1.6/manual.yml +3 -8
- package/deps/jq/docs/content/manual/v1.7/manual.yml +499 -500
- package/deps/jq/docs/content/manual/v1.8/manual.yml +3858 -0
- package/deps/jq/docs/content/tutorial/default.yml +3 -3
- package/deps/jq/docs/manual_schema.yml +0 -3
- package/deps/jq/docs/public/CNAME +1 -0
- package/deps/jq/docs/templates/index.html.j2 +10 -10
- package/deps/jq/docs/templates/manual.html.j2 +14 -3
- package/deps/jq/docs/templates/shared/_head.html.j2 +8 -3
- package/deps/jq/docs/templates/shared/_navbar.html.j2 +4 -4
- package/deps/jq/jq.1.prebuilt +219 -44
- package/deps/jq/jq.spec +2 -2
- package/deps/jq/libjq.pc.in +1 -1
- package/deps/jq/scripts/version +1 -1
- 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.8.0/jq-1.8.0.tar.gz.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-1.8.0.zip.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-amd64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-arm64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-armel.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-armhf.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-i386.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mips.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mips64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mips64el.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mips64r6.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mips64r6el.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mipsel.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mipsr6.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-mipsr6el.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-powerpc.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-ppc64el.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-riscv64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux-s390x.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-linux64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-macos-amd64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-macos-arm64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-osx-amd64.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-win64.exe.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-windows-amd64.exe.asc +16 -0
- package/deps/jq/sig/v1.8.0/jq-windows-i386.exe.asc +16 -0
- package/deps/jq/sig/v1.8.0/sha256sum.txt +26 -0
- package/deps/jq/src/builtin.c +446 -271
- package/deps/jq/src/builtin.jq +25 -60
- package/deps/jq/src/bytecode.h +8 -3
- package/deps/jq/src/compile.c +22 -43
- package/deps/jq/src/compile.h +1 -1
- package/deps/jq/src/execute.c +20 -25
- package/deps/jq/src/jq_test.c +113 -44
- package/deps/jq/src/jv.c +134 -42
- package/deps/jq/src/jv.h +10 -3
- package/deps/jq/src/jv_alloc.c +8 -5
- package/deps/jq/src/jv_alloc.h +0 -1
- package/deps/jq/src/jv_aux.c +41 -8
- package/deps/jq/src/jv_dtoa.c +4 -12
- package/deps/jq/src/jv_dtoa_tsd.c +5 -4
- package/deps/jq/src/jv_dtoa_tsd.h +1 -1
- package/deps/jq/src/jv_parse.c +5 -3
- package/deps/jq/src/jv_print.c +87 -65
- package/deps/jq/src/jv_unicode.c +18 -0
- package/deps/jq/src/jv_unicode.h +2 -0
- package/deps/jq/src/lexer.c +303 -278
- package/deps/jq/src/lexer.h +5 -4
- package/deps/jq/src/lexer.l +8 -2
- package/deps/jq/src/libm.h +15 -5
- package/deps/jq/src/linker.c +6 -4
- package/deps/jq/src/locfile.c +12 -12
- package/deps/jq/src/main.c +204 -270
- package/deps/jq/src/parser.c +1105 -1273
- package/deps/jq/src/parser.y +149 -181
- package/deps/jq/src/util.c +46 -48
- package/deps/jq/src/util.h +1 -1
- package/deps/jq/tests/base64.test +12 -0
- package/deps/jq/tests/jq.test +429 -37
- package/deps/jq/tests/jq_fuzz_load_file.c +1 -0
- package/deps/jq/tests/man.test +46 -13
- package/deps/jq/tests/manonig.test +13 -0
- package/deps/jq/tests/onig.test +40 -2
- package/deps/jq/tests/optional.test +4 -12
- package/deps/jq/tests/setup +5 -1
- package/deps/jq/tests/shtest +358 -130
- package/deps/jq/tests/uri.test +38 -0
- package/deps/jq/tests/uritest +5 -0
- package/deps/jq/{src → vendor}/decNumber/decBasic.c +1 -1
- package/deps/jq/{src → vendor}/decNumber/decCommon.c +1 -1
- package/deps/jq/{src → vendor}/decNumber/decNumber.c +4 -4
- package/deps/jq/{modules → vendor}/oniguruma/CMakeLists.txt +5 -3
- package/deps/jq/{modules → vendor}/oniguruma/HISTORY +45 -7
- package/deps/jq/{modules → vendor}/oniguruma/Makefile.am +1 -1
- package/deps/jq/{modules → vendor}/oniguruma/README.md +10 -23
- package/deps/jq/{modules → vendor}/oniguruma/compile +29 -13
- package/deps/jq/{modules → vendor}/oniguruma/config.guess +91 -27
- package/deps/jq/{modules → vendor}/oniguruma/config.sub +716 -242
- package/deps/jq/{modules → vendor}/oniguruma/configure.ac +2 -2
- package/deps/jq/{modules → vendor}/oniguruma/depcomp +10 -9
- package/deps/jq/{modules → vendor}/oniguruma/doc/API +3 -1
- package/deps/jq/{modules → vendor}/oniguruma/doc/API.ja +3 -1
- package/deps/jq/{modules → vendor}/oniguruma/doc/CALLOUTS.BUILTIN +10 -1
- package/deps/jq/{modules → vendor}/oniguruma/doc/CALLOUTS.BUILTIN.ja +9 -1
- package/deps/jq/{modules → vendor}/oniguruma/doc/RE +12 -13
- package/deps/jq/{modules → vendor}/oniguruma/doc/RE.ja +12 -13
- package/deps/jq/{modules → vendor}/oniguruma/doc/SYNTAX.md +202 -167
- package/deps/jq/{modules → vendor}/oniguruma/doc/UNICODE_PROPERTIES +33 -1
- package/deps/jq/vendor/oniguruma/doc/onig_syn_md.c +667 -0
- package/deps/jq/{modules → vendor}/oniguruma/harnesses/base.c +1 -1
- package/deps/jq/{modules → vendor}/oniguruma/install-sh +9 -9
- package/deps/jq/{modules → vendor}/oniguruma/missing +50 -29
- package/deps/jq/{modules → vendor}/oniguruma/sample/callback_each_match.c +1 -3
- package/deps/jq/vendor/oniguruma/sbom.cdx.json +44 -0
- package/deps/jq/{modules → vendor}/oniguruma/src/ascii.c +4 -1
- package/deps/jq/{modules → vendor}/oniguruma/src/gperf_fold_key_conv.py +4 -4
- package/deps/jq/{modules → vendor}/oniguruma/src/gperf_unfold_key_conv.py +4 -4
- package/deps/jq/vendor/oniguruma/src/make_unicode_egcb.sh +7 -0
- package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_egcb_data.py +20 -19
- package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_fold.sh +5 -5
- package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_fold_data.py +37 -37
- package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_property.sh +2 -2
- package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_property_data.py +66 -65
- package/deps/jq/vendor/oniguruma/src/make_unicode_wb.sh +7 -0
- package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_wb_data.py +20 -19
- package/deps/jq/{modules → vendor}/oniguruma/src/oniguruma.h +6 -3
- package/deps/jq/{modules → vendor}/oniguruma/src/regcomp.c +14 -6
- package/deps/jq/{modules → vendor}/oniguruma/src/regerror.c +2 -2
- package/deps/jq/{modules → vendor}/oniguruma/src/regexec.c +85 -14
- package/deps/jq/{modules → vendor}/oniguruma/src/regint.h +17 -4
- package/deps/jq/{modules → vendor}/oniguruma/src/regparse.c +115 -27
- package/deps/jq/{modules → vendor}/oniguruma/src/regsyntax.c +10 -7
- package/deps/jq/{modules → vendor}/oniguruma/src/st.c +49 -75
- package/deps/jq/{modules → vendor}/oniguruma/src/st.h +3 -10
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_egcb_data.c +54 -49
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_fold1_key.c +1567 -1507
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_fold2_key.c +1 -1
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_fold3_key.c +1 -1
- package/deps/jq/vendor/oniguruma/src/unicode_fold_data.c +1619 -0
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_property_data.c +5520 -4178
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_property_data_posix.c +239 -83
- package/deps/jq/vendor/oniguruma/src/unicode_unfold_key.c +3497 -0
- package/deps/jq/{modules → vendor}/oniguruma/src/unicode_wb_data.c +51 -19
- package/deps/jq/{modules → vendor}/oniguruma/src/utf16_be.c +3 -2
- package/deps/jq/{modules → vendor}/oniguruma/src/utf16_le.c +3 -2
- package/deps/jq/{modules → vendor}/oniguruma/test/test_back.c +3 -3
- package/deps/jq/{modules → vendor}/oniguruma/test/test_options.c +2 -2
- package/deps/jq/{modules → vendor}/oniguruma/test/test_syntax.c +54 -2
- package/deps/jq/{modules → vendor}/oniguruma/test/test_utf8.c +19 -5
- package/deps/jq/{modules → vendor}/oniguruma/test/testc.c +1 -1
- package/deps/jq/{modules → vendor}/oniguruma/test/testp.c +1 -1
- package/deps/jq/{modules → vendor}/oniguruma/test-driver +13 -6
- package/deps/jq/{modules → vendor}/oniguruma/windows/CMakeLists.txt +1 -1
- package/package.json +4 -3
- package/test/santiy-async.test.js +4 -4
- package/test/santiy.test.js +4 -4
- package/test/template.test.js +6 -6
- package/deps/jq/modules/oniguruma/src/make_unicode_egcb.sh +0 -7
- package/deps/jq/modules/oniguruma/src/make_unicode_wb.sh +0 -7
- package/deps/jq/modules/oniguruma/src/unicode_fold_data.c +0 -1592
- package/deps/jq/modules/oniguruma/src/unicode_unfold_key.c +0 -3394
- package/deps/jq/scripts/update-website +0 -30
- /package/deps/jq/{src → vendor}/decNumber/ICU-license.html +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decContext.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decContext.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decDPD.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decDouble.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decDouble.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decNumber.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decNumberLocal.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decPacked.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decPacked.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decQuad.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decQuad.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decSingle.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decSingle.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decimal128.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decimal128.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decimal32.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decimal32.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decimal64.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decimal64.h +0 -0
- /package/deps/jq/{src → vendor}/decNumber/decnumber.pdf +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example1.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example2.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example3.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example4.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example5.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example6.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example7.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/example8.c +0 -0
- /package/deps/jq/{src → vendor}/decNumber/readme.txt +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/.travis.yml +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/AUTHORS +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/COPYING +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/ChangeLog +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/NEWS +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/README +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/README_japanese +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/autogen.sh +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/cmake/Config.cmake.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/doc/CALLOUTS.API +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/doc/CALLOUTS.API.ja +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/doc/FAQ +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/doc/FAQ.ja +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/harnesses/ascii_compatible.dict +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/harnesses/deluxe.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/harnesses/dict_conv.py +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/harnesses/fuzzer.options +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/harnesses/libfuzzer-onig.cpp +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/harnesses/regset.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/index.html +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/index_ja.html +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/m4/.whatever +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/make_win.bat +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/make_win32.bat +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/make_win64.bat +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/onig-config.cmake.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/onig-config.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/oniguruma.pc.cmake.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/oniguruma.pc.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/CMakeLists.txt +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/Makefile.am +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/bug_fix.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/callout.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/count.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/crnl.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/echo.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/encode.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/listcap.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/names.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/posix.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/regset.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/scan.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/simple.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/sql.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/syntax.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/sample/user_property.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/Makefile.am +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/Makefile.windows +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/big5.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/config.h.cmake.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/config.h.win32 +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/config.h.win64 +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/config.h.windows.in +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/cp1251.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/euc_jp.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/euc_jp_prop.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/euc_jp_prop.gperf +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/euc_kr.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/euc_tw.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/gb18030.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_1.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_10.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_11.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_13.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_14.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_15.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_16.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_2.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_3.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_4.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_5.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_6.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_7.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_8.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_9.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/koi8.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/koi8_r.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/make_property.sh +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/mktable.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/onig_init.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/oniggnu.h +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/onigposix.h +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regenc.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regenc.h +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regext.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/reggnu.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regparse.h +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regposerr.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regposix.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regtrav.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/regversion.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/sjis.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/sjis_prop.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/sjis_prop.gperf +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/unicode.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/utf32_be.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/utf32_le.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/src/utf8.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/test/CMakeLists.txt +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/test/Makefile.am +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/test/test.sh +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/test/test_regset.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/test/testu.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/stub.c +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/test_back.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/test_regset.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/test_syntax.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/test_utf8.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/testc.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/testu.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/tis.config +0 -0
- /package/deps/jq/{modules → vendor}/oniguruma/windows/testc.c +0 -0
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
headline: jq 1.7 Manual
|
|
3
3
|
|
|
4
|
-
history: |
|
|
5
|
-
|
|
6
|
-
*The manual for the development version of jq can be found
|
|
7
|
-
[here](../).*
|
|
8
|
-
|
|
9
4
|
body: |
|
|
10
5
|
|
|
11
6
|
A jq program is a "filter": it takes an input, and produces an
|
|
@@ -381,29 +376,29 @@ sections:
|
|
|
381
376
|
illustrated in one of the following examples.
|
|
382
377
|
|
|
383
378
|
examples:
|
|
384
|
-
- program:
|
|
379
|
+
- program: '.'
|
|
385
380
|
input: '"Hello, world!"'
|
|
386
381
|
output: ['"Hello, world!"']
|
|
387
382
|
|
|
388
|
-
- program:
|
|
389
|
-
input:
|
|
390
|
-
output: [
|
|
383
|
+
- program: '.'
|
|
384
|
+
input: '0.12345678901234567890123456789'
|
|
385
|
+
output: ['0.12345678901234567890123456789']
|
|
391
386
|
|
|
392
|
-
- program:
|
|
393
|
-
input:
|
|
387
|
+
- program: '[., tojson]'
|
|
388
|
+
input: '12345678909876543212345'
|
|
394
389
|
output: ['[12345678909876543212345,"12345678909876543212345"]']
|
|
395
390
|
|
|
396
|
-
- program:
|
|
397
|
-
input:
|
|
398
|
-
output: [
|
|
391
|
+
- program: '. < 0.12345678901234567890123456788'
|
|
392
|
+
input: '0.12345678901234567890123456789'
|
|
393
|
+
output: ['false']
|
|
399
394
|
|
|
400
|
-
- program:
|
|
401
|
-
input:
|
|
395
|
+
- program: 'map([., . == 1]) | tojson'
|
|
396
|
+
input: '[1, 1.000, 1.0, 100e-2]'
|
|
402
397
|
output: ['"[[1,true],[1.000,true],[1.0,true],[1.00,true]]"']
|
|
403
398
|
|
|
404
|
-
- program:
|
|
405
|
-
input:
|
|
406
|
-
output: [
|
|
399
|
+
- program: '. as $big | [$big, $big + 1] | map(. > 10000000000000000000000000000000)'
|
|
400
|
+
input: '10000000000000000000000000000001'
|
|
401
|
+
output: ['[true, false]']
|
|
407
402
|
|
|
408
403
|
- title: "Object Identifier-Index: `.foo`, `.foo.bar`"
|
|
409
404
|
body: |
|
|
@@ -426,17 +421,17 @@ sections:
|
|
|
426
421
|
`.foo::bar` does not.
|
|
427
422
|
|
|
428
423
|
examples:
|
|
429
|
-
- program:
|
|
424
|
+
- program: '.foo'
|
|
430
425
|
input: '{"foo": 42, "bar": "less interesting data"}'
|
|
431
|
-
output: [
|
|
426
|
+
output: ['42']
|
|
432
427
|
|
|
433
|
-
- program:
|
|
428
|
+
- program: '.foo'
|
|
434
429
|
input: '{"notfoo": true, "alsonotfoo": false}'
|
|
435
|
-
output: [
|
|
430
|
+
output: ['null']
|
|
436
431
|
|
|
437
432
|
- program: '.["foo"]'
|
|
438
433
|
input: '{"foo": 42}'
|
|
439
|
-
output: [
|
|
434
|
+
output: ['42']
|
|
440
435
|
|
|
441
436
|
- title: "Optional Object Identifier-Index: `.foo?`"
|
|
442
437
|
body: |
|
|
@@ -445,18 +440,18 @@ sections:
|
|
|
445
440
|
object.
|
|
446
441
|
|
|
447
442
|
examples:
|
|
448
|
-
- program:
|
|
443
|
+
- program: '.foo?'
|
|
449
444
|
input: '{"foo": 42, "bar": "less interesting data"}'
|
|
450
|
-
output: [
|
|
451
|
-
- program:
|
|
445
|
+
output: ['42']
|
|
446
|
+
- program: '.foo?'
|
|
452
447
|
input: '{"notfoo": true, "alsonotfoo": false}'
|
|
453
|
-
output: [
|
|
448
|
+
output: ['null']
|
|
454
449
|
- program: '.["foo"]?'
|
|
455
450
|
input: '{"foo": 42}'
|
|
456
|
-
output: [
|
|
457
|
-
- program:
|
|
458
|
-
input:
|
|
459
|
-
output: [
|
|
451
|
+
output: ['42']
|
|
452
|
+
- program: '[.foo?]'
|
|
453
|
+
input: '[1,2]'
|
|
454
|
+
output: ['[]']
|
|
460
455
|
|
|
461
456
|
- title: "Object Index: `.[<string>]`"
|
|
462
457
|
body: |
|
|
@@ -476,17 +471,17 @@ sections:
|
|
|
476
471
|
element, -2 referring to the next to last element, and so on.
|
|
477
472
|
|
|
478
473
|
examples:
|
|
479
|
-
- program:
|
|
474
|
+
- program: '.[0]'
|
|
480
475
|
input: '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]'
|
|
481
476
|
output: ['{"name":"JSON", "good":true}']
|
|
482
477
|
|
|
483
|
-
- program:
|
|
478
|
+
- program: '.[2]'
|
|
484
479
|
input: '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]'
|
|
485
|
-
output: [
|
|
480
|
+
output: ['null']
|
|
486
481
|
|
|
487
|
-
- program:
|
|
488
|
-
input:
|
|
489
|
-
output: [
|
|
482
|
+
- program: '.[-2]'
|
|
483
|
+
input: '[1,2,3]'
|
|
484
|
+
output: ['2']
|
|
490
485
|
|
|
491
486
|
- title: "Array/String Slice: `.[<number>:<number>]`"
|
|
492
487
|
body: |
|
|
@@ -501,19 +496,19 @@ sections:
|
|
|
501
496
|
Indices are zero-based.
|
|
502
497
|
|
|
503
498
|
examples:
|
|
504
|
-
- program:
|
|
499
|
+
- program: '.[2:4]'
|
|
505
500
|
input: '["a","b","c","d","e"]'
|
|
506
501
|
output: ['["c", "d"]']
|
|
507
502
|
|
|
508
|
-
- program:
|
|
503
|
+
- program: '.[2:4]'
|
|
509
504
|
input: '"abcdefghi"'
|
|
510
505
|
output: ['"cd"']
|
|
511
506
|
|
|
512
|
-
- program:
|
|
507
|
+
- program: '.[:3]'
|
|
513
508
|
input: '["a","b","c","d","e"]'
|
|
514
509
|
output: ['["a", "b", "c"]']
|
|
515
510
|
|
|
516
|
-
- program:
|
|
511
|
+
- program: '.[-2:]'
|
|
517
512
|
input: '["a","b","c","d","e"]'
|
|
518
513
|
output: ['["d", "e"]']
|
|
519
514
|
|
|
@@ -533,23 +528,23 @@ sections:
|
|
|
533
528
|
Note that the iterator operator is a generator of values.
|
|
534
529
|
|
|
535
530
|
examples:
|
|
536
|
-
- program:
|
|
531
|
+
- program: '.[]'
|
|
537
532
|
input: '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]'
|
|
538
533
|
output:
|
|
539
534
|
- '{"name":"JSON", "good":true}'
|
|
540
535
|
- '{"name":"XML", "good":false}'
|
|
541
536
|
|
|
542
|
-
- program:
|
|
543
|
-
input:
|
|
537
|
+
- program: '.[]'
|
|
538
|
+
input: '[]'
|
|
544
539
|
output: []
|
|
545
540
|
|
|
546
|
-
- program:
|
|
541
|
+
- program: '.foo[]'
|
|
547
542
|
input: '{"foo":[1,2,3]}'
|
|
548
|
-
output: [
|
|
543
|
+
output: ['1','2','3']
|
|
549
544
|
|
|
550
|
-
- program:
|
|
545
|
+
- program: '.[]'
|
|
551
546
|
input: '{"a": 1, "b": 1}'
|
|
552
|
-
output: [
|
|
547
|
+
output: ['1', '1']
|
|
553
548
|
|
|
554
549
|
- title: "`.[]?`"
|
|
555
550
|
body: |
|
|
@@ -569,18 +564,18 @@ sections:
|
|
|
569
564
|
.bar`, produces both the "foo" fields and "bar" fields as
|
|
570
565
|
separate outputs.
|
|
571
566
|
|
|
572
|
-
The `,` operator is one way to
|
|
567
|
+
The `,` operator is one way to construct generators.
|
|
573
568
|
|
|
574
569
|
examples:
|
|
575
|
-
- program:
|
|
570
|
+
- program: '.foo, .bar'
|
|
576
571
|
input: '{"foo": 42, "bar": "something else", "baz": true}'
|
|
577
|
-
output: [
|
|
572
|
+
output: ['42', '"something else"']
|
|
578
573
|
|
|
579
574
|
- program: ".user, .projects[]"
|
|
580
575
|
input: '{"user":"stedolan", "projects": ["jq", "wikiflow"]}'
|
|
581
576
|
output: ['"stedolan"', '"jq"', '"wikiflow"']
|
|
582
577
|
|
|
583
|
-
- program:
|
|
578
|
+
- program: '.[4,2]'
|
|
584
579
|
input: '["a","b","c","d","e"]'
|
|
585
580
|
output: ['"e"', '"c"']
|
|
586
581
|
|
|
@@ -605,7 +600,7 @@ sections:
|
|
|
605
600
|
middle refers to whatever value `.a` produced.
|
|
606
601
|
|
|
607
602
|
examples:
|
|
608
|
-
- program:
|
|
603
|
+
- program: '.[] | .name'
|
|
609
604
|
input: '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]'
|
|
610
605
|
output: ['"JSON"', '"XML"']
|
|
611
606
|
|
|
@@ -616,9 +611,9 @@ sections:
|
|
|
616
611
|
programming language.
|
|
617
612
|
|
|
618
613
|
examples:
|
|
619
|
-
- program:
|
|
620
|
-
input:
|
|
621
|
-
output: [
|
|
614
|
+
- program: '(. + 2) * 5'
|
|
615
|
+
input: '1'
|
|
616
|
+
output: ['15']
|
|
622
617
|
|
|
623
618
|
- title: Types and Values
|
|
624
619
|
body: |
|
|
@@ -670,8 +665,8 @@ sections:
|
|
|
670
665
|
input: '{"user":"stedolan", "projects": ["jq", "wikiflow"]}'
|
|
671
666
|
output: ['["stedolan", "jq", "wikiflow"]']
|
|
672
667
|
- program: "[ .[] | . * 2]"
|
|
673
|
-
input:
|
|
674
|
-
output: [
|
|
668
|
+
input: '[1, 2, 3]'
|
|
669
|
+
output: ['[2, 4, 6]']
|
|
675
670
|
|
|
676
671
|
- title: "Object Construction: `{}`"
|
|
677
672
|
body: |
|
|
@@ -738,12 +733,12 @@ sections:
|
|
|
738
733
|
{"foo":"f o o","b a r":"f o o"}
|
|
739
734
|
|
|
740
735
|
examples:
|
|
741
|
-
- program:
|
|
736
|
+
- program: '{user, title: .titles[]}'
|
|
742
737
|
input: '{"user":"stedolan","titles":["JQ Primer", "More JQ"]}'
|
|
743
738
|
output:
|
|
744
739
|
- '{"user":"stedolan", "title": "JQ Primer"}'
|
|
745
740
|
- '{"user":"stedolan", "title": "More JQ"}'
|
|
746
|
-
- program:
|
|
741
|
+
- program: '{(.user): .titles}'
|
|
747
742
|
input: '{"user":"stedolan","titles":["JQ Primer", "More JQ"]}'
|
|
748
743
|
output: ['{"stedolan": ["JQ Primer", "More JQ"]}']
|
|
749
744
|
|
|
@@ -761,9 +756,9 @@ sections:
|
|
|
761
756
|
(also see below) and the `?` operator.
|
|
762
757
|
|
|
763
758
|
examples:
|
|
764
|
-
- program:
|
|
759
|
+
- program: '.. | .a?'
|
|
765
760
|
input: '[[{"a":1}]]'
|
|
766
|
-
output: [
|
|
761
|
+
output: ['1']
|
|
767
762
|
|
|
768
763
|
- title: Builtin operators and functions
|
|
769
764
|
body: |
|
|
@@ -810,20 +805,20 @@ sections:
|
|
|
810
805
|
value unchanged.
|
|
811
806
|
|
|
812
807
|
examples:
|
|
813
|
-
- program:
|
|
808
|
+
- program: '.a + 1'
|
|
814
809
|
input: '{"a": 7}'
|
|
815
|
-
output: [
|
|
816
|
-
- program:
|
|
810
|
+
output: ['8']
|
|
811
|
+
- program: '.a + .b'
|
|
817
812
|
input: '{"a": [1,2], "b": [3,4]}'
|
|
818
|
-
output: [
|
|
819
|
-
- program:
|
|
813
|
+
output: ['[1,2,3,4]']
|
|
814
|
+
- program: '.a + null'
|
|
820
815
|
input: '{"a": 1}'
|
|
821
|
-
output: [
|
|
822
|
-
- program:
|
|
823
|
-
input:
|
|
824
|
-
output: [
|
|
825
|
-
- program:
|
|
826
|
-
input:
|
|
816
|
+
output: ['1']
|
|
817
|
+
- program: '.a + 1'
|
|
818
|
+
input: '{}'
|
|
819
|
+
output: ['1']
|
|
820
|
+
- program: '{a: 1} + {b: 2} + {c: 3} + {a: 42}'
|
|
821
|
+
input: 'null'
|
|
827
822
|
output: ['{"a": 42, "b": 2, "c": 3}']
|
|
828
823
|
|
|
829
824
|
- title: "Subtraction: `-`"
|
|
@@ -834,9 +829,9 @@ sections:
|
|
|
834
829
|
the second array's elements from the first array.
|
|
835
830
|
|
|
836
831
|
examples:
|
|
837
|
-
- program:
|
|
832
|
+
- program: '4 - .a'
|
|
838
833
|
input: '{"a":3}'
|
|
839
|
-
output: [
|
|
834
|
+
output: ['1']
|
|
840
835
|
- program: . - ["xml", "yaml"]
|
|
841
836
|
input: '["xml", "yaml", "json"]'
|
|
842
837
|
output: ['["json"]']
|
|
@@ -859,18 +854,18 @@ sections:
|
|
|
859
854
|
the same strategy.
|
|
860
855
|
|
|
861
856
|
examples:
|
|
862
|
-
- program:
|
|
863
|
-
input:
|
|
864
|
-
output: [
|
|
857
|
+
- program: '10 / . * 3'
|
|
858
|
+
input: '5'
|
|
859
|
+
output: ['6']
|
|
865
860
|
- program: '. / ", "'
|
|
866
861
|
input: '"a, b,c,d, e"'
|
|
867
862
|
output: ['["a","b,c,d","e"]']
|
|
868
863
|
- program: '{"k": {"a": 1, "b": 2}} * {"k": {"a": 0,"c": 3}}'
|
|
869
|
-
input:
|
|
864
|
+
input: 'null'
|
|
870
865
|
output: ['{"k": {"a": 0, "b": 2, "c": 3}}']
|
|
871
|
-
- program:
|
|
872
|
-
input:
|
|
873
|
-
output: [
|
|
866
|
+
- program: '.[] | (1 / .)?'
|
|
867
|
+
input: '[1,0,-1]'
|
|
868
|
+
output: ['1', '-1']
|
|
874
869
|
|
|
875
870
|
- title: "`abs`"
|
|
876
871
|
body: |
|
|
@@ -884,9 +879,9 @@ sections:
|
|
|
884
879
|
To compute the absolute value of a number as a floating point number, you may wish use `fabs`.
|
|
885
880
|
|
|
886
881
|
examples:
|
|
887
|
-
- program:
|
|
888
|
-
input:
|
|
889
|
-
output: [
|
|
882
|
+
- program: 'map(abs)'
|
|
883
|
+
input: '[-10, -1.1, -1e-1]'
|
|
884
|
+
output: ['[10,1.1,1e-1]']
|
|
890
885
|
|
|
891
886
|
- title: "`length`"
|
|
892
887
|
body: |
|
|
@@ -909,9 +904,10 @@ sections:
|
|
|
909
904
|
- It is an error to use `length` on a **boolean**.
|
|
910
905
|
|
|
911
906
|
examples:
|
|
912
|
-
- program:
|
|
907
|
+
- program: '.[] | length'
|
|
913
908
|
input: '[[1,2], "string", {"a":2}, null, -5]'
|
|
914
|
-
output: [
|
|
909
|
+
output: ['2', '6', '1', '0', '5']
|
|
910
|
+
|
|
915
911
|
|
|
916
912
|
- title: "`utf8bytelength`"
|
|
917
913
|
body: |
|
|
@@ -920,9 +916,9 @@ sections:
|
|
|
920
916
|
bytes used to encode a string in UTF-8.
|
|
921
917
|
|
|
922
918
|
examples:
|
|
923
|
-
- program:
|
|
919
|
+
- program: 'utf8bytelength'
|
|
924
920
|
input: '"\u03bc"'
|
|
925
|
-
output: [
|
|
921
|
+
output: ['2']
|
|
926
922
|
|
|
927
923
|
- title: "`keys`, `keys_unsorted`"
|
|
928
924
|
body: |
|
|
@@ -944,12 +940,12 @@ sections:
|
|
|
944
940
|
instead the keys will roughly be in insertion order.
|
|
945
941
|
|
|
946
942
|
examples:
|
|
947
|
-
- program:
|
|
943
|
+
- program: 'keys'
|
|
948
944
|
input: '{"abc": 1, "abcd": 2, "Foo": 3}'
|
|
949
945
|
output: ['["Foo", "abc", "abcd"]']
|
|
950
|
-
- program:
|
|
951
|
-
input:
|
|
952
|
-
output: [
|
|
946
|
+
- program: 'keys'
|
|
947
|
+
input: '[42,3,35]'
|
|
948
|
+
output: ['[0,1,2]']
|
|
953
949
|
|
|
954
950
|
- title: "`has(key)`"
|
|
955
951
|
body: |
|
|
@@ -965,10 +961,10 @@ sections:
|
|
|
965
961
|
examples:
|
|
966
962
|
- program: 'map(has("foo"))'
|
|
967
963
|
input: '[{"foo": 42}, {}]'
|
|
968
|
-
output: [
|
|
969
|
-
- program:
|
|
964
|
+
output: ['[true, false]']
|
|
965
|
+
- program: 'map(has(2))'
|
|
970
966
|
input: '[[0,1], ["a","b","c"]]'
|
|
971
|
-
output: [
|
|
967
|
+
output: ['[false, true]']
|
|
972
968
|
|
|
973
969
|
- title: "`in`"
|
|
974
970
|
body: |
|
|
@@ -981,10 +977,10 @@ sections:
|
|
|
981
977
|
examples:
|
|
982
978
|
- program: '.[] | in({"foo": 42})'
|
|
983
979
|
input: '["foo", "bar"]'
|
|
984
|
-
output: [
|
|
985
|
-
- program:
|
|
986
|
-
input:
|
|
987
|
-
output: [
|
|
980
|
+
output: ['true', 'false']
|
|
981
|
+
- program: 'map(in([0,1]))'
|
|
982
|
+
input: '[2, 0]'
|
|
983
|
+
output: ['[false, true]']
|
|
988
984
|
|
|
989
985
|
- title: "`map(f)`, `map_values(f)`"
|
|
990
986
|
body: |
|
|
@@ -1004,15 +1000,15 @@ sections:
|
|
|
1004
1000
|
|
|
1005
1001
|
The key difference between `map(f)` and `map_values(f)` is
|
|
1006
1002
|
that the former simply forms an array from all the values of
|
|
1007
|
-
`($x|f)` for each value,
|
|
1003
|
+
`($x|f)` for each value, `$x`, in the input array or object,
|
|
1008
1004
|
but `map_values(f)` only uses `first($x|f)`.
|
|
1009
1005
|
|
|
1010
|
-
Specifically, for object inputs, `
|
|
1006
|
+
Specifically, for object inputs, `map_values(f)` constructs
|
|
1011
1007
|
the output object by examining in turn the value of
|
|
1012
|
-
`first(.[$k]|f)` for each key,
|
|
1008
|
+
`first(.[$k]|f)` for each key, `$k`, of the input. If this
|
|
1013
1009
|
expression produces no values, then the corresponding key
|
|
1014
1010
|
will be dropped; otherwise, the output object will have that
|
|
1015
|
-
value at the key,
|
|
1011
|
+
value at the key, `$k`.
|
|
1016
1012
|
|
|
1017
1013
|
Here are some examples to clarify the behavior of `map` and
|
|
1018
1014
|
`map_values` when applied to arrays. These examples assume the
|
|
@@ -1031,23 +1027,25 @@ sections:
|
|
|
1031
1027
|
|
|
1032
1028
|
In fact, these are their implementations.
|
|
1033
1029
|
|
|
1030
|
+
|
|
1034
1031
|
examples:
|
|
1035
|
-
- program:
|
|
1036
|
-
input:
|
|
1037
|
-
output: [
|
|
1032
|
+
- program: 'map(.+1)'
|
|
1033
|
+
input: '[1,2,3]'
|
|
1034
|
+
output: ['[2,3,4]']
|
|
1038
1035
|
|
|
1039
|
-
- program:
|
|
1036
|
+
- program: 'map_values(.+1)'
|
|
1040
1037
|
input: '{"a": 1, "b": 2, "c": 3}'
|
|
1041
1038
|
output: ['{"a": 2, "b": 3, "c": 4}']
|
|
1042
1039
|
|
|
1043
|
-
- program:
|
|
1044
|
-
input:
|
|
1045
|
-
output: [
|
|
1040
|
+
- program: 'map(., .)'
|
|
1041
|
+
input: '[1,2]'
|
|
1042
|
+
output: ['[1,1,2,2]']
|
|
1046
1043
|
|
|
1047
|
-
- program:
|
|
1044
|
+
- program: 'map_values(. // empty)'
|
|
1048
1045
|
input: '{"a": null, "b": true, "c": false}'
|
|
1049
1046
|
output: ['{"b":true}']
|
|
1050
1047
|
|
|
1048
|
+
|
|
1051
1049
|
- title: "`pick(pathexps)`"
|
|
1052
1050
|
body: |
|
|
1053
1051
|
|
|
@@ -1058,13 +1056,14 @@ sections:
|
|
|
1058
1056
|
indices and `.[m:n]` specifications should not be used.
|
|
1059
1057
|
|
|
1060
1058
|
examples:
|
|
1061
|
-
- program:
|
|
1059
|
+
- program: 'pick(.a, .b.c, .x)'
|
|
1062
1060
|
input: '{"a": 1, "b": {"c": 2, "d": 3}, "e": 4}'
|
|
1063
1061
|
output: ['{"a":1,"b":{"c":2},"x":null}']
|
|
1064
1062
|
|
|
1065
|
-
- program:
|
|
1066
|
-
input:
|
|
1067
|
-
output: [
|
|
1063
|
+
- program: 'pick(.[2], .[0], .[0])'
|
|
1064
|
+
input: '[1,2,3,4]'
|
|
1065
|
+
output: ['[1,null,3]']
|
|
1066
|
+
|
|
1068
1067
|
|
|
1069
1068
|
- title: "`path(path_expression)`"
|
|
1070
1069
|
body: |
|
|
@@ -1091,10 +1090,10 @@ sections:
|
|
|
1091
1090
|
boolean values in `.`, and only those paths.
|
|
1092
1091
|
|
|
1093
1092
|
examples:
|
|
1094
|
-
- program:
|
|
1095
|
-
input:
|
|
1093
|
+
- program: 'path(.a[0].b)'
|
|
1094
|
+
input: 'null'
|
|
1096
1095
|
output: ['["a",0,"b"]']
|
|
1097
|
-
- program:
|
|
1096
|
+
- program: '[path(..)]'
|
|
1098
1097
|
input: '{"a":[{"b":1}]}'
|
|
1099
1098
|
output: ['[[],["a"],["a",0],["a",0,"b"]]']
|
|
1100
1099
|
|
|
@@ -1105,10 +1104,10 @@ sections:
|
|
|
1105
1104
|
value from an object.
|
|
1106
1105
|
|
|
1107
1106
|
examples:
|
|
1108
|
-
- program:
|
|
1107
|
+
- program: 'del(.foo)'
|
|
1109
1108
|
input: '{"foo": 42, "bar": 9001, "baz": 42}'
|
|
1110
1109
|
output: ['{"bar": 9001, "baz": 42}']
|
|
1111
|
-
- program:
|
|
1110
|
+
- program: 'del(.[1, 2])'
|
|
1112
1111
|
input: '["foo", "bar", "baz"]'
|
|
1113
1112
|
output: ['["foo"]']
|
|
1114
1113
|
|
|
@@ -1120,11 +1119,11 @@ sections:
|
|
|
1120
1119
|
|
|
1121
1120
|
examples:
|
|
1122
1121
|
- program: 'getpath(["a","b"])'
|
|
1123
|
-
input:
|
|
1124
|
-
output: [
|
|
1122
|
+
input: 'null'
|
|
1123
|
+
output: ['null']
|
|
1125
1124
|
- program: '[getpath(["a","b"], ["a","c"])]'
|
|
1126
1125
|
input: '{"a":{"b":0, "c":1}}'
|
|
1127
|
-
output: [
|
|
1126
|
+
output: ['[0, 1]']
|
|
1128
1127
|
|
|
1129
1128
|
- title: "`setpath(PATHS; VALUE)`"
|
|
1130
1129
|
body: |
|
|
@@ -1133,13 +1132,13 @@ sections:
|
|
|
1133
1132
|
|
|
1134
1133
|
examples:
|
|
1135
1134
|
- program: 'setpath(["a","b"]; 1)'
|
|
1136
|
-
input:
|
|
1135
|
+
input: 'null'
|
|
1137
1136
|
output: ['{"a": {"b": 1}}']
|
|
1138
1137
|
- program: 'setpath(["a","b"]; 1)'
|
|
1139
1138
|
input: '{"a":{"b":0}}'
|
|
1140
1139
|
output: ['{"a": {"b": 1}}']
|
|
1141
1140
|
- program: 'setpath([0,"a"]; 1)'
|
|
1142
|
-
input:
|
|
1141
|
+
input: 'null'
|
|
1143
1142
|
output: ['[{"a":1}]']
|
|
1144
1143
|
|
|
1145
1144
|
- title: "`delpaths(PATHS)`"
|
|
@@ -1169,16 +1168,17 @@ sections:
|
|
|
1169
1168
|
`"value"`, and `"Value"` as keys.
|
|
1170
1169
|
|
|
1171
1170
|
examples:
|
|
1172
|
-
- program:
|
|
1171
|
+
- program: 'to_entries'
|
|
1173
1172
|
input: '{"a": 1, "b": 2}'
|
|
1174
1173
|
output: ['[{"key":"a", "value":1}, {"key":"b", "value":2}]']
|
|
1175
|
-
- program:
|
|
1174
|
+
- program: 'from_entries'
|
|
1176
1175
|
input: '[{"key":"a", "value":1}, {"key":"b", "value":2}]'
|
|
1177
1176
|
output: ['{"a": 1, "b": 2}']
|
|
1178
1177
|
- program: 'with_entries(.key |= "KEY_" + .)'
|
|
1179
1178
|
input: '{"a": 1, "b": 2}'
|
|
1180
1179
|
output: ['{"KEY_a": 1, "KEY_b": 2}']
|
|
1181
1180
|
|
|
1181
|
+
|
|
1182
1182
|
- title: "`select(boolean_expression)`"
|
|
1183
1183
|
body: |
|
|
1184
1184
|
|
|
@@ -1190,13 +1190,14 @@ sections:
|
|
|
1190
1190
|
will give you `[2,3]`.
|
|
1191
1191
|
|
|
1192
1192
|
examples:
|
|
1193
|
-
- program:
|
|
1194
|
-
input:
|
|
1195
|
-
output: [
|
|
1193
|
+
- program: 'map(select(. >= 2))'
|
|
1194
|
+
input: '[1,5,3,0,7]'
|
|
1195
|
+
output: ['[5,3,7]']
|
|
1196
1196
|
- program: '.[] | select(.id == "second")'
|
|
1197
1197
|
input: '[{"id": "first", "val": 1}, {"id": "second", "val": 2}]'
|
|
1198
1198
|
output: ['{"id": "second", "val": 2}']
|
|
1199
1199
|
|
|
1200
|
+
|
|
1200
1201
|
- title: "`arrays`, `objects`, `iterables`, `booleans`, `numbers`, `normals`, `finites`, `strings`, `nulls`, `values`, `scalars`"
|
|
1201
1202
|
body: |
|
|
1202
1203
|
|
|
@@ -1206,9 +1207,9 @@ sections:
|
|
|
1206
1207
|
non-iterables, respectively.
|
|
1207
1208
|
|
|
1208
1209
|
examples:
|
|
1209
|
-
- program:
|
|
1210
|
+
- program: '.[]|numbers'
|
|
1210
1211
|
input: '[[],{},1,"foo",null,true,false]'
|
|
1211
|
-
output: [
|
|
1212
|
+
output: ['1']
|
|
1212
1213
|
|
|
1213
1214
|
- title: "`empty`"
|
|
1214
1215
|
body: |
|
|
@@ -1218,12 +1219,12 @@ sections:
|
|
|
1218
1219
|
It's useful on occasion. You'll know if you need it :)
|
|
1219
1220
|
|
|
1220
1221
|
examples:
|
|
1221
|
-
- program:
|
|
1222
|
-
input:
|
|
1223
|
-
output: [
|
|
1224
|
-
- program:
|
|
1225
|
-
input:
|
|
1226
|
-
output: [
|
|
1222
|
+
- program: '1, empty, 2'
|
|
1223
|
+
input: 'null'
|
|
1224
|
+
output: ['1', '2']
|
|
1225
|
+
- program: '[1,2,empty,3]'
|
|
1226
|
+
input: 'null'
|
|
1227
|
+
output: ['[1,2,3]']
|
|
1227
1228
|
|
|
1228
1229
|
- title: "`error`, `error(message)`"
|
|
1229
1230
|
body: |
|
|
@@ -1233,12 +1234,12 @@ sections:
|
|
|
1233
1234
|
see below.
|
|
1234
1235
|
|
|
1235
1236
|
examples:
|
|
1236
|
-
- program:
|
|
1237
|
+
- program: 'try error catch .'
|
|
1237
1238
|
input: '"error message"'
|
|
1238
1239
|
output: ['"error message"']
|
|
1239
1240
|
|
|
1240
1241
|
- program: 'try error("invalid value: \(.)") catch .'
|
|
1241
|
-
input:
|
|
1242
|
+
input: '42'
|
|
1242
1243
|
output: ['"invalid value: 42"']
|
|
1243
1244
|
|
|
1244
1245
|
- title: "`halt`"
|
|
@@ -1268,7 +1269,7 @@ sections:
|
|
|
1268
1269
|
|
|
1269
1270
|
examples:
|
|
1270
1271
|
- program: 'try error("\($__loc__)") catch .'
|
|
1271
|
-
input:
|
|
1272
|
+
input: 'null'
|
|
1272
1273
|
output: ['"{\"file\":\"<top-level>\",\"line\":1}"']
|
|
1273
1274
|
|
|
1274
1275
|
- title: "`paths`, `paths(node_filter)`"
|
|
@@ -1283,7 +1284,7 @@ sections:
|
|
|
1283
1284
|
values.
|
|
1284
1285
|
|
|
1285
1286
|
examples:
|
|
1286
|
-
- program:
|
|
1287
|
+
- program: '[paths]'
|
|
1287
1288
|
input: '[1,[[],{"a":2}]]'
|
|
1288
1289
|
output: ['[[0],[1],[1,0],[1,1],[1,1,"a"]]']
|
|
1289
1290
|
- program: '[paths(type == "number")]'
|
|
@@ -1306,10 +1307,10 @@ sections:
|
|
|
1306
1307
|
input: '["a","b","c"]'
|
|
1307
1308
|
output: ['"abc"']
|
|
1308
1309
|
- program: add
|
|
1309
|
-
input:
|
|
1310
|
-
output: [
|
|
1310
|
+
input: '[1, 2, 3]'
|
|
1311
|
+
output: ['6']
|
|
1311
1312
|
- program: add
|
|
1312
|
-
input:
|
|
1313
|
+
input: '[]'
|
|
1313
1314
|
output: ["null"]
|
|
1314
1315
|
|
|
1315
1316
|
- title: "`any`, `any(condition)`, `any(generator; condition)`"
|
|
@@ -1329,13 +1330,13 @@ sections:
|
|
|
1329
1330
|
|
|
1330
1331
|
examples:
|
|
1331
1332
|
- program: any
|
|
1332
|
-
input:
|
|
1333
|
+
input: '[true, false]'
|
|
1333
1334
|
output: ["true"]
|
|
1334
1335
|
- program: any
|
|
1335
|
-
input:
|
|
1336
|
+
input: '[false, false]'
|
|
1336
1337
|
output: ["false"]
|
|
1337
1338
|
- program: any
|
|
1338
|
-
input:
|
|
1339
|
+
input: '[]'
|
|
1339
1340
|
output: ["false"]
|
|
1340
1341
|
|
|
1341
1342
|
- title: "`all`, `all(condition)`, `all(generator; condition)`"
|
|
@@ -1355,13 +1356,13 @@ sections:
|
|
|
1355
1356
|
|
|
1356
1357
|
examples:
|
|
1357
1358
|
- program: all
|
|
1358
|
-
input:
|
|
1359
|
+
input: '[true, false]'
|
|
1359
1360
|
output: ["false"]
|
|
1360
1361
|
- program: all
|
|
1361
|
-
input:
|
|
1362
|
+
input: '[true, true]'
|
|
1362
1363
|
output: ["true"]
|
|
1363
1364
|
- program: all
|
|
1364
|
-
input:
|
|
1365
|
+
input: '[]'
|
|
1365
1366
|
output: ["true"]
|
|
1366
1367
|
|
|
1367
1368
|
- title: "`flatten`, `flatten(depth)`"
|
|
@@ -1377,13 +1378,13 @@ sections:
|
|
|
1377
1378
|
|
|
1378
1379
|
examples:
|
|
1379
1380
|
- program: flatten
|
|
1380
|
-
input:
|
|
1381
|
+
input: '[1, [2], [[3]]]'
|
|
1381
1382
|
output: ["[1, 2, 3]"]
|
|
1382
1383
|
- program: flatten(1)
|
|
1383
|
-
input:
|
|
1384
|
+
input: '[1, [2], [[3]]]'
|
|
1384
1385
|
output: ["[1, 2, [3]]"]
|
|
1385
1386
|
- program: flatten
|
|
1386
|
-
input:
|
|
1387
|
+
input: '[[]]'
|
|
1387
1388
|
output: ["[]"]
|
|
1388
1389
|
- program: flatten
|
|
1389
1390
|
input: '[{"foo": "bar"}, [{"foo": "baz"}]]'
|
|
@@ -1407,24 +1408,24 @@ sections:
|
|
|
1407
1408
|
with an increment of `by`.
|
|
1408
1409
|
|
|
1409
1410
|
examples:
|
|
1410
|
-
- program:
|
|
1411
|
-
input:
|
|
1412
|
-
output: [
|
|
1413
|
-
- program:
|
|
1414
|
-
input:
|
|
1415
|
-
output: [
|
|
1416
|
-
- program:
|
|
1417
|
-
input:
|
|
1418
|
-
output: [
|
|
1419
|
-
- program:
|
|
1420
|
-
input:
|
|
1421
|
-
output: [
|
|
1422
|
-
- program:
|
|
1423
|
-
input:
|
|
1424
|
-
output: [
|
|
1425
|
-
- program:
|
|
1426
|
-
input:
|
|
1427
|
-
output: [
|
|
1411
|
+
- program: 'range(2; 4)'
|
|
1412
|
+
input: 'null'
|
|
1413
|
+
output: ['2', '3']
|
|
1414
|
+
- program: '[range(2; 4)]'
|
|
1415
|
+
input: 'null'
|
|
1416
|
+
output: ['[2,3]']
|
|
1417
|
+
- program: '[range(4)]'
|
|
1418
|
+
input: 'null'
|
|
1419
|
+
output: ['[0,1,2,3]']
|
|
1420
|
+
- program: '[range(0; 10; 3)]'
|
|
1421
|
+
input: 'null'
|
|
1422
|
+
output: ['[0,3,6,9]']
|
|
1423
|
+
- program: '[range(0; 10; -1)]'
|
|
1424
|
+
input: 'null'
|
|
1425
|
+
output: ['[]']
|
|
1426
|
+
- program: '[range(0; -5; -1)]'
|
|
1427
|
+
input: 'null'
|
|
1428
|
+
output: ['[0,-1,-2,-3,-4]']
|
|
1428
1429
|
|
|
1429
1430
|
- title: "`floor`"
|
|
1430
1431
|
body: |
|
|
@@ -1432,9 +1433,9 @@ sections:
|
|
|
1432
1433
|
The `floor` function returns the floor of its numeric input.
|
|
1433
1434
|
|
|
1434
1435
|
examples:
|
|
1435
|
-
- program:
|
|
1436
|
-
input:
|
|
1437
|
-
output: [
|
|
1436
|
+
- program: 'floor'
|
|
1437
|
+
input: '3.14159'
|
|
1438
|
+
output: ['3']
|
|
1438
1439
|
|
|
1439
1440
|
- title: "`sqrt`"
|
|
1440
1441
|
body: |
|
|
@@ -1442,9 +1443,9 @@ sections:
|
|
|
1442
1443
|
The `sqrt` function returns the square root of its numeric input.
|
|
1443
1444
|
|
|
1444
1445
|
examples:
|
|
1445
|
-
- program:
|
|
1446
|
-
input:
|
|
1447
|
-
output: [
|
|
1446
|
+
- program: 'sqrt'
|
|
1447
|
+
input: '9'
|
|
1448
|
+
output: ['3']
|
|
1448
1449
|
|
|
1449
1450
|
- title: "`tonumber`"
|
|
1450
1451
|
body: |
|
|
@@ -1454,9 +1455,9 @@ sections:
|
|
|
1454
1455
|
equivalent, leave numbers alone, and give an error on all other input.
|
|
1455
1456
|
|
|
1456
1457
|
examples:
|
|
1457
|
-
- program:
|
|
1458
|
+
- program: '.[] | tonumber'
|
|
1458
1459
|
input: '[1, "1"]'
|
|
1459
|
-
output: [
|
|
1460
|
+
output: ['1', '1']
|
|
1460
1461
|
|
|
1461
1462
|
- title: "`tostring`"
|
|
1462
1463
|
body: |
|
|
@@ -1466,7 +1467,7 @@ sections:
|
|
|
1466
1467
|
JSON-encoded.
|
|
1467
1468
|
|
|
1468
1469
|
examples:
|
|
1469
|
-
- program:
|
|
1470
|
+
- program: '.[] | tostring'
|
|
1470
1471
|
input: '[1, "1", [1]]'
|
|
1471
1472
|
output: ['"1"', '"1"', '"[1]"']
|
|
1472
1473
|
|
|
@@ -1478,10 +1479,9 @@ sections:
|
|
|
1478
1479
|
or object.
|
|
1479
1480
|
|
|
1480
1481
|
examples:
|
|
1481
|
-
- program:
|
|
1482
|
+
- program: 'map(type)'
|
|
1482
1483
|
input: '[0, false, [], {}, null, "hello"]'
|
|
1483
|
-
output:
|
|
1484
|
-
['["number", "boolean", "array", "object", "null", "string"]']
|
|
1484
|
+
output: ['["number", "boolean", "array", "object", "null", "string"]']
|
|
1485
1485
|
|
|
1486
1486
|
- title: "`infinite`, `nan`, `isinfinite`, `isnan`, `isfinite`, `isnormal`"
|
|
1487
1487
|
body: |
|
|
@@ -1500,11 +1500,11 @@ sections:
|
|
|
1500
1500
|
NaNs, and sub-normals do not raise errors.
|
|
1501
1501
|
|
|
1502
1502
|
examples:
|
|
1503
|
-
- program:
|
|
1504
|
-
input:
|
|
1505
|
-
output: [
|
|
1506
|
-
- program:
|
|
1507
|
-
input:
|
|
1503
|
+
- program: '.[] | (infinite * .) < 0'
|
|
1504
|
+
input: '[-1, 1]'
|
|
1505
|
+
output: ['true', 'false']
|
|
1506
|
+
- program: 'infinite, nan | type'
|
|
1507
|
+
input: 'null'
|
|
1508
1508
|
output: ['"number"', '"number"']
|
|
1509
1509
|
|
|
1510
1510
|
- title: "`sort`, `sort_by(path_expression)`"
|
|
@@ -1534,21 +1534,17 @@ sections:
|
|
|
1534
1534
|
equal, and so on.
|
|
1535
1535
|
|
|
1536
1536
|
examples:
|
|
1537
|
-
- program:
|
|
1538
|
-
input:
|
|
1539
|
-
output: [
|
|
1537
|
+
- program: 'sort'
|
|
1538
|
+
input: '[8,3,null,6]'
|
|
1539
|
+
output: ['[null,3,6,8]']
|
|
1540
1540
|
|
|
1541
|
-
- program:
|
|
1541
|
+
- program: 'sort_by(.foo)'
|
|
1542
1542
|
input: '[{"foo":4, "bar":10}, {"foo":3, "bar":10}, {"foo":2, "bar":1}]'
|
|
1543
|
-
output:
|
|
1544
|
-
['[{"foo":2, "bar":1}, {"foo":3, "bar":10}, {"foo":4, "bar":10}]']
|
|
1543
|
+
output: ['[{"foo":2, "bar":1}, {"foo":3, "bar":10}, {"foo":4, "bar":10}]']
|
|
1545
1544
|
|
|
1546
|
-
- program:
|
|
1545
|
+
- program: 'sort_by(.foo, .bar)'
|
|
1547
1546
|
input: '[{"foo":4, "bar":10}, {"foo":3, "bar":20}, {"foo":2, "bar":1}, {"foo":3, "bar":10}]'
|
|
1548
|
-
output:
|
|
1549
|
-
[
|
|
1550
|
-
'[{"foo":2, "bar":1}, {"foo":3, "bar":10}, {"foo":3, "bar":20}, {"foo":4, "bar":10}]',
|
|
1551
|
-
]
|
|
1547
|
+
output: ['[{"foo":2, "bar":1}, {"foo":3, "bar":10}, {"foo":3, "bar":20}, {"foo":4, "bar":10}]']
|
|
1552
1548
|
|
|
1553
1549
|
- title: "`group_by(path_expression)`"
|
|
1554
1550
|
body: |
|
|
@@ -1563,12 +1559,9 @@ sections:
|
|
|
1563
1559
|
in the `sort` function above.
|
|
1564
1560
|
|
|
1565
1561
|
examples:
|
|
1566
|
-
- program:
|
|
1562
|
+
- program: 'group_by(.foo)'
|
|
1567
1563
|
input: '[{"foo":1, "bar":10}, {"foo":3, "bar":100}, {"foo":1, "bar":1}]'
|
|
1568
|
-
output:
|
|
1569
|
-
[
|
|
1570
|
-
'[[{"foo":1, "bar":10}, {"foo":1, "bar":1}], [{"foo":3, "bar":100}]]',
|
|
1571
|
-
]
|
|
1564
|
+
output: ['[[{"foo":1, "bar":10}, {"foo":1, "bar":1}], [{"foo":3, "bar":100}]]']
|
|
1572
1565
|
|
|
1573
1566
|
- title: "`min`, `max`, `min_by(path_exp)`, `max_by(path_exp)`"
|
|
1574
1567
|
body: |
|
|
@@ -1580,10 +1573,10 @@ sections:
|
|
|
1580
1573
|
`min_by(.foo)` finds the object with the smallest `foo` field.
|
|
1581
1574
|
|
|
1582
1575
|
examples:
|
|
1583
|
-
- program:
|
|
1584
|
-
input:
|
|
1585
|
-
output: [
|
|
1586
|
-
- program:
|
|
1576
|
+
- program: 'min'
|
|
1577
|
+
input: '[5,4,2,7]'
|
|
1578
|
+
output: ['2']
|
|
1579
|
+
- program: 'max_by(.foo)'
|
|
1587
1580
|
input: '[{"foo":1, "bar":14}, {"foo":2, "bar":3}]'
|
|
1588
1581
|
output: ['{"foo":2, "bar":3}']
|
|
1589
1582
|
|
|
@@ -1600,13 +1593,13 @@ sections:
|
|
|
1600
1593
|
produced by `group`.
|
|
1601
1594
|
|
|
1602
1595
|
examples:
|
|
1603
|
-
- program:
|
|
1604
|
-
input:
|
|
1605
|
-
output: [
|
|
1606
|
-
- program:
|
|
1596
|
+
- program: 'unique'
|
|
1597
|
+
input: '[1,2,5,3,5,3,1,3]'
|
|
1598
|
+
output: ['[1,2,3,5]']
|
|
1599
|
+
- program: 'unique_by(.foo)'
|
|
1607
1600
|
input: '[{"foo": 1, "bar": 2}, {"foo": 1, "bar": 3}, {"foo": 4, "bar": 5}]'
|
|
1608
1601
|
output: ['[{"foo": 1, "bar": 2}, {"foo": 4, "bar": 5}]']
|
|
1609
|
-
- program:
|
|
1602
|
+
- program: 'unique_by(length)'
|
|
1610
1603
|
input: '["chunky", "bacon", "kitten", "cicada", "asparagus"]'
|
|
1611
1604
|
output: ['["bacon", "chunky", "asparagus"]']
|
|
1612
1605
|
|
|
@@ -1616,9 +1609,9 @@ sections:
|
|
|
1616
1609
|
This function reverses an array.
|
|
1617
1610
|
|
|
1618
1611
|
examples:
|
|
1619
|
-
- program:
|
|
1620
|
-
input:
|
|
1621
|
-
output: [
|
|
1612
|
+
- program: 'reverse'
|
|
1613
|
+
input: '[1,2,3,4]'
|
|
1614
|
+
output: ['[4,3,2,1]']
|
|
1622
1615
|
|
|
1623
1616
|
- title: "`contains(element)`"
|
|
1624
1617
|
body: |
|
|
@@ -1635,19 +1628,19 @@ sections:
|
|
|
1635
1628
|
examples:
|
|
1636
1629
|
- program: 'contains("bar")'
|
|
1637
1630
|
input: '"foobar"'
|
|
1638
|
-
output: [
|
|
1631
|
+
output: ['true']
|
|
1639
1632
|
- program: 'contains(["baz", "bar"])'
|
|
1640
1633
|
input: '["foobar", "foobaz", "blarp"]'
|
|
1641
|
-
output: [
|
|
1634
|
+
output: ['true']
|
|
1642
1635
|
- program: 'contains(["bazzzzz", "bar"])'
|
|
1643
1636
|
input: '["foobar", "foobaz", "blarp"]'
|
|
1644
|
-
output: [
|
|
1645
|
-
- program:
|
|
1637
|
+
output: ['false']
|
|
1638
|
+
- program: 'contains({foo: 12, bar: [{barp: 12}]})'
|
|
1646
1639
|
input: '{"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]}'
|
|
1647
|
-
output: [
|
|
1648
|
-
- program:
|
|
1640
|
+
output: ['true']
|
|
1641
|
+
- program: 'contains({foo: 12, bar: [{barp: 15}]})'
|
|
1649
1642
|
input: '{"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]}'
|
|
1650
|
-
output: [
|
|
1643
|
+
output: ['false']
|
|
1651
1644
|
|
|
1652
1645
|
- title: "`indices(s)`"
|
|
1653
1646
|
body: |
|
|
@@ -1660,13 +1653,13 @@ sections:
|
|
|
1660
1653
|
examples:
|
|
1661
1654
|
- program: 'indices(", ")'
|
|
1662
1655
|
input: '"a,b, cd, efg, hijk"'
|
|
1663
|
-
output: [
|
|
1664
|
-
- program:
|
|
1665
|
-
input:
|
|
1666
|
-
output: [
|
|
1667
|
-
- program:
|
|
1668
|
-
input:
|
|
1669
|
-
output: [
|
|
1656
|
+
output: ['[3,7,12]']
|
|
1657
|
+
- program: 'indices(1)'
|
|
1658
|
+
input: '[0,1,2,1,3,1,4]'
|
|
1659
|
+
output: ['[1,3,5]']
|
|
1660
|
+
- program: 'indices([1,2])'
|
|
1661
|
+
input: '[0,1,2,3,1,4,2,5,1,2,6,7]'
|
|
1662
|
+
output: ['[1,8]']
|
|
1670
1663
|
|
|
1671
1664
|
- title: "`index(s)`, `rindex(s)`"
|
|
1672
1665
|
body: |
|
|
@@ -1677,22 +1670,22 @@ sections:
|
|
|
1677
1670
|
examples:
|
|
1678
1671
|
- program: 'index(", ")'
|
|
1679
1672
|
input: '"a,b, cd, efg, hijk"'
|
|
1680
|
-
output: [
|
|
1681
|
-
- program:
|
|
1682
|
-
input:
|
|
1683
|
-
output: [
|
|
1684
|
-
- program:
|
|
1685
|
-
input:
|
|
1686
|
-
output: [
|
|
1673
|
+
output: ['3']
|
|
1674
|
+
- program: 'index(1)'
|
|
1675
|
+
input: '[0,1,2,1,3,1,4]'
|
|
1676
|
+
output: ['1']
|
|
1677
|
+
- program: 'index([1,2])'
|
|
1678
|
+
input: '[0,1,2,3,1,4,2,5,1,2,6,7]'
|
|
1679
|
+
output: ['1']
|
|
1687
1680
|
- program: 'rindex(", ")'
|
|
1688
1681
|
input: '"a,b, cd, efg, hijk"'
|
|
1689
|
-
output: [
|
|
1690
|
-
- program:
|
|
1691
|
-
input:
|
|
1692
|
-
output: [
|
|
1693
|
-
- program:
|
|
1694
|
-
input:
|
|
1695
|
-
output: [
|
|
1682
|
+
output: ['12']
|
|
1683
|
+
- program: 'rindex(1)'
|
|
1684
|
+
input: '[0,1,2,1,3,1,4]'
|
|
1685
|
+
output: ['5']
|
|
1686
|
+
- program: 'rindex([1,2])'
|
|
1687
|
+
input: '[0,1,2,3,1,4,2,5,1,2,6,7]'
|
|
1688
|
+
output: ['8']
|
|
1696
1689
|
|
|
1697
1690
|
- title: "`inside`"
|
|
1698
1691
|
body: |
|
|
@@ -1704,19 +1697,19 @@ sections:
|
|
|
1704
1697
|
examples:
|
|
1705
1698
|
- program: 'inside("foobar")'
|
|
1706
1699
|
input: '"bar"'
|
|
1707
|
-
output: [
|
|
1700
|
+
output: ['true']
|
|
1708
1701
|
- program: 'inside(["foobar", "foobaz", "blarp"])'
|
|
1709
1702
|
input: '["baz", "bar"]'
|
|
1710
|
-
output: [
|
|
1703
|
+
output: ['true']
|
|
1711
1704
|
- program: 'inside(["foobar", "foobaz", "blarp"])'
|
|
1712
1705
|
input: '["bazzzzz", "bar"]'
|
|
1713
|
-
output: [
|
|
1706
|
+
output: ['false']
|
|
1714
1707
|
- program: 'inside({"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]})'
|
|
1715
1708
|
input: '{"foo": 12, "bar": [{"barp": 12}]}'
|
|
1716
|
-
output: [
|
|
1709
|
+
output: ['true']
|
|
1717
1710
|
- program: 'inside({"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]})'
|
|
1718
1711
|
input: '{"foo": 12, "bar": [{"barp": 15}]}'
|
|
1719
|
-
output: [
|
|
1712
|
+
output: ['false']
|
|
1720
1713
|
|
|
1721
1714
|
- title: "`startswith(str)`"
|
|
1722
1715
|
body: |
|
|
@@ -1726,7 +1719,7 @@ sections:
|
|
|
1726
1719
|
examples:
|
|
1727
1720
|
- program: '[.[]|startswith("foo")]'
|
|
1728
1721
|
input: '["fo", "foo", "barfoo", "foobar", "barfoob"]'
|
|
1729
|
-
output: [
|
|
1722
|
+
output: ['[false, true, false, true, false]']
|
|
1730
1723
|
|
|
1731
1724
|
- title: "`endswith(str)`"
|
|
1732
1725
|
body: |
|
|
@@ -1736,7 +1729,7 @@ sections:
|
|
|
1736
1729
|
examples:
|
|
1737
1730
|
- program: '[.[]|endswith("foo")]'
|
|
1738
1731
|
input: '["foobar", "barfoo"]'
|
|
1739
|
-
output: [
|
|
1732
|
+
output: ['[false, true]']
|
|
1740
1733
|
|
|
1741
1734
|
- title: "`combinations`, `combinations(n)`"
|
|
1742
1735
|
body: |
|
|
@@ -1746,12 +1739,12 @@ sections:
|
|
|
1746
1739
|
of `n` repetitions of the input array.
|
|
1747
1740
|
|
|
1748
1741
|
examples:
|
|
1749
|
-
- program:
|
|
1750
|
-
input:
|
|
1751
|
-
output: [
|
|
1752
|
-
- program:
|
|
1753
|
-
input:
|
|
1754
|
-
output: [
|
|
1742
|
+
- program: 'combinations'
|
|
1743
|
+
input: '[[1,2], [3, 4]]'
|
|
1744
|
+
output: ['[1, 3]', '[1, 4]', '[2, 3]', '[2, 4]']
|
|
1745
|
+
- program: 'combinations(2)'
|
|
1746
|
+
input: '[0, 1]'
|
|
1747
|
+
output: ['[0, 0]', '[0, 1]', '[1, 0]', '[1, 1]']
|
|
1755
1748
|
|
|
1756
1749
|
- title: "`ltrimstr(str)`"
|
|
1757
1750
|
body: |
|
|
@@ -1782,9 +1775,9 @@ sections:
|
|
|
1782
1775
|
codepoint numbers.
|
|
1783
1776
|
|
|
1784
1777
|
examples:
|
|
1785
|
-
- program:
|
|
1778
|
+
- program: 'explode'
|
|
1786
1779
|
input: '"foobar"'
|
|
1787
|
-
output: [
|
|
1780
|
+
output: ['[102,111,111,98,97,114]']
|
|
1788
1781
|
|
|
1789
1782
|
- title: "`implode`"
|
|
1790
1783
|
body: |
|
|
@@ -1792,8 +1785,8 @@ sections:
|
|
|
1792
1785
|
The inverse of explode.
|
|
1793
1786
|
|
|
1794
1787
|
examples:
|
|
1795
|
-
- program:
|
|
1796
|
-
input:
|
|
1788
|
+
- program: 'implode'
|
|
1789
|
+
input: '[65, 66, 67]'
|
|
1797
1790
|
output: ['"ABC"']
|
|
1798
1791
|
|
|
1799
1792
|
- title: "`split(str)`"
|
|
@@ -1836,7 +1829,7 @@ sections:
|
|
|
1836
1829
|
converted to the specified case.
|
|
1837
1830
|
|
|
1838
1831
|
examples:
|
|
1839
|
-
- program:
|
|
1832
|
+
- program: 'ascii_upcase'
|
|
1840
1833
|
input: '"useful but not for é"'
|
|
1841
1834
|
output: ['"USEFUL BUT NOT FOR é"']
|
|
1842
1835
|
|
|
@@ -1852,9 +1845,9 @@ sections:
|
|
|
1852
1845
|
output for each input. See advanced topics below.
|
|
1853
1846
|
|
|
1854
1847
|
examples:
|
|
1855
|
-
- program:
|
|
1856
|
-
input:
|
|
1857
|
-
output: [
|
|
1848
|
+
- program: '[while(.<100; .*2)]'
|
|
1849
|
+
input: '1'
|
|
1850
|
+
output: ['[1,2,4,8,16,32,64]']
|
|
1858
1851
|
|
|
1859
1852
|
- title: "`repeat(exp)`"
|
|
1860
1853
|
body: |
|
|
@@ -1868,9 +1861,9 @@ sections:
|
|
|
1868
1861
|
output for each input. See advanced topics below.
|
|
1869
1862
|
|
|
1870
1863
|
examples:
|
|
1871
|
-
- program:
|
|
1872
|
-
input:
|
|
1873
|
-
output: [
|
|
1864
|
+
- program: '[repeat(.*2, error)?]'
|
|
1865
|
+
input: '1'
|
|
1866
|
+
output: ['[2]']
|
|
1874
1867
|
|
|
1875
1868
|
- title: "`until(cond; next)`"
|
|
1876
1869
|
body: |
|
|
@@ -1886,9 +1879,10 @@ sections:
|
|
|
1886
1879
|
output for each input. See advanced topics below.
|
|
1887
1880
|
|
|
1888
1881
|
examples:
|
|
1889
|
-
- program:
|
|
1890
|
-
input:
|
|
1891
|
-
output: [
|
|
1882
|
+
- program: '[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]'
|
|
1883
|
+
input: '4'
|
|
1884
|
+
output: ['24']
|
|
1885
|
+
|
|
1892
1886
|
|
|
1893
1887
|
- title: "`recurse(f)`, `recurse`, `recurse(f; condition)`"
|
|
1894
1888
|
body: |
|
|
@@ -1929,7 +1923,7 @@ sections:
|
|
|
1929
1923
|
input.
|
|
1930
1924
|
|
|
1931
1925
|
examples:
|
|
1932
|
-
- program:
|
|
1926
|
+
- program: 'recurse(.foo[])'
|
|
1933
1927
|
input: '{"foo":[{"foo": []}, {"foo":[{"foo":[]}]}]}'
|
|
1934
1928
|
output:
|
|
1935
1929
|
- '{"foo":[{"foo":[]},{"foo":[{"foo":[]}]}]}'
|
|
@@ -1937,17 +1931,17 @@ sections:
|
|
|
1937
1931
|
- '{"foo":[{"foo":[]}]}'
|
|
1938
1932
|
- '{"foo":[]}'
|
|
1939
1933
|
|
|
1940
|
-
- program:
|
|
1934
|
+
- program: 'recurse'
|
|
1941
1935
|
input: '{"a":0,"b":[1]}'
|
|
1942
1936
|
output:
|
|
1943
1937
|
- '{"a":0,"b":[1]}'
|
|
1944
|
-
-
|
|
1945
|
-
-
|
|
1946
|
-
-
|
|
1938
|
+
- '0'
|
|
1939
|
+
- '[1]'
|
|
1940
|
+
- '1'
|
|
1947
1941
|
|
|
1948
|
-
- program:
|
|
1949
|
-
input:
|
|
1950
|
-
output: [
|
|
1942
|
+
- program: 'recurse(. * .; . < 20)'
|
|
1943
|
+
input: '2'
|
|
1944
|
+
output: ['2', '4', '16']
|
|
1951
1945
|
|
|
1952
1946
|
- title: "`walk(f)`"
|
|
1953
1947
|
body: |
|
|
@@ -1966,9 +1960,9 @@ sections:
|
|
|
1966
1960
|
|
|
1967
1961
|
examples:
|
|
1968
1962
|
- program: 'walk(if type == "array" then sort else . end)'
|
|
1969
|
-
input:
|
|
1963
|
+
input: '[[4, 1, 7], [8, 5, 2], [3, 6, 9]]'
|
|
1970
1964
|
output:
|
|
1971
|
-
-
|
|
1965
|
+
- '[[1,4,7],[2,5,8],[3,6,9]]'
|
|
1972
1966
|
|
|
1973
1967
|
- program: 'walk( if type == "object" then with_entries( .key |= sub( "^_+"; "") ) else . end )'
|
|
1974
1968
|
input: '[ { "_a": { "__b": 2 } } ]'
|
|
@@ -1985,7 +1979,7 @@ sections:
|
|
|
1985
1979
|
future to include the version strings for the build
|
|
1986
1980
|
tooling used.
|
|
1987
1981
|
|
|
1988
|
-
Note that this can be
|
|
1982
|
+
Note that this can be overridden in the command-line
|
|
1989
1983
|
with `--arg` and related options.
|
|
1990
1984
|
|
|
1991
1985
|
- title: "`$ENV`, `env`"
|
|
@@ -2000,12 +1994,12 @@ sections:
|
|
|
2000
1994
|
variables.
|
|
2001
1995
|
|
|
2002
1996
|
examples:
|
|
2003
|
-
- program:
|
|
2004
|
-
input:
|
|
1997
|
+
- program: '$ENV.PAGER'
|
|
1998
|
+
input: 'null'
|
|
2005
1999
|
output: ['"less"']
|
|
2006
2000
|
|
|
2007
|
-
- program:
|
|
2008
|
-
input:
|
|
2001
|
+
- program: 'env.PAGER'
|
|
2002
|
+
input: 'null'
|
|
2009
2003
|
output: ['"less"']
|
|
2010
2004
|
|
|
2011
2005
|
- title: "`transpose`"
|
|
@@ -2015,9 +2009,9 @@ sections:
|
|
|
2015
2009
|
Rows are padded with nulls so the result is always rectangular.
|
|
2016
2010
|
|
|
2017
2011
|
examples:
|
|
2018
|
-
- program:
|
|
2019
|
-
input:
|
|
2020
|
-
output: [
|
|
2012
|
+
- program: 'transpose'
|
|
2013
|
+
input: '[[1], [2,3]]'
|
|
2014
|
+
output: ['[[1,2],[null,3]]']
|
|
2021
2015
|
|
|
2022
2016
|
- title: "`bsearch(x)`"
|
|
2023
2017
|
body: |
|
|
@@ -2032,15 +2026,15 @@ sections:
|
|
|
2032
2026
|
interest.
|
|
2033
2027
|
|
|
2034
2028
|
examples:
|
|
2035
|
-
- program:
|
|
2036
|
-
input:
|
|
2037
|
-
output: [
|
|
2038
|
-
- program:
|
|
2039
|
-
input:
|
|
2040
|
-
output: [
|
|
2041
|
-
- program:
|
|
2042
|
-
input:
|
|
2043
|
-
output: [
|
|
2029
|
+
- program: 'bsearch(0)'
|
|
2030
|
+
input: '[0,1]'
|
|
2031
|
+
output: ['0']
|
|
2032
|
+
- program: 'bsearch(0)'
|
|
2033
|
+
input: '[1,2,3]'
|
|
2034
|
+
output: ['-1']
|
|
2035
|
+
- program: 'bsearch(4) as $ix | if $ix < 0 then .[-(1+$ix)] = 4 else . end'
|
|
2036
|
+
input: '[1,2,3]'
|
|
2037
|
+
output: ['[1,2,3,4]']
|
|
2044
2038
|
|
|
2045
2039
|
- title: "String interpolation: `\\(exp)`"
|
|
2046
2040
|
body: |
|
|
@@ -2051,7 +2045,7 @@ sections:
|
|
|
2051
2045
|
|
|
2052
2046
|
examples:
|
|
2053
2047
|
- program: '"The input was \(.), which is one less than \(.+1)"'
|
|
2054
|
-
input:
|
|
2048
|
+
input: '42'
|
|
2055
2049
|
output: ['"The input was 42, which is one less than 43"']
|
|
2056
2050
|
|
|
2057
2051
|
- title: "Convert to/from JSON"
|
|
@@ -2063,13 +2057,13 @@ sections:
|
|
|
2063
2057
|
unmodified, while `tojson` encodes strings as JSON strings.
|
|
2064
2058
|
|
|
2065
2059
|
examples:
|
|
2066
|
-
- program:
|
|
2060
|
+
- program: '[.[]|tostring]'
|
|
2067
2061
|
input: '[1, "foo", ["foo"]]'
|
|
2068
2062
|
output: ['["1","foo","[\"foo\"]"]']
|
|
2069
|
-
- program:
|
|
2063
|
+
- program: '[.[]|tojson]'
|
|
2070
2064
|
input: '[1, "foo", ["foo"]]'
|
|
2071
2065
|
output: ['["1","\"foo\"","[\"foo\"]"]']
|
|
2072
|
-
- program:
|
|
2066
|
+
- program: '[.[]|tojson|fromjson]'
|
|
2073
2067
|
input: '[1, "foo", ["foo"]]'
|
|
2074
2068
|
output: ['[1,"foo",["foo"]]']
|
|
2075
2069
|
|
|
@@ -2148,19 +2142,19 @@ sections:
|
|
|
2148
2142
|
not escaped, as they were part of the string literal.
|
|
2149
2143
|
|
|
2150
2144
|
examples:
|
|
2151
|
-
- program:
|
|
2145
|
+
- program: '@html'
|
|
2152
2146
|
input: '"This works if x < y"'
|
|
2153
2147
|
output: ['"This works if x < y"']
|
|
2154
2148
|
|
|
2155
2149
|
- program: '@sh "echo \(.)"'
|
|
2156
|
-
input:
|
|
2150
|
+
input: "\"O'Hara's Ale\""
|
|
2157
2151
|
output: ["\"echo 'O'\\\\''Hara'\\\\''s Ale'\""]
|
|
2158
2152
|
|
|
2159
|
-
- program:
|
|
2153
|
+
- program: '@base64'
|
|
2160
2154
|
input: '"This is a message"'
|
|
2161
2155
|
output: ['"VGhpcyBpcyBhIG1lc3NhZ2U="']
|
|
2162
2156
|
|
|
2163
|
-
- program:
|
|
2157
|
+
- program: '@base64d'
|
|
2164
2158
|
input: '"VGhpcyBpcyBhIG1lc3NhZ2U="'
|
|
2165
2159
|
output: ['"This is a message"']
|
|
2166
2160
|
|
|
@@ -2212,7 +2206,7 @@ sections:
|
|
|
2212
2206
|
|
|
2213
2207
|
The `strptime(fmt)` builtin parses input strings matching the
|
|
2214
2208
|
`fmt` argument. The output is in the "broken down time"
|
|
2215
|
-
representation consumed by `
|
|
2209
|
+
representation consumed by `mktime` and output by `gmtime`.
|
|
2216
2210
|
|
|
2217
2211
|
The `strftime(fmt)` builtin formats a time (GMT) with the
|
|
2218
2212
|
given format. The `strflocaltime` does the same, but using
|
|
@@ -2227,30 +2221,30 @@ sections:
|
|
|
2227
2221
|
`strptime(fmt)` are not supported on macOS.
|
|
2228
2222
|
|
|
2229
2223
|
examples:
|
|
2230
|
-
- program:
|
|
2224
|
+
- program: 'fromdate'
|
|
2231
2225
|
input: '"2015-03-05T23:51:47Z"'
|
|
2232
|
-
output: [
|
|
2226
|
+
output: ['1425599507']
|
|
2233
2227
|
|
|
2234
2228
|
- program: 'strptime("%Y-%m-%dT%H:%M:%SZ")'
|
|
2235
2229
|
input: '"2015-03-05T23:51:47Z"'
|
|
2236
|
-
output: [
|
|
2230
|
+
output: ['[2015,2,5,23,51,47,4,63]']
|
|
2237
2231
|
|
|
2238
2232
|
- program: 'strptime("%Y-%m-%dT%H:%M:%SZ")|mktime'
|
|
2239
2233
|
input: '"2015-03-05T23:51:47Z"'
|
|
2240
|
-
output: [
|
|
2234
|
+
output: ['1425599507']
|
|
2241
2235
|
|
|
2242
2236
|
- title: "SQL-Style Operators"
|
|
2243
2237
|
body: |
|
|
2244
2238
|
|
|
2245
2239
|
jq provides a few SQL-style operators.
|
|
2246
2240
|
|
|
2247
|
-
* INDEX(stream; index_expression)
|
|
2241
|
+
* `INDEX(stream; index_expression)`:
|
|
2248
2242
|
|
|
2249
2243
|
This builtin produces an object whose keys are computed by
|
|
2250
2244
|
the given index expression applied to each value from the
|
|
2251
2245
|
given stream.
|
|
2252
2246
|
|
|
2253
|
-
* JOIN($idx; stream; idx_expr; join_expr)
|
|
2247
|
+
* `JOIN($idx; stream; idx_expr; join_expr)`:
|
|
2254
2248
|
|
|
2255
2249
|
This builtin joins the values from the given stream to the
|
|
2256
2250
|
given index. The index's keys are computed by applying the
|
|
@@ -2259,22 +2253,22 @@ sections:
|
|
|
2259
2253
|
value from the index is fed to the given join expression to
|
|
2260
2254
|
produce each result.
|
|
2261
2255
|
|
|
2262
|
-
* JOIN($idx; stream; idx_expr)
|
|
2256
|
+
* `JOIN($idx; stream; idx_expr)`:
|
|
2263
2257
|
|
|
2264
2258
|
Same as `JOIN($idx; stream; idx_expr; .)`.
|
|
2265
2259
|
|
|
2266
|
-
* JOIN($idx; idx_expr)
|
|
2260
|
+
* `JOIN($idx; idx_expr)`:
|
|
2267
2261
|
|
|
2268
2262
|
This builtin joins the input `.` to the given index, applying
|
|
2269
2263
|
the given index expression to `.` to compute the index key.
|
|
2270
2264
|
The join operation is as described above.
|
|
2271
2265
|
|
|
2272
|
-
* IN(s)
|
|
2266
|
+
* `IN(s)`:
|
|
2273
2267
|
|
|
2274
2268
|
This builtin outputs `true` if `.` appears in the given
|
|
2275
2269
|
stream, otherwise it outputs `false`.
|
|
2276
2270
|
|
|
2277
|
-
* IN(source; s)
|
|
2271
|
+
* `IN(source; s)`:
|
|
2278
2272
|
|
|
2279
2273
|
This builtin outputs `true` if any value in the source stream
|
|
2280
2274
|
appears in the second stream, otherwise it outputs `false`.
|
|
@@ -2302,17 +2296,17 @@ sections:
|
|
|
2302
2296
|
!= is "not equal", and 'a != b' returns the opposite value of 'a == b'
|
|
2303
2297
|
|
|
2304
2298
|
examples:
|
|
2305
|
-
- program:
|
|
2306
|
-
input:
|
|
2307
|
-
output: [
|
|
2299
|
+
- program: '. == false'
|
|
2300
|
+
input: 'null'
|
|
2301
|
+
output: ['false']
|
|
2308
2302
|
|
|
2309
2303
|
- program: '. == {"b": {"d": (4 + 1e-20), "c": 3}, "a":1}'
|
|
2310
2304
|
input: '{"a":1, "b": {"c": 3, "d": 4}}'
|
|
2311
|
-
output: [
|
|
2305
|
+
output: ['true']
|
|
2312
2306
|
|
|
2313
|
-
- program:
|
|
2307
|
+
- program: '.[] == 1'
|
|
2314
2308
|
input: '[1, 1.0, "1", "banana"]'
|
|
2315
|
-
output: [
|
|
2309
|
+
output: ['true', 'true', 'false', 'false']
|
|
2316
2310
|
|
|
2317
2311
|
- title: if-then-else-end
|
|
2318
2312
|
body: |
|
|
@@ -2347,7 +2341,7 @@ sections:
|
|
|
2347
2341
|
else
|
|
2348
2342
|
"many"
|
|
2349
2343
|
end
|
|
2350
|
-
input:
|
|
2344
|
+
input: '2'
|
|
2351
2345
|
output: ['"many"']
|
|
2352
2346
|
|
|
2353
2347
|
- title: "`>`, `>=`, `<=`, `<`"
|
|
@@ -2361,9 +2355,9 @@ sections:
|
|
|
2361
2355
|
The ordering is the same as that described for `sort`, above.
|
|
2362
2356
|
|
|
2363
2357
|
examples:
|
|
2364
|
-
- program:
|
|
2365
|
-
input:
|
|
2366
|
-
output: [
|
|
2358
|
+
- program: '. < 5'
|
|
2359
|
+
input: '2'
|
|
2360
|
+
output: ['true']
|
|
2367
2361
|
|
|
2368
2362
|
- title: "`and`, `or`, `not`"
|
|
2369
2363
|
body: |
|
|
@@ -2390,17 +2384,17 @@ sections:
|
|
|
2390
2384
|
|
|
2391
2385
|
examples:
|
|
2392
2386
|
- program: '42 and "a string"'
|
|
2393
|
-
input:
|
|
2394
|
-
output: [
|
|
2395
|
-
- program:
|
|
2396
|
-
input:
|
|
2397
|
-
output: [
|
|
2398
|
-
- program:
|
|
2399
|
-
input:
|
|
2400
|
-
output: [
|
|
2401
|
-
- program:
|
|
2402
|
-
input:
|
|
2403
|
-
output: [
|
|
2387
|
+
input: 'null'
|
|
2388
|
+
output: ['true']
|
|
2389
|
+
- program: '(true, false) or false'
|
|
2390
|
+
input: 'null'
|
|
2391
|
+
output: ['true', 'false']
|
|
2392
|
+
- program: '(true, true) and (true, false)'
|
|
2393
|
+
input: 'null'
|
|
2394
|
+
output: ['true', 'false', 'true', 'false']
|
|
2395
|
+
- program: '[true, false | not]'
|
|
2396
|
+
input: 'null'
|
|
2397
|
+
output: ['[false, true]']
|
|
2404
2398
|
|
|
2405
2399
|
- title: "Alternative operator: `//`"
|
|
2406
2400
|
body: |
|
|
@@ -2437,21 +2431,21 @@ sections:
|
|
|
2437
2431
|
produced.
|
|
2438
2432
|
|
|
2439
2433
|
examples:
|
|
2440
|
-
- program:
|
|
2441
|
-
input:
|
|
2442
|
-
output: [
|
|
2443
|
-
- program:
|
|
2434
|
+
- program: 'empty // 42'
|
|
2435
|
+
input: 'null'
|
|
2436
|
+
output: ['42']
|
|
2437
|
+
- program: '.foo // 42'
|
|
2444
2438
|
input: '{"foo": 19}'
|
|
2445
|
-
output: [
|
|
2446
|
-
- program:
|
|
2447
|
-
input:
|
|
2448
|
-
output: [
|
|
2449
|
-
- program:
|
|
2450
|
-
input:
|
|
2451
|
-
output: [
|
|
2452
|
-
- program:
|
|
2453
|
-
input:
|
|
2454
|
-
output: [
|
|
2439
|
+
output: ['19']
|
|
2440
|
+
- program: '.foo // 42'
|
|
2441
|
+
input: '{}'
|
|
2442
|
+
output: ['42']
|
|
2443
|
+
- program: '(false, null, 1) // 42'
|
|
2444
|
+
input: 'null'
|
|
2445
|
+
output: ['1']
|
|
2446
|
+
- program: '(false, null, 1) | . // 42'
|
|
2447
|
+
input: 'null'
|
|
2448
|
+
output: ['42', '42', '1']
|
|
2455
2449
|
|
|
2456
2450
|
- title: try-catch
|
|
2457
2451
|
body: |
|
|
@@ -2466,13 +2460,13 @@ sections:
|
|
|
2466
2460
|
|
|
2467
2461
|
examples:
|
|
2468
2462
|
- program: 'try .a catch ". is not an object"'
|
|
2469
|
-
input:
|
|
2463
|
+
input: 'true'
|
|
2470
2464
|
output: ['". is not an object"']
|
|
2471
|
-
- program:
|
|
2465
|
+
- program: '[.[]|try .a]'
|
|
2472
2466
|
input: '[{}, true, {"a":1}]'
|
|
2473
|
-
output: [
|
|
2467
|
+
output: ['[null, 1]']
|
|
2474
2468
|
- program: 'try error("some exception") catch .'
|
|
2475
|
-
input:
|
|
2469
|
+
input: 'true'
|
|
2476
2470
|
output: ['"some exception"']
|
|
2477
2471
|
|
|
2478
2472
|
- title: Breaking out of control structures
|
|
@@ -2493,7 +2487,7 @@ sections:
|
|
|
2493
2487
|
label $out | ... break $out ...
|
|
2494
2488
|
|
|
2495
2489
|
The `break $label_name` expression will cause the program to
|
|
2496
|
-
|
|
2490
|
+
act as though the nearest (to the left) `label $label_name`
|
|
2497
2491
|
produced `empty`.
|
|
2498
2492
|
|
|
2499
2493
|
The relationship between the `break` and corresponding `label`
|
|
@@ -2515,12 +2509,12 @@ sections:
|
|
|
2515
2509
|
The `?` operator, used as `EXP?`, is shorthand for `try EXP`.
|
|
2516
2510
|
|
|
2517
2511
|
examples:
|
|
2518
|
-
- program:
|
|
2512
|
+
- program: '[.[] | .a?]'
|
|
2519
2513
|
input: '[{}, true, {"a":1}]'
|
|
2520
|
-
output: [
|
|
2521
|
-
- program:
|
|
2514
|
+
output: ['[null, 1]']
|
|
2515
|
+
- program: '[.[] | tonumber?]'
|
|
2522
2516
|
input: '["1", "invalid", "3", 4]'
|
|
2523
|
-
output: [
|
|
2517
|
+
output: ['[1, 3, 4]']
|
|
2524
2518
|
|
|
2525
2519
|
- title: Regular expressions
|
|
2526
2520
|
body: |
|
|
@@ -2582,10 +2576,10 @@ sections:
|
|
|
2582
2576
|
examples:
|
|
2583
2577
|
- program: 'test("foo")'
|
|
2584
2578
|
input: '"foo"'
|
|
2585
|
-
output: [
|
|
2579
|
+
output: ['true']
|
|
2586
2580
|
- program: '.[] | test("a b c # spaces are ignored"; "ix")'
|
|
2587
2581
|
input: '["xabcd", "ABC"]'
|
|
2588
|
-
output: [
|
|
2582
|
+
output: ['true', 'true']
|
|
2589
2583
|
|
|
2590
2584
|
- title: "`match(val)`, `match(regex; flags)`"
|
|
2591
2585
|
body: |
|
|
@@ -2611,33 +2605,33 @@ sections:
|
|
|
2611
2605
|
- program: 'match("(abc)+"; "g")'
|
|
2612
2606
|
input: '"abc abc"'
|
|
2613
2607
|
output:
|
|
2614
|
-
|
|
2615
|
-
|
|
2608
|
+
- '{"offset": 0, "length": 3, "string": "abc", "captures": [{"offset": 0, "length": 3, "string": "abc", "name": null}]}'
|
|
2609
|
+
- '{"offset": 4, "length": 3, "string": "abc", "captures": [{"offset": 4, "length": 3, "string": "abc", "name": null}]}'
|
|
2616
2610
|
- program: 'match("foo")'
|
|
2617
2611
|
input: '"foo bar foo"'
|
|
2618
|
-
output:
|
|
2619
|
-
['{"offset": 0, "length": 3, "string": "foo", "captures": []}']
|
|
2612
|
+
output: ['{"offset": 0, "length": 3, "string": "foo", "captures": []}']
|
|
2620
2613
|
- program: 'match(["foo", "ig"])'
|
|
2621
2614
|
input: '"foo bar FOO"'
|
|
2622
2615
|
output:
|
|
2623
|
-
|
|
2624
|
-
|
|
2616
|
+
- '{"offset": 0, "length": 3, "string": "foo", "captures": []}'
|
|
2617
|
+
- '{"offset": 8, "length": 3, "string": "FOO", "captures": []}'
|
|
2625
2618
|
- program: 'match("foo (?<bar123>bar)? foo"; "ig")'
|
|
2626
2619
|
input: '"foo bar foo foo foo"'
|
|
2627
2620
|
output:
|
|
2628
|
-
|
|
2629
|
-
|
|
2621
|
+
- '{"offset": 0, "length": 11, "string": "foo bar foo", "captures": [{"offset": 4, "length": 3, "string": "bar", "name": "bar123"}]}'
|
|
2622
|
+
- '{"offset": 12, "length": 8, "string": "foo foo", "captures": [{"offset": -1, "length": 0, "string": null, "name": "bar123"}]}'
|
|
2630
2623
|
|
|
2631
2624
|
- program: '[ match("."; "g")] | length'
|
|
2632
2625
|
input: '"abc"'
|
|
2633
|
-
output: [
|
|
2626
|
+
output: ['3']
|
|
2627
|
+
|
|
2634
2628
|
|
|
2635
2629
|
- title: "`capture(val)`, `capture(regex; flags)`"
|
|
2636
2630
|
body: |
|
|
2637
2631
|
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2632
|
+
Collects the named captures in a JSON object, with the name
|
|
2633
|
+
of each capture as the key, and the matched string as the
|
|
2634
|
+
corresponding value.
|
|
2641
2635
|
|
|
2642
2636
|
examples:
|
|
2643
2637
|
- program: 'capture("(?<a>[a-z]+)-(?<n>[0-9]+)")'
|
|
@@ -2651,12 +2645,17 @@ sections:
|
|
|
2651
2645
|
that match the regex in accordance with the flags, if any
|
|
2652
2646
|
have been specified. If there is no match, the stream is empty.
|
|
2653
2647
|
To capture all the matches for each input string, use the idiom
|
|
2654
|
-
`[ expr ]`, e.g. `[ scan(regex) ]`.
|
|
2648
|
+
`[ expr ]`, e.g. `[ scan(regex) ]`. If the regex contains capturing
|
|
2649
|
+
groups, the filter emits a stream of arrays, each of which contains
|
|
2650
|
+
the captured strings.
|
|
2655
2651
|
|
|
2656
2652
|
examples:
|
|
2657
2653
|
- program: 'scan("c")'
|
|
2658
2654
|
input: '"abcdefabc"'
|
|
2659
2655
|
output: ['"c"', '"c"']
|
|
2656
|
+
- program: 'scan("(a+)(b+)")'
|
|
2657
|
+
input: '"abaabbaaabbb"'
|
|
2658
|
+
output: ['["a","b"]', '["aa","bb"]', '["aaa","bbb"]']
|
|
2660
2659
|
|
|
2661
2660
|
- title: "`split(regex; flags)`"
|
|
2662
2661
|
body: |
|
|
@@ -2671,6 +2670,7 @@ sections:
|
|
|
2671
2670
|
input: '"ab,cd, ef"'
|
|
2672
2671
|
output: ['["ab","cd","ef"]']
|
|
2673
2672
|
|
|
2673
|
+
|
|
2674
2674
|
- title: "`splits(regex)`, `splits(regex; flags)`"
|
|
2675
2675
|
body: |
|
|
2676
2676
|
|
|
@@ -2680,7 +2680,7 @@ sections:
|
|
|
2680
2680
|
examples:
|
|
2681
2681
|
- program: 'splits(", *")'
|
|
2682
2682
|
input: '"ab,cd, ef, gh"'
|
|
2683
|
-
output: ['"ab"',
|
|
2683
|
+
output: ['"ab"','"cd"','"ef"','"gh"']
|
|
2684
2684
|
|
|
2685
2685
|
- title: "`sub(regex; tostring)`, `sub(regex; tostring; flags)`"
|
|
2686
2686
|
body: |
|
|
@@ -2719,6 +2719,7 @@ sections:
|
|
|
2719
2719
|
input: '"p"'
|
|
2720
2720
|
output: ['["a","b"]']
|
|
2721
2721
|
|
|
2722
|
+
|
|
2722
2723
|
- title: Advanced features
|
|
2723
2724
|
body: |
|
|
2724
2725
|
Variables are an absolute necessity in most programming languages, but
|
|
@@ -2794,7 +2795,7 @@ sections:
|
|
|
2794
2795
|
{"title": "First post", "author": "Anonymous Coward"}
|
|
2795
2796
|
{"title": "A well-written article", "author": "Person McPherson"}
|
|
2796
2797
|
|
|
2797
|
-
We use a variable,
|
|
2798
|
+
We use a variable, `$names`, to store the realnames object, so that we
|
|
2798
2799
|
can refer to it later when looking up author usernames:
|
|
2799
2800
|
|
|
2800
2801
|
.realnames as $names | .posts[] | {title, author: $names[.author]}
|
|
@@ -2837,20 +2838,20 @@ sections:
|
|
|
2837
2838
|
will not be visible where the old one was.
|
|
2838
2839
|
|
|
2839
2840
|
examples:
|
|
2840
|
-
- program:
|
|
2841
|
+
- program: '.bar as $x | .foo | . + $x'
|
|
2841
2842
|
input: '{"foo":10, "bar":200}'
|
|
2842
|
-
output: [
|
|
2843
|
-
- program:
|
|
2844
|
-
input:
|
|
2845
|
-
output: [
|
|
2846
|
-
- program:
|
|
2843
|
+
output: ['210']
|
|
2844
|
+
- program: '. as $i|[(.*2|. as $i| $i), $i]'
|
|
2845
|
+
input: '5'
|
|
2846
|
+
output: ['[10,5]']
|
|
2847
|
+
- program: '. as [$a, $b, {c: $c}] | $a + $b + $c'
|
|
2847
2848
|
input: '[2, 3, {"c": 4, "d": 5}]'
|
|
2848
|
-
output: [
|
|
2849
|
-
- program:
|
|
2850
|
-
input:
|
|
2849
|
+
output: ['9']
|
|
2850
|
+
- program: '.[] as [$a, $b] | {a: $a, b: $b}'
|
|
2851
|
+
input: '[[0], [0, 1], [2, 1, 0]]'
|
|
2851
2852
|
output: ['{"a":0,"b":null}', '{"a":0,"b":1}', '{"a":2,"b":1}']
|
|
2852
2853
|
|
|
2853
|
-
- title:
|
|
2854
|
+
- title: 'Destructuring Alternative Operator: `?//`'
|
|
2854
2855
|
body: |
|
|
2855
2856
|
|
|
2856
2857
|
The destructuring alternative operator provides a concise mechanism
|
|
@@ -2886,18 +2887,17 @@ sections:
|
|
|
2886
2887
|
[[3]] | .[] as [$a] ?// [$b] | if $a != null then error("err: \($a)") else {$a,$b} end
|
|
2887
2888
|
|
|
2888
2889
|
examples:
|
|
2889
|
-
- program:
|
|
2890
|
+
- program: '.[] as {$a, $b, c: {$d, $e}} ?// {$a, $b, c: [{$d, $e}]} | {$a, $b, $d, $e}'
|
|
2890
2891
|
input: '[{"a": 1, "b": 2, "c": {"d": 3, "e": 4}}, {"a": 1, "b": 2, "c": [{"d": 3, "e": 4}]}]'
|
|
2891
2892
|
output: ['{"a":1,"b":2,"d":3,"e":4}', '{"a":1,"b":2,"d":3,"e":4}']
|
|
2892
|
-
- program:
|
|
2893
|
+
- program: '.[] as {$a, $b, c: {$d}} ?// {$a, $b, c: [{$e}]} | {$a, $b, $d, $e}'
|
|
2893
2894
|
input: '[{"a": 1, "b": 2, "c": {"d": 3, "e": 4}}, {"a": 1, "b": 2, "c": [{"d": 3, "e": 4}]}]'
|
|
2894
|
-
output:
|
|
2895
|
-
['{"a":1,"b":2,"d":3,"e":null}', '{"a":1,"b":2,"d":null,"e":4}']
|
|
2895
|
+
output: ['{"a":1,"b":2,"d":3,"e":null}', '{"a":1,"b":2,"d":null,"e":4}']
|
|
2896
2896
|
- program: '.[] as [$a] ?// [$b] | if $a != null then error("err: \($a)") else {$a,$b} end'
|
|
2897
|
-
input:
|
|
2897
|
+
input: '[[3]]'
|
|
2898
2898
|
output: ['{"a":null,"b":3}']
|
|
2899
2899
|
|
|
2900
|
-
- title:
|
|
2900
|
+
- title: 'Defining Functions'
|
|
2901
2901
|
body: |
|
|
2902
2902
|
|
|
2903
2903
|
You can give a filter a name using "def" syntax:
|
|
@@ -2948,14 +2948,14 @@ sections:
|
|
|
2948
2948
|
See also the section below on scoping.
|
|
2949
2949
|
|
|
2950
2950
|
examples:
|
|
2951
|
-
- program:
|
|
2952
|
-
input:
|
|
2953
|
-
output: [
|
|
2954
|
-
- program:
|
|
2955
|
-
input:
|
|
2956
|
-
output: [
|
|
2951
|
+
- program: 'def addvalue(f): . + [f]; map(addvalue(.[0]))'
|
|
2952
|
+
input: '[[1,2],[10,20]]'
|
|
2953
|
+
output: ['[[1,2,1], [10,20,10]]']
|
|
2954
|
+
- program: 'def addvalue(f): f as $x | map(. + $x); addvalue(.[0])'
|
|
2955
|
+
input: '[[1,2],[10,20]]'
|
|
2956
|
+
output: ['[[1,2,1,2], [10,20,1,2]]']
|
|
2957
2957
|
|
|
2958
|
-
- title:
|
|
2958
|
+
- title: 'Scoping'
|
|
2959
2959
|
body: |
|
|
2960
2960
|
|
|
2961
2961
|
There are two types of symbols in jq: value bindings (a.k.a.,
|
|
@@ -2978,17 +2978,17 @@ sections:
|
|
|
2978
2978
|
Returns true if `exp` produces no outputs, false otherwise.
|
|
2979
2979
|
|
|
2980
2980
|
examples:
|
|
2981
|
-
- program:
|
|
2982
|
-
input:
|
|
2983
|
-
output: [
|
|
2981
|
+
- program: 'isempty(empty)'
|
|
2982
|
+
input: 'null'
|
|
2983
|
+
output: ['true']
|
|
2984
2984
|
|
|
2985
|
-
- program:
|
|
2986
|
-
input:
|
|
2987
|
-
output: [
|
|
2985
|
+
- program: 'isempty(.[])'
|
|
2986
|
+
input: '[]'
|
|
2987
|
+
output: ['true']
|
|
2988
2988
|
|
|
2989
|
-
- program:
|
|
2990
|
-
input:
|
|
2991
|
-
output: [
|
|
2989
|
+
- program: 'isempty(.[])'
|
|
2990
|
+
input: '[1,2,3]'
|
|
2991
|
+
output: ['false']
|
|
2992
2992
|
|
|
2993
2993
|
- title: "`limit(n; exp)`"
|
|
2994
2994
|
body: |
|
|
@@ -2996,9 +2996,9 @@ sections:
|
|
|
2996
2996
|
The `limit` function extracts up to `n` outputs from `exp`.
|
|
2997
2997
|
|
|
2998
2998
|
examples:
|
|
2999
|
-
- program:
|
|
3000
|
-
input:
|
|
3001
|
-
output: [
|
|
2999
|
+
- program: '[limit(3;.[])]'
|
|
3000
|
+
input: '[0,1,2,3,4,5,6,7,8,9]'
|
|
3001
|
+
output: ['[0,1,2]']
|
|
3002
3002
|
|
|
3003
3003
|
- title: "`first(expr)`, `last(expr)`, `nth(n; expr)`"
|
|
3004
3004
|
body: |
|
|
@@ -3010,9 +3010,9 @@ sections:
|
|
|
3010
3010
|
Note that `nth(n; expr)` doesn't support negative values of `n`.
|
|
3011
3011
|
|
|
3012
3012
|
examples:
|
|
3013
|
-
- program:
|
|
3014
|
-
input:
|
|
3015
|
-
output: [
|
|
3013
|
+
- program: '[first(range(.)), last(range(.)), nth(./2; range(.))]'
|
|
3014
|
+
input: '10'
|
|
3015
|
+
output: ['[0,9,5]']
|
|
3016
3016
|
|
|
3017
3017
|
- title: "`first`, `last`, `nth(n)`"
|
|
3018
3018
|
body: |
|
|
@@ -3023,9 +3023,9 @@ sections:
|
|
|
3023
3023
|
The `nth(n)` function extracts the nth value of any array at `.`.
|
|
3024
3024
|
|
|
3025
3025
|
examples:
|
|
3026
|
-
- program:
|
|
3027
|
-
input:
|
|
3028
|
-
output: [
|
|
3026
|
+
- program: '[range(.)]|[first, last, nth(5)]'
|
|
3027
|
+
input: '10'
|
|
3028
|
+
output: ['[0,9,5]']
|
|
3029
3029
|
|
|
3030
3030
|
- title: "`reduce`"
|
|
3031
3031
|
body: |
|
|
@@ -3047,15 +3047,15 @@ sections:
|
|
|
3047
3047
|
3 as $item | . + $item
|
|
3048
3048
|
|
|
3049
3049
|
examples:
|
|
3050
|
-
- program:
|
|
3051
|
-
input:
|
|
3052
|
-
output: [
|
|
3050
|
+
- program: 'reduce .[] as $item (0; . + $item)'
|
|
3051
|
+
input: '[1,2,3,4,5]'
|
|
3052
|
+
output: ['15']
|
|
3053
3053
|
|
|
3054
|
-
- program:
|
|
3055
|
-
input:
|
|
3056
|
-
output: [
|
|
3054
|
+
- program: 'reduce .[] as [$i,$j] (0; . + $i * $j)'
|
|
3055
|
+
input: '[[1,2],[3,4],[5,6]]'
|
|
3056
|
+
output: ['44']
|
|
3057
3057
|
|
|
3058
|
-
- program:
|
|
3058
|
+
- program: 'reduce .[] as {$x,$y} (null; .x += $x | .y += [$y])'
|
|
3059
3059
|
input: '[{"x":"a","y":1},{"x":"b","y":2},{"x":"c","y":3}]'
|
|
3060
3060
|
output: ['{"x":"abc","y":[1,2,3]}']
|
|
3061
3061
|
|
|
@@ -3086,15 +3086,15 @@ sections:
|
|
|
3086
3086
|
That is, it outputs the intermediate values as they are.
|
|
3087
3087
|
|
|
3088
3088
|
examples:
|
|
3089
|
-
- program:
|
|
3090
|
-
input:
|
|
3091
|
-
output: [
|
|
3089
|
+
- program: 'foreach .[] as $item (0; . + $item)'
|
|
3090
|
+
input: '[1,2,3,4,5]'
|
|
3091
|
+
output: ['1','3','6','10','15']
|
|
3092
3092
|
|
|
3093
|
-
- program:
|
|
3094
|
-
input:
|
|
3095
|
-
output: [
|
|
3093
|
+
- program: 'foreach .[] as $item (0; . + $item; [$item, . * 2])'
|
|
3094
|
+
input: '[1,2,3,4,5]'
|
|
3095
|
+
output: ['[1,2]','[2,6]','[3,12]','[4,20]','[5,30]']
|
|
3096
3096
|
|
|
3097
|
-
- program:
|
|
3097
|
+
- program: 'foreach .[] as $item (0; . + 1; {index: ., $item})'
|
|
3098
3098
|
input: '["foo", "bar", "baz"]'
|
|
3099
3099
|
output:
|
|
3100
3100
|
- '{"index":1,"item":"foo"}'
|
|
@@ -3130,52 +3130,51 @@ sections:
|
|
|
3130
3130
|
- title: Generators and iterators
|
|
3131
3131
|
body: |
|
|
3132
3132
|
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
examples:
|
|
3160
|
-
- program:
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
- title: "Math"
|
|
3133
|
+
Some jq operators and functions are actually generators in
|
|
3134
|
+
that they can produce zero, one, or more values for each
|
|
3135
|
+
input, just as one might expect in other programming
|
|
3136
|
+
languages that have generators. For example, `.[]`
|
|
3137
|
+
generates all the values in its input (which must be an
|
|
3138
|
+
array or an object), `range(0; 10)` generates the integers
|
|
3139
|
+
between 0 and 10, and so on.
|
|
3140
|
+
|
|
3141
|
+
Even the comma operator is a generator, generating first
|
|
3142
|
+
the values generated by the expression to the left of the
|
|
3143
|
+
comma, then the values generated by the expression on the
|
|
3144
|
+
right of the comma.
|
|
3145
|
+
|
|
3146
|
+
The `empty` builtin is the generator that produces zero
|
|
3147
|
+
outputs. The `empty` builtin backtracks to the preceding
|
|
3148
|
+
generator expression.
|
|
3149
|
+
|
|
3150
|
+
All jq functions can be generators just by using builtin
|
|
3151
|
+
generators. It is also possible to construct new generators
|
|
3152
|
+
using only recursion and the comma operator. If
|
|
3153
|
+
recursive calls are "in tail position" then the
|
|
3154
|
+
generator will be efficient. In the example below the
|
|
3155
|
+
recursive call by `_range` to itself is in tail position.
|
|
3156
|
+
The example shows off three advanced topics: tail recursion,
|
|
3157
|
+
generator construction, and sub-functions.
|
|
3158
|
+
|
|
3159
|
+
examples:
|
|
3160
|
+
- program: 'def range(init; upto; by):
|
|
3161
|
+
def _range:
|
|
3162
|
+
if (by > 0 and . < upto) or (by < 0 and . > upto)
|
|
3163
|
+
then ., ((.+by)|_range)
|
|
3164
|
+
else empty end;
|
|
3165
|
+
if init == upto then empty elif by == 0 then init else init|_range end;
|
|
3166
|
+
range(0; 10; 3)'
|
|
3167
|
+
input: 'null'
|
|
3168
|
+
output: ['0', '3', '6', '9']
|
|
3169
|
+
- program: 'def while(cond; update):
|
|
3170
|
+
def _while:
|
|
3171
|
+
if cond then ., (update | _while) else empty end;
|
|
3172
|
+
_while;
|
|
3173
|
+
[while(.<100; .*2)]'
|
|
3174
|
+
input: '1'
|
|
3175
|
+
output: ['[1,2,4,8,16,32,64]']
|
|
3176
|
+
|
|
3177
|
+
- title: 'Math'
|
|
3179
3178
|
body: |
|
|
3180
3179
|
|
|
3181
3180
|
jq currently only has IEEE754 double-precision (64-bit) floating
|
|
@@ -3210,7 +3209,7 @@ sections:
|
|
|
3210
3209
|
|
|
3211
3210
|
See your system's manual for more information on each of these.
|
|
3212
3211
|
|
|
3213
|
-
- title:
|
|
3212
|
+
- title: 'I/O'
|
|
3214
3213
|
body: |
|
|
3215
3214
|
|
|
3216
3215
|
At this time jq has minimal support for I/O, mostly in the
|
|
@@ -3240,7 +3239,7 @@ sections:
|
|
|
3240
3239
|
|
|
3241
3240
|
Outputs one new input.
|
|
3242
3241
|
|
|
3243
|
-
Note that when using `input` it is generally
|
|
3242
|
+
Note that when using `input` it is generally necessary to
|
|
3244
3243
|
invoke jq with the `-n` command-line option, otherwise
|
|
3245
3244
|
the first entity will be lost.
|
|
3246
3245
|
|
|
@@ -3303,7 +3302,7 @@ sections:
|
|
|
3303
3302
|
|
|
3304
3303
|
Returns the line number of the input currently being filtered.
|
|
3305
3304
|
|
|
3306
|
-
- title:
|
|
3305
|
+
- title: 'Streaming'
|
|
3307
3306
|
body: |
|
|
3308
3307
|
|
|
3309
3308
|
With the `--stream` option jq can parse input texts in a streaming
|
|
@@ -3317,8 +3316,8 @@ sections:
|
|
|
3317
3316
|
|
|
3318
3317
|
Several builtins are provided to make handling streams easier.
|
|
3319
3318
|
|
|
3320
|
-
The examples below use the streamed form of `[
|
|
3321
|
-
`[[0],
|
|
3319
|
+
The examples below use the streamed form of `["a",["b"]]`, which is
|
|
3320
|
+
`[[0],"a"],[[1,0],"b"],[[1,0]],[[1]]`.
|
|
3322
3321
|
|
|
3323
3322
|
Streaming forms include `[<path>, <leaf-value>]` (to indicate any
|
|
3324
3323
|
scalar value, empty array, or empty object), and `[<path>]` (to
|
|
@@ -3335,9 +3334,9 @@ sections:
|
|
|
3335
3334
|
given streaming expression.
|
|
3336
3335
|
|
|
3337
3336
|
examples:
|
|
3338
|
-
- program:
|
|
3339
|
-
input:
|
|
3340
|
-
output: [
|
|
3337
|
+
- program: 'truncate_stream([[0],"a"],[[1,0],"b"],[[1,0]],[[1]])'
|
|
3338
|
+
input: '1'
|
|
3339
|
+
output: ['[[0],"b"]', '[[0]]']
|
|
3341
3340
|
|
|
3342
3341
|
- title: "`fromstream(stream_expression)`"
|
|
3343
3342
|
body: |
|
|
@@ -3346,9 +3345,9 @@ sections:
|
|
|
3346
3345
|
outputs.
|
|
3347
3346
|
|
|
3348
3347
|
examples:
|
|
3349
|
-
- program:
|
|
3350
|
-
input:
|
|
3351
|
-
output: [
|
|
3348
|
+
- program: 'fromstream(1|truncate_stream([[0],"a"],[[1,0],"b"],[[1,0]],[[1]]))'
|
|
3349
|
+
input: 'null'
|
|
3350
|
+
output: ['["b"]']
|
|
3352
3351
|
|
|
3353
3352
|
- title: "`tostream`"
|
|
3354
3353
|
body: |
|
|
@@ -3356,9 +3355,9 @@ sections:
|
|
|
3356
3355
|
The `tostream` builtin outputs the streamed form of its input.
|
|
3357
3356
|
|
|
3358
3357
|
examples:
|
|
3359
|
-
- program:
|
|
3358
|
+
- program: '. as $dot|fromstream($dot|tostream)|.==$dot'
|
|
3360
3359
|
input: '[0,[1,{"a":1},{"b":2}]]'
|
|
3361
|
-
output: [
|
|
3360
|
+
output: ['true']
|
|
3362
3361
|
|
|
3363
3362
|
- title: Assignment
|
|
3364
3363
|
body: |
|
|
@@ -3432,8 +3431,8 @@ sections:
|
|
|
3432
3431
|
|
|
3433
3432
|
examples:
|
|
3434
3433
|
- program: '(..|select(type=="boolean")) |= if . then 1 else 0 end'
|
|
3435
|
-
input:
|
|
3436
|
-
output: [
|
|
3434
|
+
input: '[true,false,[5,true,[true,[false]],false]]'
|
|
3435
|
+
output: ['[1,0,[5,1,[1,[0]],0]]']
|
|
3437
3436
|
|
|
3438
3437
|
- title: "Arithmetic update-assignment: `+=`, `-=`, `*=`, `/=`, `%=`, `//=`"
|
|
3439
3438
|
body: |
|
|
@@ -3488,14 +3487,14 @@ sections:
|
|
|
3488
3487
|
output: ['{"a":10,"b":20}']
|
|
3489
3488
|
|
|
3490
3489
|
- program: (.a, .b) = range(3)
|
|
3491
|
-
input:
|
|
3490
|
+
input: 'null'
|
|
3492
3491
|
output:
|
|
3493
3492
|
- '{"a":0,"b":0}'
|
|
3494
3493
|
- '{"a":1,"b":1}'
|
|
3495
3494
|
- '{"a":2,"b":2}'
|
|
3496
3495
|
|
|
3497
3496
|
- program: (.a, .b) |= range(3)
|
|
3498
|
-
input:
|
|
3497
|
+
input: 'null'
|
|
3499
3498
|
output: ['{"a":0,"b":0}']
|
|
3500
3499
|
|
|
3501
3500
|
- title: Complex assignments
|
|
@@ -3548,7 +3547,7 @@ sections:
|
|
|
3548
3547
|
path (see below). The `import` and `include` directives allow the
|
|
3549
3548
|
importer to alter this path.
|
|
3550
3549
|
|
|
3551
|
-
Paths in the
|
|
3550
|
+
Paths in the search path are subject to various substitutions.
|
|
3552
3551
|
|
|
3553
3552
|
For paths starting with `~/`, the user's home directory is
|
|
3554
3553
|
substituted for `~`.
|