@port-labs/jq-node-bindings 0.0.14 → 0.0.15-dev1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (453) hide show
  1. package/README.md +6 -1
  2. package/binding.gyp +41 -19
  3. package/configure +1 -1
  4. package/deps/jq/.gitattributes +12 -0
  5. package/deps/jq/AUTHORS +149 -43
  6. package/deps/jq/COPYING +75 -1
  7. package/deps/jq/ChangeLog +2 -2
  8. package/deps/jq/Makefile.am +106 -65
  9. package/deps/jq/NEWS.md +391 -0
  10. package/deps/jq/README.md +54 -52
  11. package/deps/jq/SECURITY.md +7 -0
  12. package/deps/jq/compile-ios.sh +106 -102
  13. package/deps/jq/configure.ac +72 -59
  14. package/deps/jq/docs/Pipfile +14 -0
  15. package/deps/jq/docs/Pipfile.lock +415 -0
  16. package/deps/jq/docs/README.md +15 -14
  17. package/deps/jq/docs/build_manpage.py +251 -0
  18. package/deps/jq/docs/build_mantests.py +21 -0
  19. package/deps/jq/docs/build_website.py +95 -0
  20. package/deps/jq/docs/content/download/default.yml +249 -0
  21. package/deps/jq/docs/content/index.yml +83 -0
  22. package/deps/jq/docs/content/{3.manual/v1.6 → manual/dev}/manual.yml +992 -452
  23. package/deps/jq/docs/content/{3.manual → manual}/v1.3/manual.yml +105 -116
  24. package/deps/jq/docs/content/{3.manual → manual}/v1.4/manual.yml +122 -129
  25. package/deps/jq/docs/content/{3.manual → manual}/v1.5/manual.yml +313 -262
  26. package/deps/jq/docs/content/{3.manual → manual/v1.6}/manual.yml +407 -332
  27. package/deps/jq/docs/content/manual/v1.7/manual.yml +3697 -0
  28. package/deps/jq/docs/content/tutorial/default.yml +337 -0
  29. package/deps/jq/docs/manual_schema.yml +60 -0
  30. package/deps/jq/docs/public/css/style.css +99 -0
  31. package/deps/jq/docs/public/icon.png +0 -0
  32. package/deps/jq/docs/public/icon.svg +1 -0
  33. package/deps/jq/docs/public/jq.svg +1 -0
  34. package/deps/jq/docs/public/js/manual-search.js +31 -49
  35. package/deps/jq/docs/templates/default.html.j2 +31 -0
  36. package/deps/jq/docs/templates/index.html.j2 +58 -0
  37. package/deps/jq/docs/templates/manual.html.j2 +120 -0
  38. package/deps/jq/docs/templates/shared/_footer.html.j2 +14 -0
  39. package/deps/jq/docs/templates/shared/_head.html.j2 +23 -0
  40. package/deps/jq/docs/templates/shared/_navbar.html.j2 +40 -0
  41. package/deps/jq/docs/validate_manual_schema.py +19 -0
  42. package/deps/jq/jq.1.prebuilt +1102 -294
  43. package/deps/jq/jq.spec +2 -3
  44. package/deps/jq/libjq.pc.in +11 -0
  45. package/deps/jq/m4/ax_pthread.m4 +522 -0
  46. package/deps/jq/modules/oniguruma/.travis.yml +17 -0
  47. package/deps/jq/modules/oniguruma/CMakeLists.txt +206 -41
  48. package/deps/jq/modules/oniguruma/COPYING +23 -25
  49. package/deps/jq/modules/oniguruma/HISTORY +368 -23
  50. package/deps/jq/modules/oniguruma/Makefile.am +61 -7
  51. package/deps/jq/modules/oniguruma/README +34 -20
  52. package/deps/jq/modules/oniguruma/README.md +106 -33
  53. package/deps/jq/modules/oniguruma/README_japanese +183 -0
  54. package/deps/jq/modules/oniguruma/autogen.sh +9 -0
  55. package/deps/jq/modules/oniguruma/cmake/Config.cmake.in +4 -0
  56. package/deps/jq/modules/oniguruma/configure.ac +66 -55
  57. package/deps/jq/modules/oniguruma/doc/API +485 -42
  58. package/deps/jq/modules/oniguruma/doc/API.ja +732 -293
  59. package/deps/jq/modules/oniguruma/doc/CALLOUTS.API +397 -0
  60. package/deps/jq/modules/oniguruma/doc/CALLOUTS.API.ja +393 -0
  61. package/deps/jq/modules/oniguruma/doc/CALLOUTS.BUILTIN +95 -0
  62. package/deps/jq/modules/oniguruma/doc/CALLOUTS.BUILTIN.ja +93 -0
  63. package/deps/jq/modules/oniguruma/doc/FAQ +3 -3
  64. package/deps/jq/modules/oniguruma/doc/FAQ.ja +8 -8
  65. package/deps/jq/modules/oniguruma/doc/RE +223 -63
  66. package/deps/jq/modules/oniguruma/doc/RE.ja +420 -265
  67. package/deps/jq/modules/oniguruma/doc/SYNTAX.md +1091 -0
  68. package/deps/jq/modules/oniguruma/doc/UNICODE_PROPERTIES +840 -697
  69. package/deps/jq/modules/oniguruma/harnesses/ascii_compatible.dict +113 -0
  70. package/deps/jq/modules/oniguruma/harnesses/base.c +749 -0
  71. package/deps/jq/modules/oniguruma/harnesses/deluxe.c +206 -0
  72. package/deps/jq/modules/oniguruma/harnesses/dict_conv.py +72 -0
  73. package/deps/jq/modules/oniguruma/harnesses/fuzzer.options +2 -0
  74. package/deps/jq/modules/oniguruma/harnesses/libfuzzer-onig.cpp +45 -0
  75. package/deps/jq/modules/oniguruma/harnesses/regset.c +392 -0
  76. package/deps/jq/modules/oniguruma/index.html +16 -5
  77. package/deps/jq/modules/oniguruma/index_ja.html +16 -5
  78. package/deps/jq/modules/oniguruma/make_win.bat +5 -0
  79. package/deps/jq/modules/oniguruma/make_win32.bat +5 -3
  80. package/deps/jq/modules/oniguruma/make_win64.bat +5 -3
  81. package/deps/jq/modules/oniguruma/onig-config.cmake.in +80 -0
  82. package/deps/jq/modules/oniguruma/onig-config.in +1 -1
  83. package/deps/jq/modules/oniguruma/oniguruma.pc.cmake.in +1 -1
  84. package/deps/jq/modules/oniguruma/oniguruma.pc.in +0 -1
  85. package/deps/jq/modules/oniguruma/sample/CMakeLists.txt +9 -2
  86. package/deps/jq/modules/oniguruma/sample/Makefile.am +24 -5
  87. package/deps/jq/modules/oniguruma/sample/bug_fix.c +13 -51
  88. package/deps/jq/modules/oniguruma/sample/callback_each_match.c +168 -0
  89. package/deps/jq/modules/oniguruma/sample/callout.c +268 -0
  90. package/deps/jq/modules/oniguruma/sample/count.c +125 -0
  91. package/deps/jq/modules/oniguruma/sample/crnl.c +6 -4
  92. package/deps/jq/modules/oniguruma/sample/echo.c +136 -0
  93. package/deps/jq/modules/oniguruma/sample/encode.c +53 -146
  94. package/deps/jq/modules/oniguruma/sample/listcap.c +18 -10
  95. package/deps/jq/modules/oniguruma/sample/names.c +10 -6
  96. package/deps/jq/modules/oniguruma/sample/posix.c +13 -2
  97. package/deps/jq/modules/oniguruma/sample/regset.c +95 -0
  98. package/deps/jq/modules/oniguruma/sample/scan.c +20 -6
  99. package/deps/jq/modules/oniguruma/sample/simple.c +8 -4
  100. package/deps/jq/modules/oniguruma/sample/sql.c +13 -8
  101. package/deps/jq/modules/oniguruma/sample/syntax.c +11 -10
  102. package/deps/jq/modules/oniguruma/sample/user_property.c +12 -7
  103. package/deps/jq/modules/oniguruma/src/Makefile.am +41 -15
  104. package/deps/jq/modules/oniguruma/src/Makefile.windows +196 -183
  105. package/deps/jq/modules/oniguruma/src/ascii.c +64 -7
  106. package/deps/jq/modules/oniguruma/src/big5.c +25 -15
  107. package/deps/jq/modules/oniguruma/src/config.h.cmake.in +7 -22
  108. package/deps/jq/modules/oniguruma/src/config.h.win32 +56 -84
  109. package/deps/jq/modules/oniguruma/src/config.h.win64 +56 -84
  110. package/deps/jq/modules/oniguruma/src/config.h.windows.in +62 -0
  111. package/deps/jq/modules/oniguruma/src/cp1251.c +14 -8
  112. package/deps/jq/modules/oniguruma/src/euc_jp.c +28 -30
  113. package/deps/jq/modules/oniguruma/src/euc_jp_prop.c +25 -32
  114. package/deps/jq/modules/oniguruma/src/euc_jp_prop.gperf +1 -2
  115. package/deps/jq/modules/oniguruma/src/euc_kr.c +27 -15
  116. package/deps/jq/modules/oniguruma/src/euc_tw.c +40 -17
  117. package/deps/jq/modules/oniguruma/src/gb18030.c +177 -119
  118. package/deps/jq/modules/oniguruma/src/gperf_fold_key_conv.py +12 -8
  119. package/deps/jq/modules/oniguruma/src/gperf_unfold_key_conv.py +8 -6
  120. package/deps/jq/modules/oniguruma/src/iso8859_1.c +92 -91
  121. package/deps/jq/modules/oniguruma/src/iso8859_10.c +13 -29
  122. package/deps/jq/modules/oniguruma/src/iso8859_11.c +4 -2
  123. package/deps/jq/modules/oniguruma/src/iso8859_13.c +13 -33
  124. package/deps/jq/modules/oniguruma/src/iso8859_14.c +13 -30
  125. package/deps/jq/modules/oniguruma/src/iso8859_15.c +13 -34
  126. package/deps/jq/modules/oniguruma/src/iso8859_16.c +13 -29
  127. package/deps/jq/modules/oniguruma/src/iso8859_2.c +13 -29
  128. package/deps/jq/modules/oniguruma/src/iso8859_3.c +13 -33
  129. package/deps/jq/modules/oniguruma/src/iso8859_4.c +13 -32
  130. package/deps/jq/modules/oniguruma/src/iso8859_5.c +16 -23
  131. package/deps/jq/modules/oniguruma/src/iso8859_6.c +4 -2
  132. package/deps/jq/modules/oniguruma/src/iso8859_7.c +14 -29
  133. package/deps/jq/modules/oniguruma/src/iso8859_8.c +4 -2
  134. package/deps/jq/modules/oniguruma/src/iso8859_9.c +13 -33
  135. package/deps/jq/modules/oniguruma/src/koi8.c +14 -27
  136. package/deps/jq/modules/oniguruma/src/koi8_r.c +12 -19
  137. package/deps/jq/modules/oniguruma/src/make_property.sh +21 -0
  138. package/deps/jq/modules/oniguruma/src/make_unicode_egcb.sh +7 -0
  139. package/deps/jq/modules/oniguruma/src/make_unicode_egcb_data.py +267 -0
  140. package/deps/jq/modules/oniguruma/src/make_unicode_fold.sh +25 -11
  141. package/deps/jq/modules/oniguruma/src/make_unicode_fold_data.py +206 -26
  142. package/deps/jq/modules/oniguruma/src/make_unicode_property.sh +19 -10
  143. package/deps/jq/modules/oniguruma/src/make_unicode_property_data.py +474 -375
  144. package/deps/jq/modules/oniguruma/src/make_unicode_wb.sh +7 -0
  145. package/deps/jq/modules/oniguruma/src/make_unicode_wb_data.py +267 -0
  146. package/deps/jq/modules/oniguruma/src/mktable.c +28 -24
  147. package/deps/jq/modules/oniguruma/src/onig_init.c +2 -2
  148. package/deps/jq/modules/oniguruma/src/oniggnu.h +7 -5
  149. package/deps/jq/modules/oniguruma/src/onigposix.h +40 -16
  150. package/deps/jq/modules/oniguruma/src/oniguruma.h +357 -107
  151. package/deps/jq/modules/oniguruma/src/regcomp.c +6214 -3933
  152. package/deps/jq/modules/oniguruma/src/regenc.c +197 -120
  153. package/deps/jq/modules/oniguruma/src/regenc.h +106 -63
  154. package/deps/jq/modules/oniguruma/src/regerror.c +112 -91
  155. package/deps/jq/modules/oniguruma/src/regexec.c +4876 -2010
  156. package/deps/jq/modules/oniguruma/src/regext.c +8 -8
  157. package/deps/jq/modules/oniguruma/src/reggnu.c +13 -17
  158. package/deps/jq/modules/oniguruma/src/regint.h +757 -491
  159. package/deps/jq/modules/oniguruma/src/regparse.c +7204 -3240
  160. package/deps/jq/modules/oniguruma/src/regparse.h +361 -218
  161. package/deps/jq/modules/oniguruma/src/regposerr.c +49 -9
  162. package/deps/jq/modules/oniguruma/src/regposix.c +106 -24
  163. package/deps/jq/modules/oniguruma/src/regsyntax.c +66 -13
  164. package/deps/jq/modules/oniguruma/src/regtrav.c +1 -1
  165. package/deps/jq/modules/oniguruma/src/regversion.c +6 -4
  166. package/deps/jq/modules/oniguruma/src/sjis.c +23 -52
  167. package/deps/jq/modules/oniguruma/src/sjis_prop.c +25 -32
  168. package/deps/jq/modules/oniguruma/src/sjis_prop.gperf +1 -2
  169. package/deps/jq/modules/oniguruma/src/st.c +248 -249
  170. package/deps/jq/modules/oniguruma/src/st.h +4 -5
  171. package/deps/jq/modules/oniguruma/src/unicode.c +869 -294
  172. package/deps/jq/modules/oniguruma/src/unicode_egcb_data.c +1419 -0
  173. package/deps/jq/modules/oniguruma/src/unicode_fold1_key.c +1829 -1300
  174. package/deps/jq/modules/oniguruma/src/unicode_fold2_key.c +32 -9
  175. package/deps/jq/modules/oniguruma/src/unicode_fold3_key.c +32 -9
  176. package/deps/jq/modules/oniguruma/src/unicode_fold_data.c +1210 -984
  177. package/deps/jq/modules/oniguruma/src/unicode_property_data.c +22480 -15198
  178. package/deps/jq/modules/oniguruma/src/unicode_property_data_posix.c +1463 -591
  179. package/deps/jq/modules/oniguruma/src/unicode_unfold_key.c +1958 -1418
  180. package/deps/jq/modules/oniguruma/src/unicode_wb_data.c +1106 -0
  181. package/deps/jq/modules/oniguruma/src/utf16_be.c +90 -49
  182. package/deps/jq/modules/oniguruma/src/utf16_le.c +80 -49
  183. package/deps/jq/modules/oniguruma/src/utf32_be.c +14 -42
  184. package/deps/jq/modules/oniguruma/src/utf32_le.c +13 -40
  185. package/deps/jq/modules/oniguruma/src/utf8.c +33 -78
  186. package/deps/jq/modules/oniguruma/test/CMakeLists.txt +55 -0
  187. package/deps/jq/modules/oniguruma/test/Makefile.am +65 -10
  188. package/deps/jq/modules/oniguruma/test/test.sh +17 -0
  189. package/deps/jq/modules/oniguruma/test/test_back.c +1450 -0
  190. package/deps/jq/modules/oniguruma/test/test_options.c +228 -0
  191. package/deps/jq/modules/oniguruma/test/test_regset.c +466 -0
  192. package/deps/jq/modules/oniguruma/test/test_syntax.c +365 -0
  193. package/deps/jq/modules/oniguruma/test/test_utf8.c +1761 -0
  194. package/deps/jq/modules/oniguruma/test/testc.c +128 -88
  195. package/deps/jq/modules/oniguruma/test/testp.c +613 -0
  196. package/deps/jq/modules/oniguruma/test/testu.c +75 -28
  197. package/deps/jq/modules/oniguruma/tis-ci/stub.c +3 -0
  198. package/deps/jq/modules/oniguruma/tis-ci/test_back.config +26 -0
  199. package/deps/jq/modules/oniguruma/tis-ci/test_regset.config +20 -0
  200. package/deps/jq/modules/oniguruma/tis-ci/test_syntax.config +26 -0
  201. package/deps/jq/modules/oniguruma/tis-ci/test_utf8.config +25 -0
  202. package/deps/jq/modules/oniguruma/tis-ci/testc.config +26 -0
  203. package/deps/jq/modules/oniguruma/tis-ci/testu.config +24 -0
  204. package/deps/jq/modules/oniguruma/tis.config +1336 -0
  205. package/deps/jq/modules/oniguruma/windows/CMakeLists.txt +8 -0
  206. package/deps/jq/modules/oniguruma/windows/testc.c +865 -869
  207. package/deps/jq/scripts/update-website +6 -5
  208. package/deps/jq/scripts/version +10 -7
  209. package/deps/jq/sig/jq-release-new.key +29 -0
  210. package/deps/jq/sig/v1.4/sha256sum.txt +1 -0
  211. package/deps/jq/sig/v1.5/sha256sum.txt +2 -0
  212. package/deps/jq/sig/v1.5rc1/sha256sum.txt +1 -0
  213. package/deps/jq/sig/v1.5rc2/sha256sum.txt +2 -0
  214. package/deps/jq/sig/v1.6/sha256sum.txt +2 -0
  215. package/deps/jq/sig/v1.7/jq-1.7.tar.gz.asc +16 -0
  216. package/deps/jq/sig/v1.7/jq-1.7.zip.asc +16 -0
  217. package/deps/jq/sig/v1.7/jq-linux-amd64.asc +16 -0
  218. package/deps/jq/sig/v1.7/jq-linux-arm64.asc +16 -0
  219. package/deps/jq/sig/v1.7/jq-linux-armel.asc +16 -0
  220. package/deps/jq/sig/v1.7/jq-linux-armhf.asc +16 -0
  221. package/deps/jq/sig/v1.7/jq-linux-i386.asc +16 -0
  222. package/deps/jq/sig/v1.7/jq-linux-mips.asc +16 -0
  223. package/deps/jq/sig/v1.7/jq-linux-mips64.asc +16 -0
  224. package/deps/jq/sig/v1.7/jq-linux-mips64el.asc +16 -0
  225. package/deps/jq/sig/v1.7/jq-linux-mips64r6.asc +16 -0
  226. package/deps/jq/sig/v1.7/jq-linux-mips64r6el.asc +16 -0
  227. package/deps/jq/sig/v1.7/jq-linux-mipsel.asc +16 -0
  228. package/deps/jq/sig/v1.7/jq-linux-mipsr6.asc +16 -0
  229. package/deps/jq/sig/v1.7/jq-linux-mipsr6el.asc +16 -0
  230. package/deps/jq/sig/v1.7/jq-linux-powerpc.asc +16 -0
  231. package/deps/jq/sig/v1.7/jq-linux-ppc64el.asc +16 -0
  232. package/deps/jq/sig/v1.7/jq-linux-riscv64.asc +16 -0
  233. package/deps/jq/sig/v1.7/jq-linux-s390x.asc +16 -0
  234. package/deps/jq/sig/v1.7/jq-macos-amd64.asc +16 -0
  235. package/deps/jq/sig/v1.7/jq-macos-arm64.asc +16 -0
  236. package/deps/jq/sig/v1.7/jq-windows-amd64.exe.asc +16 -0
  237. package/deps/jq/sig/v1.7/jq-windows-i386.exe.asc +16 -0
  238. package/deps/jq/sig/v1.7/sha256sum.txt +23 -0
  239. package/deps/jq/sig/v1.7.1/jq-1.7.1.tar.gz.asc +16 -0
  240. package/deps/jq/sig/v1.7.1/jq-1.7.1.zip.asc +16 -0
  241. package/deps/jq/sig/v1.7.1/jq-linux-amd64.asc +16 -0
  242. package/deps/jq/sig/v1.7.1/jq-linux-arm64.asc +16 -0
  243. package/deps/jq/sig/v1.7.1/jq-linux-armel.asc +16 -0
  244. package/deps/jq/sig/v1.7.1/jq-linux-armhf.asc +16 -0
  245. package/deps/jq/sig/v1.7.1/jq-linux-i386.asc +16 -0
  246. package/deps/jq/sig/v1.7.1/jq-linux-mips.asc +16 -0
  247. package/deps/jq/sig/v1.7.1/jq-linux-mips64.asc +16 -0
  248. package/deps/jq/sig/v1.7.1/jq-linux-mips64el.asc +16 -0
  249. package/deps/jq/sig/v1.7.1/jq-linux-mips64r6.asc +16 -0
  250. package/deps/jq/sig/v1.7.1/jq-linux-mips64r6el.asc +16 -0
  251. package/deps/jq/sig/v1.7.1/jq-linux-mipsel.asc +16 -0
  252. package/deps/jq/sig/v1.7.1/jq-linux-mipsr6.asc +16 -0
  253. package/deps/jq/sig/v1.7.1/jq-linux-mipsr6el.asc +16 -0
  254. package/deps/jq/sig/v1.7.1/jq-linux-powerpc.asc +16 -0
  255. package/deps/jq/sig/v1.7.1/jq-linux-ppc64el.asc +16 -0
  256. package/deps/jq/sig/v1.7.1/jq-linux-riscv64.asc +16 -0
  257. package/deps/jq/sig/v1.7.1/jq-linux-s390x.asc +16 -0
  258. package/deps/jq/sig/v1.7.1/jq-linux64.asc +16 -0
  259. package/deps/jq/sig/v1.7.1/jq-macos-amd64.asc +16 -0
  260. package/deps/jq/sig/v1.7.1/jq-macos-arm64.asc +16 -0
  261. package/deps/jq/sig/v1.7.1/jq-osx-amd64.asc +16 -0
  262. package/deps/jq/sig/v1.7.1/jq-win64.exe.asc +16 -0
  263. package/deps/jq/sig/v1.7.1/jq-windows-amd64.exe.asc +16 -0
  264. package/deps/jq/sig/v1.7.1/jq-windows-i386.exe.asc +16 -0
  265. package/deps/jq/sig/v1.7.1/sha256sum.txt +26 -0
  266. package/deps/jq/sig/v1.7rc1/jq-1.7rc1.tar.gz.asc +16 -0
  267. package/deps/jq/sig/v1.7rc1/jq-1.7rc1.zip.asc +16 -0
  268. package/deps/jq/sig/v1.7rc1/jq-linux-amd64.asc +16 -0
  269. package/deps/jq/sig/v1.7rc1/jq-linux-arm64.asc +16 -0
  270. package/deps/jq/sig/v1.7rc1/jq-linux-armel.asc +16 -0
  271. package/deps/jq/sig/v1.7rc1/jq-linux-armhf.asc +16 -0
  272. package/deps/jq/sig/v1.7rc1/jq-linux-i386.asc +16 -0
  273. package/deps/jq/sig/v1.7rc1/jq-linux-mips.asc +16 -0
  274. package/deps/jq/sig/v1.7rc1/jq-linux-mips64.asc +16 -0
  275. package/deps/jq/sig/v1.7rc1/jq-linux-mips64el.asc +16 -0
  276. package/deps/jq/sig/v1.7rc1/jq-linux-mips64r6.asc +16 -0
  277. package/deps/jq/sig/v1.7rc1/jq-linux-mips64r6el.asc +16 -0
  278. package/deps/jq/sig/v1.7rc1/jq-linux-mipsel.asc +16 -0
  279. package/deps/jq/sig/v1.7rc1/jq-linux-mipsr6.asc +16 -0
  280. package/deps/jq/sig/v1.7rc1/jq-linux-mipsr6el.asc +16 -0
  281. package/deps/jq/sig/v1.7rc1/jq-linux-powerpc.asc +16 -0
  282. package/deps/jq/sig/v1.7rc1/jq-linux-ppc64el.asc +16 -0
  283. package/deps/jq/sig/v1.7rc1/jq-linux-riscv64.asc +16 -0
  284. package/deps/jq/sig/v1.7rc1/jq-linux-s390x.asc +16 -0
  285. package/deps/jq/sig/v1.7rc1/jq-macos-amd64.asc +16 -0
  286. package/deps/jq/sig/v1.7rc1/jq-macos-arm64.asc +16 -0
  287. package/deps/jq/sig/v1.7rc1/jq-windows-amd64.exe.asc +16 -0
  288. package/deps/jq/sig/v1.7rc1/jq-windows-i386.exe.asc +16 -0
  289. package/deps/jq/sig/v1.7rc1/sha256sum.txt +23 -0
  290. package/deps/jq/sig/v1.7rc2/jq-1.7rc2.tar.gz.asc +16 -0
  291. package/deps/jq/sig/v1.7rc2/jq-1.7rc2.zip.asc +16 -0
  292. package/deps/jq/sig/v1.7rc2/jq-linux-amd64.asc +16 -0
  293. package/deps/jq/sig/v1.7rc2/jq-linux-arm64.asc +16 -0
  294. package/deps/jq/sig/v1.7rc2/jq-linux-armel.asc +16 -0
  295. package/deps/jq/sig/v1.7rc2/jq-linux-armhf.asc +16 -0
  296. package/deps/jq/sig/v1.7rc2/jq-linux-i386.asc +16 -0
  297. package/deps/jq/sig/v1.7rc2/jq-linux-mips.asc +16 -0
  298. package/deps/jq/sig/v1.7rc2/jq-linux-mips64.asc +16 -0
  299. package/deps/jq/sig/v1.7rc2/jq-linux-mips64el.asc +16 -0
  300. package/deps/jq/sig/v1.7rc2/jq-linux-mips64r6.asc +16 -0
  301. package/deps/jq/sig/v1.7rc2/jq-linux-mips64r6el.asc +16 -0
  302. package/deps/jq/sig/v1.7rc2/jq-linux-mipsel.asc +16 -0
  303. package/deps/jq/sig/v1.7rc2/jq-linux-mipsr6.asc +16 -0
  304. package/deps/jq/sig/v1.7rc2/jq-linux-mipsr6el.asc +16 -0
  305. package/deps/jq/sig/v1.7rc2/jq-linux-powerpc.asc +16 -0
  306. package/deps/jq/sig/v1.7rc2/jq-linux-ppc64el.asc +16 -0
  307. package/deps/jq/sig/v1.7rc2/jq-linux-riscv64.asc +16 -0
  308. package/deps/jq/sig/v1.7rc2/jq-linux-s390x.asc +16 -0
  309. package/deps/jq/sig/v1.7rc2/jq-macos-amd64.asc +16 -0
  310. package/deps/jq/sig/v1.7rc2/jq-macos-arm64.asc +16 -0
  311. package/deps/jq/sig/v1.7rc2/jq-windows-amd64.exe.asc +16 -0
  312. package/deps/jq/sig/v1.7rc2/jq-windows-i386.exe.asc +16 -0
  313. package/deps/jq/sig/v1.7rc2/sha256sum.txt +23 -0
  314. package/deps/jq/src/builtin.c +537 -343
  315. package/deps/jq/src/builtin.h +18 -0
  316. package/deps/jq/src/builtin.jq +116 -143
  317. package/deps/jq/src/bytecode.h +8 -4
  318. package/deps/jq/src/compile.c +157 -143
  319. package/deps/jq/src/compile.h +3 -4
  320. package/deps/jq/src/decNumber/ICU-license.html +45 -0
  321. package/deps/jq/src/decNumber/decBasic.c +3908 -0
  322. package/deps/jq/src/decNumber/decCommon.c +1835 -0
  323. package/deps/jq/src/decNumber/decContext.c +437 -0
  324. package/deps/jq/src/decNumber/decContext.h +254 -0
  325. package/deps/jq/src/decNumber/decDPD.h +1185 -0
  326. package/deps/jq/src/decNumber/decDouble.c +140 -0
  327. package/deps/jq/src/decNumber/decDouble.h +155 -0
  328. package/deps/jq/src/decNumber/decNumber.c +8143 -0
  329. package/deps/jq/src/decNumber/decNumber.h +182 -0
  330. package/deps/jq/src/decNumber/decNumberLocal.h +757 -0
  331. package/deps/jq/src/decNumber/decPacked.c +220 -0
  332. package/deps/jq/src/decNumber/decPacked.h +52 -0
  333. package/deps/jq/src/decNumber/decQuad.c +135 -0
  334. package/deps/jq/src/decNumber/decQuad.h +177 -0
  335. package/deps/jq/src/decNumber/decSingle.c +71 -0
  336. package/deps/jq/src/decNumber/decSingle.h +86 -0
  337. package/deps/jq/src/decNumber/decimal128.c +553 -0
  338. package/deps/jq/src/decNumber/decimal128.h +81 -0
  339. package/deps/jq/src/decNumber/decimal32.c +476 -0
  340. package/deps/jq/src/decNumber/decimal32.h +81 -0
  341. package/deps/jq/src/decNumber/decimal64.c +839 -0
  342. package/deps/jq/src/decNumber/decimal64.h +83 -0
  343. package/deps/jq/src/decNumber/decnumber.pdf +0 -0
  344. package/deps/jq/src/decNumber/example1.c +38 -0
  345. package/deps/jq/src/decNumber/example2.c +52 -0
  346. package/deps/jq/src/decNumber/example3.c +64 -0
  347. package/deps/jq/src/decNumber/example4.c +61 -0
  348. package/deps/jq/src/decNumber/example5.c +36 -0
  349. package/deps/jq/src/decNumber/example6.c +61 -0
  350. package/deps/jq/src/decNumber/example7.c +35 -0
  351. package/deps/jq/src/decNumber/example8.c +39 -0
  352. package/deps/jq/src/decNumber/readme.txt +81 -0
  353. package/deps/jq/src/exec_stack.h +5 -3
  354. package/deps/jq/src/execute.c +126 -44
  355. package/deps/jq/src/inject_errors.c +0 -2
  356. package/deps/jq/src/jq.h +10 -1
  357. package/deps/jq/src/jq_test.c +222 -11
  358. package/deps/jq/src/jv.c +807 -176
  359. package/deps/jq/src/jv.h +22 -1
  360. package/deps/jq/src/jv_alloc.c +33 -26
  361. package/deps/jq/src/jv_alloc.h +0 -11
  362. package/deps/jq/src/jv_aux.c +153 -67
  363. package/deps/jq/src/jv_dtoa.c +12 -2
  364. package/deps/jq/src/jv_dtoa_tsd.c +51 -0
  365. package/deps/jq/src/jv_dtoa_tsd.h +4 -0
  366. package/deps/jq/src/jv_parse.c +70 -15
  367. package/deps/jq/src/jv_print.c +56 -60
  368. package/deps/jq/src/jv_private.h +7 -0
  369. package/deps/jq/src/jv_thread.h +76 -0
  370. package/deps/jq/src/jv_unicode.c +18 -0
  371. package/deps/jq/src/jv_unicode.h +2 -0
  372. package/deps/jq/src/lexer.c +782 -543
  373. package/deps/jq/src/lexer.h +438 -64
  374. package/deps/jq/src/lexer.l +10 -3
  375. package/deps/jq/src/libm.h +16 -6
  376. package/deps/jq/src/linker.c +97 -40
  377. package/deps/jq/src/locfile.c +2 -1
  378. package/deps/jq/src/main.c +384 -336
  379. package/deps/jq/src/opcode_list.h +5 -2
  380. package/deps/jq/src/parser.c +2260 -1898
  381. package/deps/jq/src/parser.h +115 -98
  382. package/deps/jq/src/parser.y +124 -89
  383. package/deps/jq/src/util.c +854 -55
  384. package/deps/jq/src/util.h +6 -4
  385. package/deps/jq/tests/jq.test +762 -26
  386. package/deps/jq/tests/jq_fuzz_compile.c +27 -0
  387. package/deps/jq/tests/jq_fuzz_execute.cpp +42 -0
  388. package/deps/jq/tests/jq_fuzz_fixed.cpp +297 -0
  389. package/deps/jq/tests/jq_fuzz_load_file.c +28 -0
  390. package/deps/jq/tests/jq_fuzz_parse.c +21 -0
  391. package/deps/jq/tests/jq_fuzz_parse_extended.c +36 -0
  392. package/deps/jq/tests/jq_fuzz_parse_stream.c +21 -0
  393. package/deps/jq/tests/local.supp +14 -0
  394. package/deps/jq/tests/man.test +979 -0
  395. package/deps/jq/tests/manonig.test +76 -0
  396. package/deps/jq/tests/manonigtest +5 -0
  397. package/deps/jq/tests/mantest +1 -2
  398. package/deps/jq/tests/modules/home2/.jq/g.jq +1 -0
  399. package/deps/jq/tests/modules/shadow1.jq +2 -0
  400. package/deps/jq/tests/modules/shadow2.jq +1 -0
  401. package/deps/jq/tests/modules/test_bind_order0.jq +1 -0
  402. package/deps/jq/tests/modules/test_bind_order1.jq +1 -1
  403. package/deps/jq/tests/modules/test_bind_order2.jq +0 -1
  404. package/deps/jq/tests/no-main-program.jq +1 -0
  405. package/deps/jq/tests/onig.test +77 -2
  406. package/deps/jq/tests/setup +7 -2
  407. package/deps/jq/tests/shtest +478 -59
  408. package/deps/jq/tests/uri.test +38 -0
  409. package/deps/jq/tests/uritest +5 -0
  410. package/deps/jq/tests/yes-main-program.jq +2 -0
  411. package/lib/index.js +3 -0
  412. package/lib/jq.js +15 -1
  413. package/lib/templateAsync.js +137 -0
  414. package/package.json +4 -3
  415. package/src/binding.cc +623 -146
  416. package/src/binding.h +3 -4
  417. package/test/santiy-async.test.js +171 -0
  418. package/test/santiy.test.js +2 -2
  419. package/test/template-async.test.js +182 -0
  420. package/test/template.test.js +3 -3
  421. package/deps/jq/.travis.yml +0 -202
  422. package/deps/jq/NEWS +0 -89
  423. package/deps/jq/appveyor.yml +0 -53
  424. package/deps/jq/docs/Gemfile +0 -7
  425. package/deps/jq/docs/Gemfile.lock +0 -63
  426. package/deps/jq/docs/Rakefile +0 -24
  427. package/deps/jq/docs/Rakefile.manual +0 -49
  428. package/deps/jq/docs/Rakefile.website +0 -76
  429. package/deps/jq/docs/content/1.tutorial/default.yml +0 -327
  430. package/deps/jq/docs/content/2.download/default.yml +0 -193
  431. package/deps/jq/docs/content/index/index.yml +0 -73
  432. package/deps/jq/docs/public/css/base.scss +0 -181
  433. package/deps/jq/docs/public/jq.png +0 -0
  434. package/deps/jq/docs/site.yml +0 -9
  435. package/deps/jq/docs/templates/default.liquid +0 -34
  436. package/deps/jq/docs/templates/index.liquid +0 -73
  437. package/deps/jq/docs/templates/manual.liquid +0 -99
  438. package/deps/jq/docs/templates/shared/_footer.liquid +0 -10
  439. package/deps/jq/docs/templates/shared/_head.liquid +0 -17
  440. package/deps/jq/docs/templates/shared/_navbar.liquid +0 -27
  441. package/deps/jq/modules/oniguruma/README.ja +0 -195
  442. package/deps/jq/modules/oniguruma/cmake/dist.cmake +0 -321
  443. package/deps/jq/modules/oniguruma/contributed/libfuzzer-onig.cpp +0 -31
  444. package/deps/jq/modules/oniguruma/dist.info +0 -10
  445. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold1_key.c +0 -2250
  446. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold2_key.c +0 -203
  447. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold3_key.c +0 -113
  448. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold_data.c +0 -1225
  449. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data.c +0 -24742
  450. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data_posix.c +0 -4846
  451. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_unfold_key.c +0 -2571
  452. /package/deps/jq/sig/{jq-release.key → jq-release-old.key} +0 -0
  453. /package/deps/jq/tests/modules/{.jq → home1/.jq} +0 -0
@@ -1,11 +1,5 @@
1
1
  ---
2
- headline: jq Manual (development version)
3
-
4
- history: |
5
-
6
- *For released versions, see [jq 1.6](/jq/manual/v1.6),
7
- [jq 1.5](/jq/manual/v1.5), [jq 1.4](/jq/manual/v1.4)
8
- or [jq 1.3](/jq/manual/v1.3).*
2
+ headline: jq 1.6 Manual
9
3
 
10
4
  body: |
11
5
 
@@ -66,7 +60,7 @@ manpage_epilogue: |
66
60
 
67
61
  Presumably. Report them or discuss them at:
68
62
 
69
- https://github.com/stedolan/jq/issues
63
+ https://github.com/jqlang/jq/issues
70
64
 
71
65
  ## AUTHOR
72
66
 
@@ -79,8 +73,8 @@ sections:
79
73
  jq filters run on a stream of JSON data. The input to jq is
80
74
  parsed as a sequence of whitespace-separated JSON values which
81
75
  are passed through the provided filter one at a time. The
82
- output(s) of the filter are written to standard out, again as a
83
- sequence of whitespace-separated JSON data.
76
+ output(s) of the filter are written to standard output, as a
77
+ sequence of newline-separated JSON data.
84
78
 
85
79
  Note: it is important to mind the shell's quoting rules. As a
86
80
  general rule it's best to always quote (with single-quote
@@ -91,55 +85,37 @@ sections:
91
85
  defined`. When using the Windows command shell (cmd.exe) it's
92
86
  best to use double quotes around your jq program when given on the
93
87
  command-line (instead of the `-f program-file` option), but then
94
- double-quotes in the jq program need backslash escaping.
88
+ double-quotes in the jq program need backslash escaping. When using
89
+ the Powershell (`powershell.exe`) or the Powershell Core
90
+ (`pwsh`/`pwsh.exe`), use single-quote characters around the jq
91
+ program and backslash-escaped double-quotes (`\"`) inside the jq
92
+ program.
93
+
94
+ * Unix shells: `jq '.["foo"]'`
95
+ * Powershell: `jq '.[\"foo\"]'`
96
+ * Windows command shell: `jq ".[\"foo\"]"`
95
97
 
96
98
  You can affect how jq reads and writes its input and output
97
99
  using some command-line options:
98
100
 
99
- * `--version`:
100
-
101
- Output the jq version and exit with zero.
102
-
103
- * `--seq`:
104
-
105
- Use the `application/json-seq` MIME type scheme for separating
106
- JSON texts in jq's input and output. This means that an ASCII
107
- RS (record separator) character is printed before each value on
108
- output and an ASCII LF (line feed) is printed after every
109
- output. Input JSON texts that fail to parse are ignored (but
110
- warned about), discarding all subsequent input until the next
111
- RS. This mode also parses the output of jq without the `--seq`
112
- option.
113
-
114
- * `--stream`:
115
-
116
- Parse the input in streaming fashion, outputing arrays of path
117
- and leaf values (scalars and empty arrays or empty objects).
118
- For example, `"a"` becomes `[[],"a"]`, and `[[],"a",["b"]]`
119
- becomes `[[0],[]]`, `[[1],"a"]`, and `[[1,0],"b"]`.
120
-
121
- This is useful for processing very large inputs. Use this in
122
- conjunction with filtering and the `reduce` and `foreach` syntax
123
- to reduce large inputs incrementally.
101
+ * `--null-input` / `-n`:
124
102
 
125
- * `--slurp`/`-s`:
126
-
127
- Instead of running the filter for each JSON object in the
128
- input, read the entire input stream into a large array and run
129
- the filter just once.
103
+ Don't read any input at all. Instead, the filter is run once
104
+ using `null` as the input. This is useful when using jq as a
105
+ simple calculator or to construct JSON data from scratch.
130
106
 
131
- * `--raw-input`/`-R`:
107
+ * `--raw-input` / `-R`:
132
108
 
133
109
  Don't parse the input as JSON. Instead, each line of text is
134
110
  passed to the filter as a string. If combined with `--slurp`,
135
111
  then the entire input is passed to the filter as a single long
136
112
  string.
137
113
 
138
- * `--null-input`/`-n`:
114
+ * `--slurp` / `-s`:
139
115
 
140
- Don't read any input at all! Instead, the filter is run once
141
- using `null` as the input. This is useful when using jq as a
142
- simple calculator or to construct JSON data from scratch.
116
+ Instead of running the filter for each JSON object in the
117
+ input, read the entire input stream into a large array and run
118
+ the filter just once.
143
119
 
144
120
  * `--compact-output` / `-c`:
145
121
 
@@ -147,13 +123,28 @@ sections:
147
123
  will result in more compact output by instead putting each
148
124
  JSON object on a single line.
149
125
 
150
- * `--tab`:
126
+ * `--raw-output` / `-r`:
151
127
 
152
- Use a tab for each indentation level instead of two spaces.
128
+ With this option, if the filter's result is a string then it
129
+ will be written directly to standard output rather than being
130
+ formatted as a JSON string with quotes. This can be useful for
131
+ making jq filters talk to non-JSON-based systems.
153
132
 
154
- * `--indent n`:
133
+ * `--join-output` / `-j`:
134
+
135
+ Like `-r` but jq won't print a newline after each output.
136
+
137
+ * `--ascii-output` / `-a`:
155
138
 
156
- Use the given number of spaces (no more than 8) for indentation.
139
+ jq usually outputs non-ASCII Unicode codepoints as UTF-8, even
140
+ if the input specified them as escape sequences (like
141
+ "\u03bc"). Using this option, you can force jq to produce pure
142
+ ASCII output with every non-ASCII character replaced with the
143
+ equivalent escape sequence.
144
+
145
+ * `--sort-keys` / `-S`:
146
+
147
+ Output the fields of each object with the keys in sorted order.
157
148
 
158
149
  * `--color-output` / `-C` and `--monochrome-output` / `-M`:
159
150
 
@@ -164,58 +155,53 @@ sections:
164
155
  Colors can be configured with the `JQ_COLORS` environment
165
156
  variable (see below).
166
157
 
167
- * `--ascii-output` / `-a`:
158
+ * `--tab`:
168
159
 
169
- jq usually outputs non-ASCII Unicode codepoints as UTF-8, even
170
- if the input specified them as escape sequences (like
171
- "\u03bc"). Using this option, you can force jq to produce pure
172
- ASCII output with every non-ASCII character replaced with the
173
- equivalent escape sequence.
160
+ Use a tab for each indentation level instead of two spaces.
161
+
162
+ * `--indent n`:
174
163
 
175
- * `--unbuffered`
164
+ Use the given number of spaces (no more than 7) for indentation.
165
+
166
+ * `--unbuffered`:
176
167
 
177
168
  Flush the output after each JSON object is printed (useful if
178
169
  you're piping a slow data source into jq and piping jq's
179
170
  output elsewhere).
180
171
 
181
- * `--sort-keys` / `-S`:
182
-
183
- Output the fields of each object with the keys in sorted order.
172
+ * `--stream`:
184
173
 
185
- * `--raw-output` / `-r`:
174
+ Parse the input in streaming fashion, outputting arrays of path
175
+ and leaf values (scalars and empty arrays or empty objects).
176
+ For example, `"a"` becomes `[[],"a"]`, and `[[],"a",["b"]]`
177
+ becomes `[[0],[]]`, `[[1],"a"]`, and `[[2,0],"b"]`.
186
178
 
187
- With this option, if the filter's result is a string then it
188
- will be written directly to standard output rather than being
189
- formatted as a JSON string with quotes. This can be useful for
190
- making jq filters talk to non-JSON-based systems.
179
+ This is useful for processing very large inputs. Use this in
180
+ conjunction with filtering and the `reduce` and `foreach` syntax
181
+ to reduce large inputs incrementally.
191
182
 
192
- * `--join-output` / `-j`:
183
+ * `--seq`:
193
184
 
194
- Like `-r` but jq won't print a newline after each output.
185
+ Use the `application/json-seq` MIME type scheme for separating
186
+ JSON texts in jq's input and output. This means that an ASCII
187
+ RS (record separator) character is printed before each value on
188
+ output and an ASCII LF (line feed) is printed after every
189
+ output. Input JSON texts that fail to parse are ignored (but
190
+ warned about), discarding all subsequent input until the next
191
+ RS. This mode also parses the output of jq without the `--seq`
192
+ option.
195
193
 
196
194
  * `-f filename` / `--from-file filename`:
197
195
 
198
196
  Read filter from the file rather than from a command line, like
199
197
  awk's -f option. You can also use '#' to make comments.
200
198
 
201
- * `-Ldirectory` / `-L directory`:
199
+ * `-L directory`:
202
200
 
203
201
  Prepend `directory` to the search list for modules. If this
204
202
  option is used then no builtin search list is used. See the
205
203
  section on modules below.
206
204
 
207
- * `-e` / `--exit-status`:
208
-
209
- Sets the exit status of jq to 0 if the last output values was
210
- neither `false` nor `null`, 1 if the last output value was
211
- either `false` or `null`, or 4 if no valid result was ever
212
- produced. Normally jq exits with 2 if there was any usage
213
- problem or system error, 3 if there was a jq program compile
214
- error, or 0 if the jq program ran.
215
-
216
- Another way to set the exit status is with the `halt_error`
217
- builtin function.
218
-
219
205
  * `--arg name value`:
220
206
 
221
207
  This option passes a value to the jq program as a predefined
@@ -245,7 +231,7 @@ sections:
245
231
 
246
232
  This option reads in the named file and binds its contents to the given
247
233
  global variable. If you run jq with `--rawfile foo bar`, then `$foo` is
248
- available in the program and has a string whose contents are to the texs
234
+ available in the program and has a string whose contents are to the texts
249
235
  in the file named `bar`.
250
236
 
251
237
  * `--argfile variable-name filename`:
@@ -266,6 +252,26 @@ sections:
266
252
  Remaining arguments are positional JSON text arguments. These
267
253
  are available to the jq program as `$ARGS.positional[]`.
268
254
 
255
+ * `--exit-status` / `-e`:
256
+
257
+ Sets the exit status of jq to 0 if the last output value was
258
+ neither `false` nor `null`, 1 if the last output value was
259
+ either `false` or `null`, or 4 if no valid result was ever
260
+ produced. Normally jq exits with 2 if there was any usage
261
+ problem or system error, 3 if there was a jq program compile
262
+ error, or 0 if the jq program ran.
263
+
264
+ Another way to set the exit status is with the `halt_error`
265
+ builtin function.
266
+
267
+ * `--version` / `-V`:
268
+
269
+ Output the jq version and exit with zero.
270
+
271
+ * `--help` / `-h`:
272
+
273
+ Output the jq help and exit with zero.
274
+
269
275
  * `--run-tests [filename]`:
270
276
 
271
277
  Runs the tests in the given file or standard input. This must
@@ -274,7 +280,7 @@ sections:
274
280
  program lines followed by one input line, as many lines of
275
281
  output as are expected (one per output), and a terminating empty
276
282
  line. Compilation failure tests start with a line containing
277
- only "%%FAIL", then a line containing the program to compile,
283
+ only `%%FAIL`, then a line containing the program to compile,
278
284
  then a line containing an error message to compare to the
279
285
  actual.
280
286
 
@@ -298,6 +304,7 @@ sections:
298
304
  input: '"Hello, world!"'
299
305
  output: ['"Hello, world!"']
300
306
 
307
+
301
308
  - title: "Object Identifier-Index: `.foo`, `.foo.bar`"
302
309
  body: |
303
310
 
@@ -311,8 +318,9 @@ sections:
311
318
  is, keys that are all made of alphanumeric characters and
312
319
  underscore, and which do not start with a digit.
313
320
 
314
- If the key contains special characters, you need to surround
315
- it with double quotes like this: `."foo$"`, or else `.["foo$"]`.
321
+ If the key contains special characters or starts with a digit,
322
+ you need to surround it with double quotes like this:
323
+ `."foo$"`, or else `.["foo$"]`.
316
324
 
317
325
  For example `.["foo::bar"]` and `.["foo.bar"]` work while
318
326
  `.foo::bar` does not, and `.foo.bar` means `.["foo"].["bar"]`.
@@ -320,45 +328,45 @@ sections:
320
328
  examples:
321
329
  - program: '.foo'
322
330
  input: '{"foo": 42, "bar": "less interesting data"}'
323
- output: [42]
331
+ output: ['42']
324
332
  - program: '.foo'
325
333
  input: '{"notfoo": true, "alsonotfoo": false}'
326
334
  output: ['null']
327
335
  - program: '.["foo"]'
328
336
  input: '{"foo": 42}'
329
- output: [42]
337
+ output: ['42']
330
338
 
331
339
  - title: "Optional Object Identifier-Index: `.foo?`"
332
340
  body: |
333
341
 
334
- Just like `.foo`, but does not output even an error when `.`
335
- is not an array or an object.
342
+ Just like `.foo`, but does not output an error when `.` is not an
343
+ object.
336
344
 
337
345
  examples:
338
346
  - program: '.foo?'
339
347
  input: '{"foo": 42, "bar": "less interesting data"}'
340
- output: [42]
348
+ output: ['42']
341
349
  - program: '.foo?'
342
350
  input: '{"notfoo": true, "alsonotfoo": false}'
343
351
  output: ['null']
344
352
  - program: '.["foo"]?'
345
353
  input: '{"foo": 42}'
346
- output: [42]
354
+ output: ['42']
347
355
  - program: '[.foo?]'
348
356
  input: '[1,2]'
349
357
  output: ['[]']
350
358
 
351
- - title: "Generic Object Index: `.[<string>]`"
359
+ - title: "Object Index: `.[<string>]`"
352
360
  body: |
353
361
 
354
362
  You can also look up fields of an object using syntax like
355
- `.["foo"]` (.foo above is a shorthand version of this, but
363
+ `.["foo"]` (`.foo` above is a shorthand version of this, but
356
364
  only for identifier-like strings).
357
365
 
358
- - title: "Array Index: `.[2]`"
366
+ - title: "Array Index: `.[<number>]`"
359
367
  body: |
360
368
 
361
- When the index value is an integer, `.[<value>]` can index
369
+ When the index value is an integer, `.[<number>]` can index
362
370
  arrays. Arrays are zero-based, so `.[2]` returns the third
363
371
  element.
364
372
 
@@ -378,16 +386,17 @@ sections:
378
386
  input: '[1,2,3]'
379
387
  output: ['2']
380
388
 
381
- - title: "Array/String Slice: `.[10:15]`"
389
+ - title: "Array/String Slice: `.[<number>:<number>]`"
382
390
  body: |
383
391
 
384
- The `.[10:15]` syntax can be used to return a subarray of an
385
- array or substring of a string. The array returned by
386
- `.[10:15]` will be of length 5, containing the elements from
387
- index 10 (inclusive) to index 15 (exclusive). Either index may
388
- be negative (in which case it counts backwards from the end of
389
- the array), or omitted (in which case it refers to the start
390
- or end of the array).
392
+ The `.[<number>:<number>]` syntax can be used to return a
393
+ subarray of an array or substring of a string. The array
394
+ returned by `.[10:15]` will be of length 5, containing the
395
+ elements from index 10 (inclusive) to index 15 (exclusive).
396
+ Either index may be negative (in which case it counts
397
+ backwards from the end of the array), or omitted (in which
398
+ case it refers to the start or end of the array).
399
+ Indices are zero-based.
391
400
 
392
401
  examples:
393
402
  - program: '.[2:4]'
@@ -413,7 +422,8 @@ sections:
413
422
  entirely, it will return *all* of the elements of an
414
423
  array. Running `.[]` with the input `[1,2,3]` will produce the
415
424
  numbers as three separate results, rather than as a single
416
- array.
425
+ array. A filter of the form `.foo[]` is equivalent to
426
+ `.foo | .[]`.
417
427
 
418
428
  You can also use this on an object, and it will return all
419
429
  the values of the object.
@@ -429,6 +439,10 @@ sections:
429
439
  input: '[]'
430
440
  output: []
431
441
 
442
+ - program: '.foo[]'
443
+ input: '{"foo":[1,2,3]}'
444
+ output: ['1','2','3']
445
+
432
446
  - program: '.[]'
433
447
  input: '{"a": 1, "b": 1}'
434
448
  output: ['1', '1']
@@ -437,7 +451,8 @@ sections:
437
451
  body: |
438
452
 
439
453
  Like `.[]`, but no errors will be output if . is not an array
440
- or object.
454
+ or object. A filter of the form `.foo[]?` is equivalent to
455
+ `.foo | .[]?`.
441
456
 
442
457
  - title: "Comma: `,`"
443
458
  body: |
@@ -497,7 +512,7 @@ sections:
497
512
  examples:
498
513
  - program: '(. + 2) * 5'
499
514
  input: '1'
500
- output: [15]
515
+ output: ['15']
501
516
 
502
517
  - title: Types and Values
503
518
  body: |
@@ -507,7 +522,7 @@ sections:
507
522
  hashes with only string keys), and "null".
508
523
 
509
524
  Booleans, null, strings and numbers are written the same way as
510
- in javascript. Just like everything else in jq, these simple
525
+ in JSON. Just like everything else in jq, these simple
511
526
  values take an input and produce an output - `42` is a valid jq
512
527
  expression that takes an input, ignores it, and returns 42
513
528
  instead.
@@ -609,22 +624,22 @@ sections:
609
624
  Recursively descends `.`, producing every value. This is the
610
625
  same as the zero-argument `recurse` builtin (see below). This
611
626
  is intended to resemble the XPath `//` operator. Note that
612
- `..a` does not work; use `..|.a` instead. In the example
613
- below we use `..|.a?` to find all the values of object keys
627
+ `..a` does not work; use `.. | .a` instead. In the example
628
+ below we use `.. | .a?` to find all the values of object keys
614
629
  "a" in any object found "below" `.`.
615
630
 
616
631
  This is particularly useful in conjunction with `path(EXP)`
617
632
  (also see below) and the `?` operator.
618
633
 
619
634
  examples:
620
- - program: '..|.a?'
635
+ - program: '.. | .a?'
621
636
  input: '[[{"a":1}]]'
622
637
  output: ['1']
623
638
 
624
639
  - title: Builtin operators and functions
625
640
  body: |
626
641
 
627
- Some jq operator (for instance, `+`) do different things
642
+ Some jq operators (for instance, `+`) do different things
628
643
  depending on the type of their arguments (arrays, numbers,
629
644
  etc.). However, jq never does implicit type conversions. If you
630
645
  try to add a string to an object you'll get an error message and
@@ -645,10 +660,10 @@ sections:
645
660
  - **Strings** are added by being joined into a larger string.
646
661
 
647
662
  - **Objects** are added by merging, that is, inserting all
648
- the key-value pairs from both objects into a single
649
- combined object. If both objects contain a value for the
650
- same key, the object on the right of the `+` wins. (For
651
- recursive merge use the `*` operator.)
663
+ the key-value pairs from both objects into a single
664
+ combined object. If both objects contain a value for the
665
+ same key, the object on the right of the `+` wins. (For
666
+ recursive merge use the `*` operator.)
652
667
 
653
668
  `null` can be added to any value, and returns the other
654
669
  value unchanged.
@@ -685,7 +700,7 @@ sections:
685
700
  input: '["xml", "yaml", "json"]'
686
701
  output: ['["json"]']
687
702
 
688
- - title: "Multiplication, division, modulo: `*`, `/`, and `%`"
703
+ - title: "Multiplication, division, modulo: `*`, `/`, `%`"
689
704
  body: |
690
705
 
691
706
  These infix operators behave as expected when given two numbers.
@@ -704,8 +719,8 @@ sections:
704
719
 
705
720
  examples:
706
721
  - program: '10 / . * 3'
707
- input: 5
708
- output: [6]
722
+ input: '5'
723
+ output: ['6']
709
724
  - program: '. / ", "'
710
725
  input: '"a, b,c,d, e"'
711
726
  output: ['["a","b,c,d","e"]']
@@ -727,16 +742,20 @@ sections:
727
742
  codepoints it contains (which will be the same as its
728
743
  JSON-encoded length in bytes if it's pure ASCII).
729
744
 
745
+ - The length of a **number** is its absolute value.
746
+
730
747
  - The length of an **array** is the number of elements.
731
748
 
732
749
  - The length of an **object** is the number of key-value pairs.
733
750
 
734
751
  - The length of **null** is zero.
735
752
 
753
+ - It is an error to use `length` on a **boolean**.
754
+
736
755
  examples:
737
756
  - program: '.[] | length'
738
- input: '[[1,2], "string", {"a":2}, null]'
739
- output: [2, 6, 1, 0]
757
+ input: '[[1,2], "string", {"a":2}, null, -5]'
758
+ output: ['2', '6', '1', '0', '5']
740
759
 
741
760
 
742
761
  - title: "`utf8bytelength`"
@@ -748,7 +767,7 @@ sections:
748
767
  examples:
749
768
  - program: 'utf8bytelength'
750
769
  input: '"\u03bc"'
751
- output: [2]
770
+ output: ['2']
752
771
 
753
772
  - title: "`keys`, `keys_unsorted`"
754
773
  body: |
@@ -812,18 +831,18 @@ sections:
812
831
  input: '[2, 0]'
813
832
  output: ['[false, true]']
814
833
 
815
- - title: "`map(x)`, `map_values(x)`"
834
+ - title: "`map(f)`, `map_values(f)`"
816
835
  body: |
817
836
 
818
- For any filter `x`, `map(x)` will run that filter for each
837
+ For any filter `f`, `map(f)` will run that filter for each
819
838
  element of the input array, and return the outputs in a new
820
839
  array. `map(.+1)` will increment each element of an array of numbers.
821
840
 
822
- Similarly, `map_values(x)` will run that filter for each element,
841
+ Similarly, `map_values(f)` will run that filter for each element,
823
842
  but it will return an object when an object is passed.
824
843
 
825
- `map(x)` is equivalent to `[.[] | x]`. In fact, this is how
826
- it's defined. Similarly, `map_values(x)` is defined as `.[] |= x`.
844
+ `map(f)` is equivalent to `[.[] | f]`. In fact, this is how
845
+ it's defined. Similarly, `map_values(f)` is defined as `.[] |= f`.
827
846
 
828
847
  examples:
829
848
  - program: 'map(.+1)'
@@ -922,7 +941,7 @@ sections:
922
941
  input: '{"a":{"b":1},"x":{"y":2}}'
923
942
  output: ['{"a":{},"x":{"y":2}}']
924
943
 
925
- - title: "`to_entries`, `from_entries`, `with_entries`"
944
+ - title: "`to_entries`, `from_entries`, `with_entries(f)`"
926
945
  body: |
927
946
 
928
947
  These functions convert between an object and an array of
@@ -930,11 +949,11 @@ sections:
930
949
  for each `k: v` entry in the input, the output array
931
950
  includes `{"key": k, "value": v}`.
932
951
 
933
- `from_entries` does the opposite conversion, and
934
- `with_entries(foo)` is a shorthand for `to_entries |
935
- map(foo) | from_entries`, useful for doing some operation to
936
- all keys and values of an object. `from_entries` accepts key, Key,
937
- name, Name, value and Value as keys.
952
+ `from_entries` does the opposite conversion, and `with_entries(f)`
953
+ is a shorthand for `to_entries | map(f) | from_entries`, useful for
954
+ doing some operation to all keys and values of an object.
955
+ `from_entries` accepts `"key"`, `"Key"`, `"name"`, `"Name"`,
956
+ `"value"`, and `"Value"` as keys.
938
957
 
939
958
  examples:
940
959
  - program: 'to_entries'
@@ -951,8 +970,8 @@ sections:
951
970
  - title: "`select(boolean_expression)`"
952
971
  body: |
953
972
 
954
- The function `select(foo)` produces its input unchanged if
955
- `foo` returns true for that input, and produces no output
973
+ The function `select(f)` produces its input unchanged if
974
+ `f` returns true for that input, and produces no output
956
975
  otherwise.
957
976
 
958
977
  It's useful for filtering lists: `[1,2,3] | map(select(. >= 2))`
@@ -990,17 +1009,30 @@ sections:
990
1009
  examples:
991
1010
  - program: '1, empty, 2'
992
1011
  input: 'null'
993
- output: [1, 2]
1012
+ output: ['1', '2']
994
1013
  - program: '[1,2,empty,3]'
995
1014
  input: 'null'
996
1015
  output: ['[1,2,3]']
997
1016
 
998
- - title: "`error(message)`"
1017
+ - title: "`error`, `error(message)`"
999
1018
  body: |
1000
1019
 
1001
- Produces an error, just like `.a` applied to values other than
1002
- null and objects would, but with the given message as the
1003
- error's value. Errors can be caught with try/catch; see below.
1020
+ Produces an error with the input value, or with the message
1021
+ given as the argument. Errors can be caught with try/catch;
1022
+ see below.
1023
+
1024
+ When the error value is `null`, it produces nothing and works
1025
+ just like `empty`. So `[null | error]` and `[error(null)]` both
1026
+ emit `[]`.
1027
+
1028
+ examples:
1029
+ - program: 'try error catch .'
1030
+ input: '"error message"'
1031
+ output: ['"error message"']
1032
+
1033
+ - program: 'try error("invalid value: \(.)") catch .'
1034
+ input: '42'
1035
+ output: ['"invalid value: 42"']
1004
1036
 
1005
1037
  - title: "`halt`"
1006
1038
  body: |
@@ -1018,7 +1050,7 @@ sections:
1018
1050
  The given `exit_code` (defaulting to `5`) will be jq's exit
1019
1051
  status.
1020
1052
 
1021
- For example, `"Error: somthing went wrong\n"|halt_error(1)`.
1053
+ For example, `"Error: something went wrong\n"|halt_error(1)`.
1022
1054
 
1023
1055
  - title: "`$__loc__`"
1024
1056
  body: |
@@ -1039,8 +1071,8 @@ sections:
1039
1071
  (except it does not output the empty list, representing .
1040
1072
  itself).
1041
1073
 
1042
- `paths(f)` outputs the paths to any values for which `f` is true.
1043
- That is, `paths(numbers)` outputs the paths to all numeric
1074
+ `paths(f)` outputs the paths to any values for which `f` is `true`.
1075
+ That is, `paths(type == "number")` outputs the paths to all numeric
1044
1076
  values.
1045
1077
 
1046
1078
  `leaf_paths` is an alias of `paths(scalars)`; `leaf_paths` is
@@ -1050,7 +1082,7 @@ sections:
1050
1082
  - program: '[paths]'
1051
1083
  input: '[1,[[],{"a":2}]]'
1052
1084
  output: ['[[0],[1],[1,0],[1,1],[1,1,"a"]]']
1053
- - program: '[paths(scalars)]'
1085
+ - program: '[paths(type == "number")]'
1054
1086
  input: '[1,[[],{"a":2}]]'
1055
1087
  output: ['[[0],[1,1,"a"]]']
1056
1088
 
@@ -1071,7 +1103,7 @@ sections:
1071
1103
  output: ['"abc"']
1072
1104
  - program: add
1073
1105
  input: '[1, 2, 3]'
1074
- output: [6]
1106
+ output: ['6']
1075
1107
  - program: add
1076
1108
  input: '[]'
1077
1109
  output: ["null"]
@@ -1153,12 +1185,12 @@ sections:
1153
1185
  input: '[{"foo": "bar"}, [{"foo": "baz"}]]'
1154
1186
  output: ['[{"foo": "bar"}, {"foo": "baz"}]']
1155
1187
 
1156
- - title: "`range(upto)`, `range(from;upto)` `range(from;upto;by)`"
1188
+ - title: "`range(upto)`, `range(from; upto)`, `range(from; upto; by)`"
1157
1189
  body: |
1158
1190
 
1159
- The `range` function produces a range of numbers. `range(4;10)`
1191
+ The `range` function produces a range of numbers. `range(4; 10)`
1160
1192
  produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers
1161
- are produced as separate outputs. Use `[range(4;10)]` to get a range as
1193
+ are produced as separate outputs. Use `[range(4; 10)]` to get a range as
1162
1194
  an array.
1163
1195
 
1164
1196
  The one argument form generates numbers from 0 to the given
@@ -1171,22 +1203,22 @@ sections:
1171
1203
  with an increment of `by`.
1172
1204
 
1173
1205
  examples:
1174
- - program: 'range(2;4)'
1206
+ - program: 'range(2; 4)'
1175
1207
  input: 'null'
1176
1208
  output: ['2', '3']
1177
- - program: '[range(2;4)]'
1209
+ - program: '[range(2; 4)]'
1178
1210
  input: 'null'
1179
1211
  output: ['[2,3]']
1180
1212
  - program: '[range(4)]'
1181
1213
  input: 'null'
1182
1214
  output: ['[0,1,2,3]']
1183
- - program: '[range(0;10;3)]'
1215
+ - program: '[range(0; 10; 3)]'
1184
1216
  input: 'null'
1185
1217
  output: ['[0,3,6,9]']
1186
- - program: '[range(0;10;-1)]'
1218
+ - program: '[range(0; 10; -1)]'
1187
1219
  input: 'null'
1188
1220
  output: ['[]']
1189
- - program: '[range(0;-5;-1)]'
1221
+ - program: '[range(0; -5; -1)]'
1190
1222
  input: 'null'
1191
1223
  output: ['[0,-1,-2,-3,-4]']
1192
1224
 
@@ -1220,7 +1252,7 @@ sections:
1220
1252
  examples:
1221
1253
  - program: '.[] | tonumber'
1222
1254
  input: '[1, "1"]'
1223
- output: [1, 1]
1255
+ output: ['1', '1']
1224
1256
 
1225
1257
  - title: "`tostring`"
1226
1258
  body: |
@@ -1270,7 +1302,7 @@ sections:
1270
1302
  input: 'null'
1271
1303
  output: ['"number"', '"number"']
1272
1304
 
1273
- - title: "`sort, sort_by(path_expression)`"
1305
+ - title: "`sort`, `sort_by(path_expression)`"
1274
1306
  body: |
1275
1307
 
1276
1308
  The `sort` functions sorts its input, which must be an
@@ -1289,19 +1321,25 @@ sections:
1289
1321
  sorted order), and if their keys are equal then the values
1290
1322
  are compared key by key.
1291
1323
 
1292
- `sort` may be used to sort by a particular field of an
1293
- object, or by applying any jq filter.
1294
-
1295
- `sort_by(foo)` compares two elements by comparing the result of
1296
- `foo` on each element.
1324
+ `sort_by` may be used to sort by a particular field of an
1325
+ object, or by applying any jq filter. `sort_by(f)` compares
1326
+ two elements by comparing the result of `f` on each element.
1327
+ When `f` produces multiple values, it firstly compares the
1328
+ first values, and the second values if the first values are
1329
+ equal, and so on.
1297
1330
 
1298
1331
  examples:
1299
1332
  - program: 'sort'
1300
1333
  input: '[8,3,null,6]'
1301
1334
  output: ['[null,3,6,8]']
1335
+
1302
1336
  - program: 'sort_by(.foo)'
1303
- input: '[{"foo":4, "bar":10}, {"foo":3, "bar":100}, {"foo":2, "bar":1}]'
1304
- output: ['[{"foo":2, "bar":1}, {"foo":3, "bar":100}, {"foo":4, "bar":10}]']
1337
+ input: '[{"foo":4, "bar":10}, {"foo":3, "bar":10}, {"foo":2, "bar":1}]'
1338
+ output: ['[{"foo":2, "bar":1}, {"foo":3, "bar":10}, {"foo":4, "bar":10}]']
1339
+
1340
+ - program: 'sort_by(.foo, .bar)'
1341
+ input: '[{"foo":4, "bar":10}, {"foo":3, "bar":20}, {"foo":2, "bar":1}, {"foo":3, "bar":10}]'
1342
+ output: ['[{"foo":2, "bar":1}, {"foo":3, "bar":10}, {"foo":3, "bar":20}, {"foo":4, "bar":10}]']
1305
1343
 
1306
1344
  - title: "`group_by(path_expression)`"
1307
1345
  body: |
@@ -1428,9 +1466,21 @@ sections:
1428
1466
  - program: 'index(", ")'
1429
1467
  input: '"a,b, cd, efg, hijk"'
1430
1468
  output: ['3']
1469
+ - program: 'index(1)'
1470
+ input: '[0,1,2,1,3,1,4]'
1471
+ output: ['1']
1472
+ - program: 'index([1,2])'
1473
+ input: '[0,1,2,3,1,4,2,5,1,2,6,7]'
1474
+ output: ['1']
1431
1475
  - program: 'rindex(", ")'
1432
1476
  input: '"a,b, cd, efg, hijk"'
1433
1477
  output: ['12']
1478
+ - program: 'rindex(1)'
1479
+ input: '[0,1,2,1,3,1,4]'
1480
+ output: ['5']
1481
+ - program: 'rindex([1,2])'
1482
+ input: '[0,1,2,3,1,4,2,5,1,2,6,7]'
1483
+ output: ['8']
1434
1484
 
1435
1485
  - title: "`inside`"
1436
1486
  body: |
@@ -1570,10 +1620,10 @@ sections:
1570
1620
  Emit a copy of the input string with its alphabetic characters (a-z and A-Z)
1571
1621
  converted to the specified case.
1572
1622
 
1573
- example:
1623
+ examples:
1574
1624
  - program: 'ascii_upcase'
1575
1625
  input: '"useful but not for é"'
1576
- output: '"USEFUL BUT NOT FOR é"'
1626
+ output: ['"USEFUL BUT NOT FOR é"']
1577
1627
 
1578
1628
  - title: "`while(cond; update)`"
1579
1629
  body: |
@@ -1635,7 +1685,7 @@ sections:
1635
1685
  When called without an argument, `recurse` is equivalent to
1636
1686
  `recurse(.[]?)`.
1637
1687
 
1638
- `recurse(f)` is identical to `recurse(f; . != null)` and can be
1688
+ `recurse(f)` is identical to `recurse(f; true)` and can be
1639
1689
  used without concerns about recursion depth.
1640
1690
 
1641
1691
  `recurse(f; condition)` is a generator which begins by
@@ -1670,11 +1720,8 @@ sections:
1670
1720
  - '1'
1671
1721
 
1672
1722
  - program: 'recurse(. * .; . < 20)'
1673
- input: 2
1674
- output:
1675
- - 2
1676
- - 4
1677
- - 16
1723
+ input: '2'
1724
+ output: ['2', '4', '16']
1678
1725
 
1679
1726
  - title: "`walk(f)`"
1680
1727
  body: |
@@ -1736,13 +1783,13 @@ sections:
1736
1783
  - title: "`bsearch(x)`"
1737
1784
  body: |
1738
1785
 
1739
- bsearch(x) conducts a binary search for x in the input
1786
+ `bsearch(x)` conducts a binary search for x in the input
1740
1787
  array. If the input is sorted and contains x, then
1741
- bsearch(x) will return its index in the array; otherwise, if
1788
+ `bsearch(x)` will return its index in the array; otherwise, if
1742
1789
  the array is sorted, it will return (-1 - ix) where ix is an
1743
1790
  insertion point such that the array would still be sorted
1744
1791
  after the insertion of x at ix. If the array is not sorted,
1745
- bsearch(x) will return an integer that is probably of no
1792
+ `bsearch(x)` will return an integer that is probably of no
1746
1793
  interest.
1747
1794
 
1748
1795
  examples:
@@ -1756,7 +1803,7 @@ sections:
1756
1803
  input: '[1,2,3]'
1757
1804
  output: ['[1,2,3,4]']
1758
1805
 
1759
- - title: "String interpolation - `\\(foo)`"
1806
+ - title: "String interpolation: `\\(exp)`"
1760
1807
  body: |
1761
1808
 
1762
1809
  Inside a string, you can put an expression inside parens
@@ -1772,9 +1819,9 @@ sections:
1772
1819
  body: |
1773
1820
 
1774
1821
  The `tojson` and `fromjson` builtins dump values as JSON texts
1775
- or parse JSON texts into values, respectively. The tojson
1776
- builtin differs from tostring in that tostring returns strings
1777
- unmodified, while tojson encodes strings as JSON strings.
1822
+ or parse JSON texts into values, respectively. The `tojson`
1823
+ builtin differs from `tostring` in that `tostring` returns strings
1824
+ unmodified, while `tojson` encodes strings as JSON strings.
1778
1825
 
1779
1826
  examples:
1780
1827
  - program: '[.[]|tostring]'
@@ -1866,10 +1913,6 @@ sections:
1866
1913
  input: '"This works if x < y"'
1867
1914
  output: ['"This works if x &lt; y"']
1868
1915
 
1869
- # - program: '@html "<span>Anonymous said: \(.)</span>"'
1870
- # input: '"<script>alert(\"lol hax\");</script>"'
1871
- # output: ["<span>Anonymous said: &lt;script&gt;alert(&quot;lol hax&quot;);&lt;/script&gt;</span>"]
1872
-
1873
1916
  - program: '@sh "echo \(.)"'
1874
1917
  input: "\"O'Hara's Ale\""
1875
1918
  output: ["\"echo 'O'\\\\''Hara'\\\\''s Ale'\""]
@@ -1914,7 +1957,7 @@ sections:
1914
1957
 
1915
1958
  The `gmtime` builtin consumes a number of seconds since the
1916
1959
  Unix epoch and outputs a "broken down time" representation of
1917
- Greenwhich Meridian time as an array of numbers representing
1960
+ Greenwich Mean Time as an array of numbers representing
1918
1961
  (in this order): the year, the month (zero-based), the day of
1919
1962
  the month (one-based), the hour of the day, the minute of the
1920
1963
  hour, the second of the minute, the day of the week, and the
@@ -1930,7 +1973,7 @@ sections:
1930
1973
 
1931
1974
  The `strptime(fmt)` builtin parses input strings matching the
1932
1975
  `fmt` argument. The output is in the "broken down time"
1933
- representation consumed by `gmtime` and output by `mktime`.
1976
+ representation consumed by `mktime` and output by `gmtime`.
1934
1977
 
1935
1978
  The `strftime(fmt)` builtin formats a time (GMT) with the
1936
1979
  given format. The `strflocaltime` does the same, but using
@@ -1962,40 +2005,40 @@ sections:
1962
2005
 
1963
2006
  jq provides a few SQL-style operators.
1964
2007
 
1965
- * INDEX(stream; index_expression):
2008
+ * INDEX(stream; index_expression):
1966
2009
 
1967
- This builtin produces an object whose keys are computed by
1968
- the given index expression applied to each value from the
1969
- given stream.
2010
+ This builtin produces an object whose keys are computed by
2011
+ the given index expression applied to each value from the
2012
+ given stream.
1970
2013
 
1971
- * JOIN($idx; stream; idx_expr; join_expr):
2014
+ * JOIN($idx; stream; idx_expr; join_expr):
1972
2015
 
1973
- This builtin joins the values from the given stream to the
1974
- given index. The index's keys are computed by applying the
1975
- given index expression to each value from the given stream.
1976
- An array of the value in the stream and the corresponding
1977
- value from the index is fed to the given join expression to
1978
- produce each result.
2016
+ This builtin joins the values from the given stream to the
2017
+ given index. The index's keys are computed by applying the
2018
+ given index expression to each value from the given stream.
2019
+ An array of the value in the stream and the corresponding
2020
+ value from the index is fed to the given join expression to
2021
+ produce each result.
1979
2022
 
1980
- * JOIN($idx; stream; idx_expr):
2023
+ * JOIN($idx; stream; idx_expr):
1981
2024
 
1982
- Same as `JOIN($idx; stream; idx_expr; .)`.
2025
+ Same as `JOIN($idx; stream; idx_expr; .)`.
1983
2026
 
1984
- * JOIN($idx; idx_expr):
2027
+ * JOIN($idx; idx_expr):
1985
2028
 
1986
- This builtin joins the input `.` to the given index, applying
1987
- the given index expression to `.` to compute the index key.
1988
- The join operation is as described above.
2029
+ This builtin joins the input `.` to the given index, applying
2030
+ the given index expression to `.` to compute the index key.
2031
+ The join operation is as described above.
1989
2032
 
1990
- * IN(s):
2033
+ * IN(s):
1991
2034
 
1992
- This builtin outputs `true` if `.` appears in the given
1993
- stream, otherwise it outputs `false`.
2035
+ This builtin outputs `true` if `.` appears in the given
2036
+ stream, otherwise it outputs `false`.
1994
2037
 
1995
- * IN(source; s):
2038
+ * IN(source; s):
1996
2039
 
1997
- This builtin outputs `true` if any value in the source stream
1998
- appears in the second stream, otherwise it outputs `false`.
2040
+ This builtin outputs `true` if any value in the source stream
2041
+ appears in the second stream, otherwise it outputs `false`.
1999
2042
 
2000
2043
  - title: "`builtins`"
2001
2044
  body: |
@@ -2013,8 +2056,8 @@ sections:
2013
2056
  The expression 'a == b' will produce 'true' if the result of a and b
2014
2057
  are equal (that is, if they represent equivalent JSON documents) and
2015
2058
  'false' otherwise. In particular, strings are never considered equal
2016
- to numbers. If you're coming from Javascript, jq's == is like
2017
- Javascript's === - considering values equal only when they have the
2059
+ to numbers. If you're coming from JavaScript, jq's == is like
2060
+ JavaScript's === - considering values equal only when they have the
2018
2061
  same type as well as the same value.
2019
2062
 
2020
2063
  != is "not equal", and 'a != b' returns the opposite value of 'a == b'
@@ -2024,7 +2067,7 @@ sections:
2024
2067
  input: '[1, 1.0, "1", "banana"]'
2025
2068
  output: ['true', 'true', 'false', 'false']
2026
2069
 
2027
- - title: if-then-else
2070
+ - title: if-then-else-end
2028
2071
  body: |
2029
2072
 
2030
2073
  `if A then B else C end` will act the same as `B` if `A`
@@ -2032,12 +2075,11 @@ sections:
2032
2075
  as `C` otherwise.
2033
2076
 
2034
2077
  Checking for false or null is a simpler notion of
2035
- "truthiness" than is found in Javascript or Python, but it
2078
+ "truthiness" than is found in JavaScript or Python, but it
2036
2079
  means that you'll sometimes have to be more explicit about
2037
- the condition you want: you can't test whether, e.g. a
2080
+ the condition you want. You can't test whether, e.g. a
2038
2081
  string is empty using `if .name then A else B end`, you'll
2039
- need something more like `if (.name | length) > 0 then A else
2040
- B end` instead.
2082
+ need something more like `if .name == "" then A else B end` instead.
2041
2083
 
2042
2084
  If the condition `A` produces multiple results, then `B` is evaluated
2043
2085
  once for each result that is not false or null, and `C` is evaluated
@@ -2054,10 +2096,10 @@ sections:
2054
2096
  else
2055
2097
  "many"
2056
2098
  end
2057
- input: 2
2099
+ input: '2'
2058
2100
  output: ['"many"']
2059
2101
 
2060
- - title: "`>, >=, <=, <`"
2102
+ - title: "`>`, `>=`, `<=`, `<`"
2061
2103
  body: |
2062
2104
 
2063
2105
  The comparison operators `>`, `>=`, `<=`, `<` return whether
@@ -2069,15 +2111,16 @@ sections:
2069
2111
 
2070
2112
  examples:
2071
2113
  - program: '. < 5'
2072
- input: 2
2114
+ input: '2'
2073
2115
  output: ['true']
2074
2116
 
2075
- - title: and/or/not
2117
+ - title: "`and`, `or`, `not`"
2076
2118
  body: |
2077
2119
 
2078
- jq supports the normal Boolean operators and/or/not. They have the
2079
- same standard of truth as if expressions - false and null are
2080
- considered "false values", and anything else is a "true value".
2120
+ jq supports the normal Boolean operators `and`, `or`, `not`. They
2121
+ have the same standard of truth as if expressions - `false` and
2122
+ `null` are considered "false values", and anything else is a "true
2123
+ value".
2081
2124
 
2082
2125
  If an operand of one of these operators produces multiple
2083
2126
  results, the operator itself will produce a result for each input.
@@ -2087,12 +2130,12 @@ sections:
2087
2130
  rather than with special syntax, as in `.foo and .bar |
2088
2131
  not`.
2089
2132
 
2090
- These three only produce the values "true" and "false", and
2133
+ These three only produce the values `true` and `false`, and
2091
2134
  so are only useful for genuine Boolean operations, rather
2092
2135
  than the common Perl/Python/Ruby idiom of
2093
2136
  "value_that_may_be_null or default". If you want to use this
2094
2137
  form of "or", picking between two values rather than
2095
- evaluating a condition, see the "//" operator below.
2138
+ evaluating a condition, see the `//` operator below.
2096
2139
 
2097
2140
  examples:
2098
2141
  - program: '42 and "a string"'
@@ -2101,9 +2144,6 @@ sections:
2101
2144
  - program: '(true, false) or false'
2102
2145
  input: 'null'
2103
2146
  output: ['true', 'false']
2104
- # - program: '(true, false) and (true, false)'
2105
- # input: 'null'
2106
- # output: ['true', 'false', 'false', 'false']
2107
2147
  - program: '(true, true) and (true, false)'
2108
2148
  input: 'null'
2109
2149
  output: ['true', 'false', 'true', 'false']
@@ -2127,10 +2167,10 @@ sections:
2127
2167
  examples:
2128
2168
  - program: '.foo // 42'
2129
2169
  input: '{"foo": 19}'
2130
- output: [19]
2170
+ output: ['19']
2131
2171
  - program: '.foo // 42'
2132
2172
  input: '{}'
2133
- output: [42]
2173
+ output: ['42']
2134
2174
 
2135
2175
  - title: try-catch
2136
2176
  body: |
@@ -2165,14 +2205,14 @@ sections:
2165
2205
  # Repeat an expression until it raises "break" as an
2166
2206
  # error, then stop repeating without re-raising the error.
2167
2207
  # But if the error caught is not "break" then re-raise it.
2168
- try repeat(exp) catch .=="break" then empty else error;
2208
+ try repeat(exp) catch if .=="break" then empty else error
2169
2209
 
2170
2210
  jq has a syntax for named lexical labels to "break" or "go (back) to":
2171
2211
 
2172
2212
  label $out | ... break $out ...
2173
2213
 
2174
2214
  The `break $label_name` expression will cause the program to
2175
- to act as though the nearest (to the left) `label $label_name`
2215
+ act as though the nearest (to the left) `label $label_name`
2176
2216
  produced `empty`.
2177
2217
 
2178
2218
  The relationship between the `break` and corresponding `label`
@@ -2194,51 +2234,54 @@ sections:
2194
2234
  The `?` operator, used as `EXP?`, is shorthand for `try EXP`.
2195
2235
 
2196
2236
  examples:
2197
- - program: '[.[]|(.a)?]'
2237
+ - program: '[.[] | .a?]'
2198
2238
  input: '[{}, true, {"a":1}]'
2199
2239
  output: ['[null, 1]']
2240
+ - program: '[.[] | tonumber?]'
2241
+ input: '["1", "invalid", "3", 4]'
2242
+ output: ['[1, 3, 4]']
2200
2243
 
2201
-
2202
- - title: Regular expressions (PCRE)
2244
+ - title: Regular expressions
2203
2245
  body: |
2204
2246
 
2205
- jq uses the Oniguruma regular expression library, as do php,
2206
- ruby, TextMate, Sublime Text, etc, so the description here
2247
+ jq uses the Oniguruma regular expression library, as do PHP,
2248
+ Ruby, TextMate, Sublime Text, etc, so the description here
2207
2249
  will focus on jq specifics.
2208
2250
 
2209
2251
  The jq regex filters are defined so that they can be used using
2210
2252
  one of these patterns:
2211
2253
 
2212
- STRING | FILTER( REGEX )
2213
- STRING | FILTER( REGEX; FLAGS )
2214
- STRING | FILTER( [REGEX] )
2215
- STRING | FILTER( [REGEX, FLAGS] )
2254
+ STRING | FILTER(REGEX)
2255
+ STRING | FILTER(REGEX; FLAGS)
2256
+ STRING | FILTER([REGEX])
2257
+ STRING | FILTER([REGEX, FLAGS])
2216
2258
 
2217
2259
  where:
2218
- * STRING, REGEX and FLAGS are jq strings and subject to jq string interpolation;
2219
- * REGEX, after string interpolation, should be a valid PCRE regex;
2260
+
2261
+ * STRING, REGEX, and FLAGS are jq strings and subject to jq string interpolation;
2262
+ * REGEX, after string interpolation, should be a valid regular expression;
2220
2263
  * FILTER is one of `test`, `match`, or `capture`, as described below.
2221
2264
 
2222
2265
  FLAGS is a string consisting of one of more of the supported flags:
2223
2266
 
2224
2267
  * `g` - Global search (find all matches, not just the first)
2225
2268
  * `i` - Case insensitive search
2226
- * `m` - Multi line mode ('.' will match newlines)
2269
+ * `m` - Multi line mode (`.` will match newlines)
2227
2270
  * `n` - Ignore empty matches
2228
2271
  * `p` - Both s and m modes are enabled
2229
- * `s` - Single line mode ('^' -> '\A', '$' -> '\Z')
2272
+ * `s` - Single line mode (`^` -> `\A`, `$` -> `\Z`)
2230
2273
  * `l` - Find longest possible matches
2231
2274
  * `x` - Extended regex format (ignore whitespace and comments)
2232
2275
 
2233
- To match whitespace in an x pattern use an escape such as \s, e.g.
2276
+ To match a whitespace with the `x` flag, use `\s`, e.g.
2234
2277
 
2235
- * test( "a\\sb", "x" ).
2278
+ jq -n '"a b" | test("a\\sb"; "x")'
2236
2279
 
2237
2280
  Note that certain flags may also be specified within REGEX, e.g.
2238
2281
 
2239
- * jq -n '("test", "TEst", "teST", "TEST") | test( "(?i)te(?-i)st" )'
2282
+ jq -n '("test", "TEst", "teST", "TEST") | test("(?i)te(?-i)st")'
2240
2283
 
2241
- evaluates to: true, true, false, false.
2284
+ evaluates to: `true`, `true`, `false`, `false`.
2242
2285
 
2243
2286
  entries:
2244
2287
  - title: "`test(val)`, `test(regex; flags)`"
@@ -2297,7 +2340,7 @@ sections:
2297
2340
 
2298
2341
  - program: '[ match("."; "g")] | length'
2299
2342
  input: '"abc"'
2300
- output: [3]
2343
+ output: ['3']
2301
2344
 
2302
2345
 
2303
2346
  - title: "`capture(val)`, `capture(regex; flags)`"
@@ -2321,24 +2364,20 @@ sections:
2321
2364
  To capture all the matches for each input string, use the idiom
2322
2365
  `[ expr ]`, e.g. `[ scan(regex) ]`.
2323
2366
 
2324
- example:
2367
+ examples:
2325
2368
  - program: 'scan("c")'
2326
2369
  input: '"abcdefabc"'
2327
2370
  output: ['"c"', '"c"']
2328
2371
 
2329
- - program: 'scan("b")'
2330
- input: ("", "")
2331
- output: ['[]', '[]']
2332
-
2333
2372
  - title: "`split(regex; flags)`"
2334
2373
  body: |
2335
2374
 
2336
2375
  For backwards compatibility, `split` splits on a string, not a regex.
2337
2376
 
2338
- example:
2377
+ examples:
2339
2378
  - program: 'split(", *"; null)'
2340
2379
  input: '"ab,cd, ef"'
2341
- output: ['"ab","cd","ef"']
2380
+ output: ['["ab","cd","ef"]']
2342
2381
 
2343
2382
 
2344
2383
  - title: "`splits(regex)`, `splits(regex; flags)`"
@@ -2347,12 +2386,12 @@ sections:
2347
2386
  These provide the same results as their `split` counterparts,
2348
2387
  but as a stream instead of an array.
2349
2388
 
2350
- example:
2389
+ examples:
2351
2390
  - program: 'splits(", *")'
2352
- input: '("ab,cd", "ef, gh")'
2353
- output: ['"ab"', '"cd"', '"ef"', '"gh"']
2391
+ input: '"ab,cd, ef, gh"'
2392
+ output: ['"ab"','"cd"','"ef"','"gh"']
2354
2393
 
2355
- - title: "`sub(regex; tostring)` `sub(regex; string; flags)`"
2394
+ - title: "`sub(regex; tostring)`, `sub(regex; string; flags)`"
2356
2395
  body: |
2357
2396
 
2358
2397
  Emit the string obtained by replacing the first match of regex in the
@@ -2360,12 +2399,12 @@ sections:
2360
2399
  be a jq string, and may contain references to named captures. The
2361
2400
  named captures are, in effect, presented as a JSON object (as
2362
2401
  constructed by `capture`) to `tostring`, so a reference to a captured
2363
- variable named "x" would take the form: "\(.x)".
2402
+ variable named "x" would take the form: `"\(.x)"`.
2364
2403
 
2365
- example:
2366
- - program: 'sub("^[^a-z]*(?<x>[a-z]*).*")'
2367
- input: '"123abc456"'
2368
- output: '"ZabcZabc"'
2404
+ examples:
2405
+ - program: 'sub("[^a-z]*(?<x>[a-z]+)"; "Z\(.x)"; "g")'
2406
+ input: '"123abc456def"'
2407
+ output: ['"ZabcZdef"']
2369
2408
 
2370
2409
 
2371
2410
  - title: "`gsub(regex; string)`, `gsub(regex; string; flags)`"
@@ -2374,10 +2413,10 @@ sections:
2374
2413
  `gsub` is like `sub` but all the non-overlapping occurrences of the regex are
2375
2414
  replaced by the string, after interpolation.
2376
2415
 
2377
- example:
2416
+ examples:
2378
2417
  - program: 'gsub("(?<x>.)[^a]*"; "+\(.x)-")'
2379
2418
  input: '"Abcabc"'
2380
- output: '"+A-+a-"'
2419
+ output: ['"+A-+a-"']
2381
2420
 
2382
2421
 
2383
2422
  - title: Advanced features
@@ -2394,7 +2433,7 @@ sections:
2394
2433
 
2395
2434
  It is also possible to define functions in jq, although this is
2396
2435
  is a feature whose biggest use is defining jq's standard library
2397
- (many jq functions such as `map` and `find` are in fact written
2436
+ (many jq functions such as `map` and `select` are in fact written
2398
2437
  in jq).
2399
2438
 
2400
2439
  jq has reduction operators, which are very powerful but a bit
@@ -2444,7 +2483,7 @@ sections:
2444
2483
  fields, and another object which is used to map author usernames to
2445
2484
  real names. Our input looks like:
2446
2485
 
2447
- {"posts": [{"title": "Frist psot", "author": "anon"},
2486
+ {"posts": [{"title": "First post", "author": "anon"},
2448
2487
  {"title": "A well-written article", "author": "person1"}],
2449
2488
  "realnames": {"anon": "Anonymous Coward",
2450
2489
  "person1": "Person McPherson"}}
@@ -2452,7 +2491,7 @@ sections:
2452
2491
  We want to produce the posts with the author field containing a real
2453
2492
  name, as in:
2454
2493
 
2455
- {"title": "Frist psot", "author": "Anonymous Coward"}
2494
+ {"title": "First post", "author": "Anonymous Coward"}
2456
2495
  {"title": "A well-written article", "author": "Person McPherson"}
2457
2496
 
2458
2497
  We use a variable, $names, to store the realnames object, so that we
@@ -2466,7 +2505,7 @@ sections:
2466
2505
  foreach loop.
2467
2506
 
2468
2507
  Just as `{foo}` is a handy way of writing `{foo: .foo}`, so
2469
- `{$foo}` is a handy way of writing `{foo:$foo}`.
2508
+ `{$foo}` is a handy way of writing `{foo: $foo}`.
2470
2509
 
2471
2510
  Multiple variables may be declared using a single `as` expression by
2472
2511
  providing a pattern that matches the structure of the input
@@ -2513,7 +2552,7 @@ sections:
2513
2552
 
2514
2553
  - title: 'Destructuring Alternative Operator: `?//`'
2515
2554
  body: |
2516
-
2555
+
2517
2556
  The destructuring alternative operator provides a concise mechanism
2518
2557
  for destructuring an input that can take one of several forms.
2519
2558
 
@@ -2522,10 +2561,10 @@ sections:
2522
2561
  the first event for each resource. The API (having been clumsily
2523
2562
  converted from XML) will only wrap the events in an array if the resource
2524
2563
  has multiple events:
2525
-
2564
+
2526
2565
  {"resources": [{"id": 1, "kind": "widget", "events": {"action": "create", "user_id": 1, "ts": 13}},
2527
2566
  {"id": 2, "kind": "widget", "events": [{"action": "create", "user_id": 1, "ts": 14}, {"action": "destroy", "user_id": 1, "ts": 15}]}]}
2528
-
2567
+
2529
2568
  We can use the destructuring alternative operator to handle this structural change simply:
2530
2569
 
2531
2570
  .resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}
@@ -2627,34 +2666,11 @@ sections:
2627
2666
 
2628
2667
  For example, in the following expression there is a binding
2629
2668
  which is visible "to the right" of it, `... | .*3 as
2630
- $times_three | [. + $times_three] | ...`, but not "to the
2669
+ $times_three | [. + $times_three] | ...`, but not "to the
2631
2670
  left". Consider this expression now, `... | (.*3 as
2632
- $times_three | [.+ $times_three]) | ...`: here the binding
2671
+ $times_three | [. + $times_three]) | ...`: here the binding
2633
2672
  `$times_three` is _not_ visible past the closing parenthesis.
2634
2673
 
2635
- - title: Reduce
2636
- body: |
2637
-
2638
- The `reduce` syntax in jq allows you to combine all of the
2639
- results of an expression by accumulating them into a single
2640
- answer. As an example, we'll pass `[3,2,1]` to this expression:
2641
-
2642
- reduce .[] as $item (0; . + $item)
2643
-
2644
- For each result that `.[]` produces, `. + $item` is run to
2645
- accumulate a running total, starting from 0. In this
2646
- example, `.[]` produces the results 3, 2, and 1, so the
2647
- effect is similar to running something like this:
2648
-
2649
- 0 | (3 as $item | . + $item) |
2650
- (2 as $item | . + $item) |
2651
- (1 as $item | . + $item)
2652
-
2653
- examples:
2654
- - program: 'reduce .[] as $item (0; . + $item)'
2655
- input: '[10,2,5,3]'
2656
- output: ['20']
2657
-
2658
2674
  - title: "`isempty(exp)`"
2659
2675
  body: |
2660
2676
 
@@ -2665,6 +2681,14 @@ sections:
2665
2681
  input: 'null'
2666
2682
  output: ['true']
2667
2683
 
2684
+ - program: 'isempty(.[])'
2685
+ input: '[]'
2686
+ output: ['true']
2687
+
2688
+ - program: 'isempty(.[])'
2689
+ input: '[1,2,3]'
2690
+ output: ['false']
2691
+
2668
2692
  - title: "`limit(n; exp)`"
2669
2693
  body: |
2670
2694
 
@@ -2704,32 +2728,79 @@ sections:
2704
2728
  input: '10'
2705
2729
  output: ['[0,9,5]']
2706
2730
 
2731
+ - title: "`reduce`"
2732
+ body: |
2733
+
2734
+ The `reduce` syntax allows you to combine all of the results of
2735
+ an expression by accumulating them into a single answer.
2736
+ The form is `reduce EXP as $var (INIT; UPDATE)`.
2737
+ As an example, we'll pass `[1,2,3]` to this expression:
2738
+
2739
+ reduce .[] as $item (0; . + $item)
2740
+
2741
+ For each result that `.[]` produces, `. + $item` is run to
2742
+ accumulate a running total, starting from 0 as the input value.
2743
+ In this example, `.[]` produces the results `1`, `2`, and `3`,
2744
+ so the effect is similar to running something like this:
2745
+
2746
+ 0 | 1 as $item | . + $item |
2747
+ 2 as $item | . + $item |
2748
+ 3 as $item | . + $item
2749
+
2750
+ examples:
2751
+ - program: 'reduce .[] as $item (0; . + $item)'
2752
+ input: '[1,2,3,4,5]'
2753
+ output: ['15']
2754
+
2755
+ - program: 'reduce .[] as [$i,$j] (0; . + $i * $j)'
2756
+ input: '[[1,2],[3,4],[5,6]]'
2757
+ output: ['44']
2758
+
2759
+ - program: 'reduce .[] as {$x,$y} (null; .x += $x | .y += [$y])'
2760
+ input: '[{"x":"a","y":1},{"x":"b","y":2},{"x":"c","y":3}]'
2761
+ output: ['{"x":"abc","y":[1,2,3]}']
2762
+
2707
2763
  - title: "`foreach`"
2708
2764
  body: |
2709
2765
 
2710
2766
  The `foreach` syntax is similar to `reduce`, but intended to
2711
2767
  allow the construction of `limit` and reducers that produce
2712
- intermediate results (see example).
2768
+ intermediate results.
2713
2769
 
2714
2770
  The form is `foreach EXP as $var (INIT; UPDATE; EXTRACT)`.
2715
- Like `reduce`, `INIT` is evaluated once to produce a state
2716
- value, then each output of `EXP` is bound to `$var`, `UPDATE`
2717
- is evaluated for each output of `EXP` with the current state
2718
- and with `$var` visible. Each value output by `UPDATE`
2719
- replaces the previous state. Finally, `EXTRACT` is evaluated
2720
- for each new state to extract an output of `foreach`.
2771
+ As an example, we'll pass `[1,2,3]` to this expression:
2772
+
2773
+ foreach .[] as $item (0; . + $item; [$item, . * 2])
2774
+
2775
+ Like the `reduce` syntax, `. + $item` is run for each result
2776
+ that `.[]` produces, but `[$item, . * 2]` is run for each
2777
+ intermediate values. In this example, since the intermediate
2778
+ values are `1`, `3`, and `6`, the `foreach` expression produces
2779
+ `[1,2]`, `[2,6]`, and `[3,12]`. So the effect is similar
2780
+ to running something like this:
2781
+
2782
+ 0 | 1 as $item | . + $item | [$item, . * 2],
2783
+ 2 as $item | . + $item | [$item, . * 2],
2784
+ 3 as $item | . + $item | [$item, . * 2]
2721
2785
 
2722
- This is mostly useful only for constructing `reduce`- and
2723
- `limit`-like functions. But it is much more general, as it
2724
- allows for partial reductions (see the example below).
2786
+ When `EXTRACT` is omitted, the identity filter is used.
2787
+ That is, it outputs the intermediate values as they are.
2725
2788
 
2726
2789
  examples:
2727
- - program: '[foreach .[] as $item
2728
- ([[],[]];
2729
- if $item == null then [[],.[0]] else [(.[0] + [$item]),[]] end;
2730
- if $item == null then .[1] else empty end)]'
2731
- input: '[1,2,3,4,null,"a","b",null]'
2732
- output: ['[[1,2,3,4],["a","b"]]']
2790
+ - program: 'foreach .[] as $item (0; . + $item)'
2791
+ input: '[1,2,3,4,5]'
2792
+ output: ['1','3','6','10','15']
2793
+
2794
+ - program: 'foreach .[] as $item (0; . + $item; [$item, . * 2])'
2795
+ input: '[1,2,3,4,5]'
2796
+ output: ['[1,2]','[2,6]','[3,12]','[4,20]','[5,30]']
2797
+
2798
+ - program: 'foreach .[] as $item (0; . + 1; {index: ., $item})'
2799
+ input: '["foo", "bar", "baz"]'
2800
+ output:
2801
+ - '{"index":1,"item":"foo"}'
2802
+ - '{"index":2,"item":"bar"}'
2803
+ - '{"index":3,"item":"baz"}'
2733
2804
 
2734
2805
  - title: Recursion
2735
2806
  body: |
@@ -2868,6 +2939,8 @@ sections:
2868
2939
 
2869
2940
  Outputs one new input.
2870
2941
 
2942
+ echo 1 2 3 4 | jq '[., input]' # [1,2] [3,4]
2943
+
2871
2944
  - title: "`inputs`"
2872
2945
  body: |
2873
2946
 
@@ -2876,6 +2949,8 @@ sections:
2876
2949
  This is primarily useful for reductions over a program's
2877
2950
  inputs.
2878
2951
 
2952
+ echo 1 2 3 | jq -n 'reduce inputs as $i (0; . + $i)' # 6
2953
+
2879
2954
  - title: "`debug`"
2880
2955
  body: |
2881
2956
 
@@ -2922,8 +2997,8 @@ sections:
2922
2997
  Streaming forms include `[<path>, <leaf-value>]` (to indicate any
2923
2998
  scalar value, empty array, or empty object), and `[<path>]` (to
2924
2999
  indicate the end of an array or object). Future versions of jq
2925
- run with `--stream` and `-seq` may output additional forms such as
2926
- `["error message"]` when an input text fails to parse.
3000
+ run with `--stream` and `--seq` may output additional forms such
3001
+ as `["error message"]` when an input text fails to parse.
2927
3002
 
2928
3003
  entries:
2929
3004
  - title: "`truncate_stream(stream_expression)`"
@@ -2934,9 +3009,9 @@ sections:
2934
3009
  given streaming expression.
2935
3010
 
2936
3011
  examples:
2937
- - program: '[1|truncate_stream([[0],1],[[1,0],2],[[1,0]],[[1]])]'
3012
+ - program: 'truncate_stream([[0],1],[[1,0],2],[[1,0]],[[1]])'
2938
3013
  input: '1'
2939
- output: ['[[[0],2],[[0]]]']
3014
+ output: ['[[0],2]', '[[0]]']
2940
3015
 
2941
3016
  - title: "`fromstream(stream_expression)`"
2942
3017
  body: |
@@ -2971,7 +3046,7 @@ sections:
2971
3046
  and you append something to `.foo`, then `.bar` will not get
2972
3047
  bigger, even if you've previously set `.bar = .foo`. If you're
2973
3048
  used to programming in languages like Python, Java, Ruby,
2974
- Javascript, etc. then you can think of it as though jq does a full
3049
+ JavaScript, etc. then you can think of it as though jq does a full
2975
3050
  deep copy of every object before it does the assignment (for
2976
3051
  performance it doesn't actually do that, but that's the general
2977
3052
  idea).
@@ -3008,16 +3083,16 @@ sections:
3008
3083
  entries:
3009
3084
  - title: "Update-assignment: `|=`"
3010
3085
  body: |
3011
- This is the "update" operator '|='. It takes a filter on the
3086
+ This is the "update" operator `|=`. It takes a filter on the
3012
3087
  right-hand side and works out the new value for the property
3013
3088
  of `.` being assigned to by running the old value through this
3014
- expression. For instance, (.foo, .bar) |= .+1 will build an
3089
+ expression. For instance, `(.foo, .bar) |= .+1` will build an
3015
3090
  object with the "foo" field set to the input's "foo" plus 1,
3016
3091
  and the "bar" field set to the input's "bar" plus 1.
3017
3092
 
3018
3093
  The left-hand side can be any general path expression; see `path()`.
3019
3094
 
3020
- Note that the left-hand side of '|=' refers to a value in `.`.
3095
+ Note that the left-hand side of `|=` refers to a value in `.`.
3021
3096
  Thus `$var.foo |= . + 1` won't work as expected (`$var.foo` is
3022
3097
  not a valid or useful path expression in `.`); use `$var |
3023
3098
  .foo |= . + 1` instead.
@@ -3064,27 +3139,27 @@ sections:
3064
3139
 
3065
3140
  This example should show the difference between '=' and '|=':
3066
3141
 
3067
- Provide input '{"a": {"b": 10}, "b": 20}' to the programs:
3142
+ Provide input `{"a": {"b": 10}, "b": 20}` to the programs:
3068
3143
 
3069
- .a = .b
3144
+ `.a = .b`
3070
3145
 
3071
- .a |= .b
3146
+ `.a |= .b`
3072
3147
 
3073
3148
  The former will set the "a" field of the input to the "b"
3074
- field of the input, and produce the output {"a": 20, "b": 20}.
3149
+ field of the input, and produce the output `{"a": 20, "b": 20}`.
3075
3150
  The latter will set the "a" field of the input to the "a"
3076
- field's "b" field, producing {"a": 10, "b": 20}.
3151
+ field's "b" field, producing `{"a": 10, "b": 20}`.
3077
3152
 
3078
- Another example of the difference between '=' and '|=':
3153
+ Another example of the difference between `=` and `|=`:
3079
3154
 
3080
- null|(.a,.b)=range(3)
3155
+ `null|(.a,.b)=range(3)`
3081
3156
 
3082
- outputs '{"a":0,"b":0}', '{"a":1,"b":1}', and '{"a":2,"b":2}',
3157
+ outputs `{"a":0,"b":0}, {"a":1,"b":1}, {"a":2,"b":2}`,
3083
3158
  while
3084
3159
 
3085
- null|(.a,.b)|=range(3)
3160
+ `null|(.a,.b)|=range(3)`
3086
3161
 
3087
- outputs just '{"a":0,"b":0}'.
3162
+ outputs just `{"a":0,"b":0}`.
3088
3163
 
3089
3164
  - title: Complex assignments
3090
3165
  body: |
@@ -3136,13 +3211,13 @@ sections:
3136
3211
  path (see below). The `import` and `include` directives allow the
3137
3212
  importer to alter this path.
3138
3213
 
3139
- Paths in the a search path are subject to various substitutions.
3214
+ Paths in the search path are subject to various substitutions.
3140
3215
 
3141
3216
  For paths starting with "~/", the user's home directory is
3142
3217
  substituted for "~".
3143
3218
 
3144
- For paths starting with "$ORIGIN/", the path of the jq executable
3145
- is substituted for "$ORIGIN".
3219
+ For paths starting with "$ORIGIN/", the directory where the jq
3220
+ executable is located is substituted for "$ORIGIN".
3146
3221
 
3147
3222
  For paths starting with "./" or paths that are ".", the path of
3148
3223
  the including file is substituted for ".". For top-level programs