@port-labs/jq-node-bindings 0.0.4 → 0.0.6

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 (286) hide show
  1. package/binding.gyp +3 -3
  2. package/configure +8 -6
  3. package/deps/jq/.travis.yml +184 -35
  4. package/deps/jq/AUTHORS +31 -30
  5. package/deps/jq/COPYING +2 -2
  6. package/deps/jq/KEYS +8 -0
  7. package/deps/jq/Makefile.am +85 -70
  8. package/deps/jq/NEWS +5 -4
  9. package/deps/jq/README.md +18 -9
  10. package/deps/jq/appveyor.yml +53 -0
  11. package/deps/jq/compile-ios.sh +5 -5
  12. package/deps/jq/config/m4/check-math-func.m4 +7 -2
  13. package/deps/jq/configure.ac +130 -68
  14. package/deps/jq/docs/Rakefile +14 -135
  15. package/deps/jq/docs/Rakefile.manual +49 -0
  16. package/deps/jq/docs/Rakefile.website +76 -0
  17. package/deps/jq/docs/content/2.download/default.yml +115 -39
  18. package/deps/jq/docs/content/3.manual/manual.yml +641 -231
  19. package/deps/jq/docs/content/3.manual/v1.3/manual.yml +130 -130
  20. package/deps/jq/docs/content/3.manual/v1.4/manual.yml +160 -160
  21. package/deps/jq/docs/content/3.manual/v1.5/manual.yml +2878 -0
  22. package/deps/jq/docs/content/3.manual/v1.6/manual.yml +3287 -0
  23. package/deps/jq/docs/content/index/index.yml +28 -6
  24. package/deps/jq/docs/public/.htaccess +2 -2
  25. package/deps/jq/docs/public/css/base.scss +141 -59
  26. package/deps/jq/docs/public/js/manual-search.js +52 -0
  27. package/deps/jq/docs/site.yml +1 -10
  28. package/deps/jq/docs/templates/default.liquid +10 -10
  29. package/deps/jq/docs/templates/index.liquid +45 -32
  30. package/deps/jq/docs/templates/manual.liquid +67 -90
  31. package/deps/jq/docs/templates/shared/_footer.liquid +10 -5
  32. package/deps/jq/docs/templates/shared/_head.liquid +17 -12
  33. package/deps/jq/docs/templates/shared/_navbar.liquid +27 -0
  34. package/deps/jq/jq.1.prebuilt +523 -139
  35. package/deps/jq/modules/oniguruma/AUTHORS +1 -0
  36. package/deps/jq/modules/oniguruma/CMakeLists.txt +86 -0
  37. package/deps/jq/modules/oniguruma/COPYING +28 -0
  38. package/deps/jq/modules/oniguruma/ChangeLog +0 -0
  39. package/deps/jq/modules/oniguruma/HISTORY +2138 -0
  40. package/deps/jq/modules/oniguruma/Makefile.am +33 -0
  41. package/deps/jq/modules/oniguruma/NEWS +0 -0
  42. package/deps/jq/modules/oniguruma/README +189 -0
  43. package/deps/jq/modules/oniguruma/README.ja +195 -0
  44. package/deps/jq/modules/oniguruma/README.md +203 -0
  45. package/deps/jq/modules/oniguruma/cmake/dist.cmake +321 -0
  46. package/deps/jq/modules/oniguruma/compile +348 -0
  47. package/deps/jq/modules/oniguruma/config.guess +1754 -0
  48. package/deps/jq/modules/oniguruma/config.sub +1890 -0
  49. package/deps/jq/modules/oniguruma/configure.ac +87 -0
  50. package/deps/jq/modules/oniguruma/contributed/libfuzzer-onig.cpp +31 -0
  51. package/deps/jq/modules/oniguruma/depcomp +791 -0
  52. package/deps/jq/modules/oniguruma/dist.info +10 -0
  53. package/deps/jq/modules/oniguruma/doc/API +660 -0
  54. package/deps/jq/modules/oniguruma/doc/API.ja +667 -0
  55. package/deps/jq/modules/oniguruma/doc/FAQ +12 -0
  56. package/deps/jq/modules/oniguruma/doc/FAQ.ja +22 -0
  57. package/deps/jq/modules/oniguruma/doc/RE +436 -0
  58. package/deps/jq/modules/oniguruma/doc/RE.ja +448 -0
  59. package/deps/jq/modules/oniguruma/doc/UNICODE_PROPERTIES +698 -0
  60. package/deps/jq/modules/oniguruma/index.html +181 -0
  61. package/deps/jq/modules/oniguruma/index_ja.html +184 -0
  62. package/deps/jq/modules/oniguruma/install-sh +541 -0
  63. package/deps/jq/modules/oniguruma/m4/.whatever +0 -0
  64. package/deps/jq/modules/oniguruma/make_win32.bat +3 -0
  65. package/deps/jq/modules/oniguruma/make_win64.bat +3 -0
  66. package/deps/jq/modules/oniguruma/missing +215 -0
  67. package/deps/jq/modules/oniguruma/onig-config.in +78 -0
  68. package/deps/jq/modules/oniguruma/oniguruma.pc.cmake.in +13 -0
  69. package/deps/jq/modules/oniguruma/oniguruma.pc.in +14 -0
  70. package/deps/jq/modules/oniguruma/sample/CMakeLists.txt +28 -0
  71. package/deps/jq/modules/oniguruma/sample/Makefile.am +34 -0
  72. package/deps/jq/modules/oniguruma/sample/bug_fix.c +131 -0
  73. package/deps/jq/modules/oniguruma/sample/crnl.c +127 -0
  74. package/deps/jq/modules/oniguruma/sample/encode.c +308 -0
  75. package/deps/jq/modules/oniguruma/sample/listcap.c +110 -0
  76. package/deps/jq/modules/oniguruma/sample/names.c +75 -0
  77. package/deps/jq/modules/oniguruma/sample/posix.c +96 -0
  78. package/deps/jq/modules/oniguruma/sample/scan.c +88 -0
  79. package/deps/jq/modules/oniguruma/sample/simple.c +59 -0
  80. package/deps/jq/modules/oniguruma/sample/sql.c +76 -0
  81. package/deps/jq/modules/oniguruma/sample/syntax.c +76 -0
  82. package/deps/jq/modules/oniguruma/sample/user_property.c +87 -0
  83. package/deps/jq/modules/oniguruma/src/Makefile.am +58 -0
  84. package/deps/jq/modules/oniguruma/src/Makefile.windows +183 -0
  85. package/deps/jq/modules/oniguruma/src/ascii.c +61 -0
  86. package/deps/jq/modules/oniguruma/src/big5.c +190 -0
  87. package/deps/jq/modules/oniguruma/src/config.h.cmake.in +71 -0
  88. package/deps/jq/modules/oniguruma/src/config.h.win32 +84 -0
  89. package/deps/jq/modules/oniguruma/src/config.h.win64 +84 -0
  90. package/deps/jq/modules/oniguruma/src/cp1251.c +203 -0
  91. package/deps/jq/modules/oniguruma/src/euc_jp.c +310 -0
  92. package/deps/jq/modules/oniguruma/src/euc_jp_prop.c +158 -0
  93. package/deps/jq/modules/oniguruma/src/euc_jp_prop.gperf +27 -0
  94. package/deps/jq/modules/oniguruma/src/euc_kr.c +188 -0
  95. package/deps/jq/modules/oniguruma/src/euc_tw.c +171 -0
  96. package/deps/jq/modules/oniguruma/src/gb18030.c +538 -0
  97. package/deps/jq/modules/oniguruma/src/gperf_fold_key_conv.py +67 -0
  98. package/deps/jq/modules/oniguruma/src/gperf_unfold_key_conv.py +55 -0
  99. package/deps/jq/modules/oniguruma/src/iso8859_1.c +275 -0
  100. package/deps/jq/modules/oniguruma/src/iso8859_10.c +242 -0
  101. package/deps/jq/modules/oniguruma/src/iso8859_11.c +99 -0
  102. package/deps/jq/modules/oniguruma/src/iso8859_13.c +231 -0
  103. package/deps/jq/modules/oniguruma/src/iso8859_14.c +244 -0
  104. package/deps/jq/modules/oniguruma/src/iso8859_15.c +238 -0
  105. package/deps/jq/modules/oniguruma/src/iso8859_16.c +240 -0
  106. package/deps/jq/modules/oniguruma/src/iso8859_2.c +238 -0
  107. package/deps/jq/modules/oniguruma/src/iso8859_3.c +238 -0
  108. package/deps/jq/modules/oniguruma/src/iso8859_4.c +240 -0
  109. package/deps/jq/modules/oniguruma/src/iso8859_5.c +229 -0
  110. package/deps/jq/modules/oniguruma/src/iso8859_6.c +99 -0
  111. package/deps/jq/modules/oniguruma/src/iso8859_7.c +225 -0
  112. package/deps/jq/modules/oniguruma/src/iso8859_8.c +99 -0
  113. package/deps/jq/modules/oniguruma/src/iso8859_9.c +231 -0
  114. package/deps/jq/modules/oniguruma/src/koi8.c +253 -0
  115. package/deps/jq/modules/oniguruma/src/koi8_r.c +215 -0
  116. package/deps/jq/modules/oniguruma/src/make_unicode_fold.sh +22 -0
  117. package/deps/jq/modules/oniguruma/src/make_unicode_fold_data.py +306 -0
  118. package/deps/jq/modules/oniguruma/src/make_unicode_property.sh +18 -0
  119. package/deps/jq/modules/oniguruma/src/make_unicode_property_data.py +545 -0
  120. package/deps/jq/modules/oniguruma/src/mktable.c +1184 -0
  121. package/deps/jq/modules/oniguruma/src/onig_init.c +45 -0
  122. package/deps/jq/modules/oniguruma/src/oniggnu.h +85 -0
  123. package/deps/jq/modules/oniguruma/src/onigposix.h +169 -0
  124. package/deps/jq/modules/oniguruma/src/oniguruma.h +841 -0
  125. package/deps/jq/modules/oniguruma/src/regcomp.c +6300 -0
  126. package/deps/jq/modules/oniguruma/src/regenc.c +917 -0
  127. package/deps/jq/modules/oniguruma/src/regenc.h +243 -0
  128. package/deps/jq/modules/oniguruma/src/regerror.c +393 -0
  129. package/deps/jq/modules/oniguruma/src/regexec.c +3856 -0
  130. package/deps/jq/modules/oniguruma/src/regext.c +202 -0
  131. package/deps/jq/modules/oniguruma/src/reggnu.c +147 -0
  132. package/deps/jq/modules/oniguruma/src/regint.h +779 -0
  133. package/deps/jq/modules/oniguruma/src/regparse.c +5403 -0
  134. package/deps/jq/modules/oniguruma/src/regparse.h +351 -0
  135. package/deps/jq/modules/oniguruma/src/regposerr.c +105 -0
  136. package/deps/jq/modules/oniguruma/src/regposix.c +306 -0
  137. package/deps/jq/modules/oniguruma/src/regsyntax.c +315 -0
  138. package/deps/jq/modules/oniguruma/src/regtrav.c +76 -0
  139. package/deps/jq/modules/oniguruma/src/regversion.c +57 -0
  140. package/deps/jq/modules/oniguruma/src/sjis.c +341 -0
  141. package/deps/jq/modules/oniguruma/src/sjis_prop.c +158 -0
  142. package/deps/jq/modules/oniguruma/src/sjis_prop.gperf +27 -0
  143. package/deps/jq/modules/oniguruma/src/st.c +589 -0
  144. package/deps/jq/modules/oniguruma/src/st.h +68 -0
  145. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold1_key.c +2250 -0
  146. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold2_key.c +203 -0
  147. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold3_key.c +113 -0
  148. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold_data.c +1225 -0
  149. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data.c +24742 -0
  150. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data_posix.c +4846 -0
  151. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_unfold_key.c +2571 -0
  152. package/deps/jq/modules/oniguruma/src/unicode.c +664 -0
  153. package/deps/jq/modules/oniguruma/src/unicode_fold1_key.c +2548 -0
  154. package/deps/jq/modules/oniguruma/src/unicode_fold2_key.c +203 -0
  155. package/deps/jq/modules/oniguruma/src/unicode_fold3_key.c +113 -0
  156. package/deps/jq/modules/oniguruma/src/unicode_fold_data.c +1366 -0
  157. package/deps/jq/modules/oniguruma/src/unicode_property_data.c +25306 -0
  158. package/deps/jq/modules/oniguruma/src/unicode_property_data_posix.c +4940 -0
  159. package/deps/jq/modules/oniguruma/src/unicode_unfold_key.c +2854 -0
  160. package/deps/jq/modules/oniguruma/src/utf16_be.c +235 -0
  161. package/deps/jq/modules/oniguruma/src/utf16_le.c +245 -0
  162. package/deps/jq/modules/oniguruma/src/utf32_be.c +194 -0
  163. package/deps/jq/modules/oniguruma/src/utf32_le.c +194 -0
  164. package/deps/jq/modules/oniguruma/src/utf8.c +335 -0
  165. package/deps/jq/modules/oniguruma/test/Makefile.am +28 -0
  166. package/deps/jq/modules/oniguruma/test/testc.c +874 -0
  167. package/deps/jq/modules/oniguruma/test/testu.c +916 -0
  168. package/deps/jq/modules/oniguruma/test-driver +153 -0
  169. package/deps/jq/modules/oniguruma/windows/testc.c +869 -0
  170. package/deps/jq/scripts/crosscompile +2 -1
  171. package/deps/jq/scripts/gen_utf8_tables.py +2 -3
  172. package/deps/jq/scripts/update-website +29 -0
  173. package/deps/jq/scripts/version +7 -2
  174. package/deps/jq/sig/jq-release.key +41 -0
  175. package/deps/jq/sig/v1.3/jq-linux-x86.asc +17 -0
  176. package/deps/jq/sig/v1.3/jq-linux-x86_64.asc +17 -0
  177. package/deps/jq/sig/v1.3/jq-osx-x86.asc +17 -0
  178. package/deps/jq/sig/v1.3/jq-osx-x86_64.asc +17 -0
  179. package/deps/jq/sig/v1.3/jq-win32.exe.asc +17 -0
  180. package/deps/jq/sig/v1.3/jq-win64.exe.asc +17 -0
  181. package/deps/jq/sig/v1.3/sha256sum.txt +6 -0
  182. package/deps/jq/sig/v1.4/jq-linux-x86.asc +17 -0
  183. package/deps/jq/sig/v1.4/jq-linux-x86_64.asc +17 -0
  184. package/deps/jq/sig/v1.4/jq-osx-x86.asc +17 -0
  185. package/deps/jq/sig/v1.4/jq-osx-x86_64.asc +17 -0
  186. package/deps/jq/sig/v1.4/jq-solaris11-32.asc +17 -0
  187. package/deps/jq/sig/v1.4/jq-solaris11-64.asc +17 -0
  188. package/deps/jq/sig/v1.4/jq-win32.exe.asc +17 -0
  189. package/deps/jq/sig/v1.4/jq-win64.exe.asc +17 -0
  190. package/deps/jq/sig/v1.4/sha256sum.txt +8 -0
  191. package/deps/jq/sig/v1.5/jq-linux32-no-oniguruma.asc +17 -0
  192. package/deps/jq/sig/v1.5/jq-linux32.asc +17 -0
  193. package/deps/jq/sig/v1.5/jq-linux64.asc +17 -0
  194. package/deps/jq/sig/v1.5/jq-osx-amd64.asc +17 -0
  195. package/deps/jq/sig/v1.5/jq-win32.exe.asc +17 -0
  196. package/deps/jq/sig/v1.5/jq-win64.exe.asc +17 -0
  197. package/deps/jq/sig/v1.5/sha256sum.txt +5 -0
  198. package/deps/jq/sig/v1.5rc1/jq-linux-x86_64-static.asc +17 -0
  199. package/deps/jq/sig/v1.5rc1/jq-win32.exe.asc +17 -0
  200. package/deps/jq/sig/v1.5rc1/jq-win64.exe.asc +17 -0
  201. package/deps/jq/sig/v1.5rc1/sha256sum.txt +3 -0
  202. package/deps/jq/sig/v1.5rc2/jq-linux-x86.asc +17 -0
  203. package/deps/jq/sig/v1.5rc2/jq-linux-x86_64.asc +17 -0
  204. package/deps/jq/sig/v1.5rc2/jq-osx-x86_64.asc +17 -0
  205. package/deps/jq/sig/v1.5rc2/jq-win32.exe.asc +17 -0
  206. package/deps/jq/sig/v1.5rc2/jq-win64.exe.asc +17 -0
  207. package/deps/jq/sig/v1.5rc2/sha256sum.txt +5 -0
  208. package/deps/jq/sig/v1.6/jq-linux32.asc +16 -0
  209. package/deps/jq/sig/v1.6/jq-linux64.asc +16 -0
  210. package/deps/jq/sig/v1.6/jq-osx-amd64.asc +16 -0
  211. package/deps/jq/sig/v1.6/jq-win32.exe.asc +16 -0
  212. package/deps/jq/sig/v1.6/jq-win64.exe.asc +16 -0
  213. package/deps/jq/sig/v1.6/sha256sum.txt +5 -0
  214. package/deps/jq/{builtin.c → src/builtin.c} +449 -344
  215. package/deps/jq/{builtin.h → src/builtin.h} +0 -0
  216. package/deps/jq/src/builtin.jq +311 -0
  217. package/deps/jq/{bytecode.c → src/bytecode.c} +0 -0
  218. package/deps/jq/{bytecode.h → src/bytecode.h} +0 -0
  219. package/deps/jq/{compile.c → src/compile.c} +213 -37
  220. package/deps/jq/{compile.h → src/compile.h} +7 -2
  221. package/deps/jq/{exec_stack.h → src/exec_stack.h} +0 -0
  222. package/deps/jq/{execute.c → src/execute.c} +127 -24
  223. package/deps/jq/{inject_errors.c → src/inject_errors.c} +0 -0
  224. package/deps/jq/{jq.h → src/jq.h} +13 -2
  225. package/deps/jq/{jq_parser.h → src/jq_parser.h} +0 -0
  226. package/deps/jq/{jq_test.c → src/jq_test.c} +1 -1
  227. package/deps/jq/{jv.c → src/jv.c} +24 -5
  228. package/deps/jq/{jv.h → src/jv.h} +46 -11
  229. package/deps/jq/{jv_alloc.c → src/jv_alloc.c} +0 -0
  230. package/deps/jq/{jv_alloc.h → src/jv_alloc.h} +0 -0
  231. package/deps/jq/{jv_aux.c → src/jv_aux.c} +38 -14
  232. package/deps/jq/{jv_dtoa.c → src/jv_dtoa.c} +4 -5
  233. package/deps/jq/{jv_dtoa.h → src/jv_dtoa.h} +0 -0
  234. package/deps/jq/src/jv_file.c +81 -0
  235. package/deps/jq/{jv_parse.c → src/jv_parse.c} +8 -2
  236. package/deps/jq/{jv_print.c → src/jv_print.c} +80 -27
  237. package/deps/jq/{jv_unicode.c → src/jv_unicode.c} +28 -4
  238. package/deps/jq/{jv_unicode.h → src/jv_unicode.h} +1 -0
  239. package/deps/jq/{jv_utf8_tables.h → src/jv_utf8_tables.h} +0 -0
  240. package/deps/jq/{lexer.c → src/lexer.c} +317 -292
  241. package/deps/jq/{lexer.h → src/lexer.h} +16 -12
  242. package/deps/jq/{lexer.l → src/lexer.l} +5 -4
  243. package/deps/jq/src/libm.h +291 -0
  244. package/deps/jq/{linker.c → src/linker.c} +5 -3
  245. package/deps/jq/{linker.h → src/linker.h} +0 -0
  246. package/deps/jq/{locfile.c → src/locfile.c} +1 -1
  247. package/deps/jq/{locfile.h → src/locfile.h} +0 -0
  248. package/deps/jq/{main.c → src/main.c} +202 -100
  249. package/deps/jq/{opcode_list.h → src/opcode_list.h} +4 -0
  250. package/deps/jq/{parser.c → src/parser.c} +1149 -1069
  251. package/deps/jq/{parser.h → src/parser.h} +28 -24
  252. package/deps/jq/{parser.y → src/parser.y} +108 -52
  253. package/deps/jq/{util.c → src/util.c} +12 -9
  254. package/deps/jq/{util.h → src/util.h} +0 -0
  255. package/deps/jq/tests/base64.test +35 -0
  256. package/deps/jq/tests/base64test +5 -0
  257. package/deps/jq/tests/jq-f-test.sh +4 -0
  258. package/deps/jq/tests/jq.test +305 -21
  259. package/deps/jq/tests/jqtest +1 -1
  260. package/deps/jq/tests/mantest +1 -1
  261. package/deps/jq/tests/onig.test +13 -0
  262. package/deps/jq/tests/onigtest +1 -1
  263. package/deps/jq/tests/optional.test +20 -0
  264. package/deps/jq/tests/optionaltest +5 -0
  265. package/deps/jq/tests/setup +7 -1
  266. package/deps/jq/tests/shtest +133 -29
  267. package/deps/jq/tests/utf8-truncate.jq +3 -0
  268. package/deps/jq/tests/utf8test +10 -0
  269. package/lib/index.js +7 -1
  270. package/package.json +3 -3
  271. package/test/santiy.test.js +24 -0
  272. package/deps/jq/docs/default_manpage.md +0 -22
  273. package/deps/jq/docs/public/bootstrap/css/bootstrap-responsive.css +0 -1058
  274. package/deps/jq/docs/public/bootstrap/css/bootstrap-responsive.min.css +0 -9
  275. package/deps/jq/docs/public/bootstrap/css/bootstrap.css +0 -5224
  276. package/deps/jq/docs/public/bootstrap/css/bootstrap.min.css +0 -9
  277. package/deps/jq/docs/public/bootstrap/img/glyphicons-halflings-white.png +0 -0
  278. package/deps/jq/docs/public/bootstrap/img/glyphicons-halflings.png +0 -0
  279. package/deps/jq/docs/public/bootstrap/js/bootstrap.js +0 -2027
  280. package/deps/jq/docs/public/bootstrap/js/bootstrap.min.js +0 -6
  281. package/deps/jq/docs/templates/shared/_header.liquid +0 -26
  282. package/deps/jq/jq.1.default +0 -39
  283. package/deps/jq/jv_file.c +0 -49
  284. package/deps/jq/libm.h +0 -160
  285. package/deps/jq/setup.sh +0 -33
  286. package/reports/jest-port-api.xml +0 -35
@@ -16,7 +16,7 @@ body: |
16
16
  Filters can be combined in various ways - you can pipe the output of
17
17
  one filter into another filter, or collect the output of a filter
18
18
  into an array.
19
-
19
+
20
20
  Some filters produce multiple results, for instance there's one that
21
21
  produces all the elements of its input array. Piping that filter
22
22
  into a second runs the second filter for each element of the
@@ -50,7 +50,7 @@ manpage_intro: |
50
50
  By default, `jq` reads a stream of JSON objects (whitespace
51
51
  separated) from `stdin`. One or more <files> may be specified, in
52
52
  which case `jq` will read input from those instead.
53
-
53
+
54
54
  The <options> are described in the [INVOKING JQ] section, they
55
55
  mostly concern input and output formatting. The <filter> is written
56
56
  in the jq language and specifies how to transform the input
@@ -68,11 +68,11 @@ manpage_epilogue: |
68
68
  ## AUTHOR
69
69
 
70
70
  Stephen Dolan `<mu@netsoc.tcd.ie>`
71
-
71
+
72
72
  sections:
73
73
  - title: Invoking jq
74
74
  body: |
75
-
75
+
76
76
  jq filters run on a stream of JSON data. The input to jq is
77
77
  parsed as a sequence of whitespace-separated JSON values which
78
78
  are passed through the provided filter one at a time. The
@@ -83,46 +83,46 @@ sections:
83
83
  using some command-line options:
84
84
 
85
85
  * `--slurp`/`-s`:
86
-
86
+
87
87
  Instead of running the filter for each JSON object in the
88
88
  input, read the entire input stream into a large array and run
89
89
  the filter just once.
90
-
90
+
91
91
  * `--raw-input`/`-R`:
92
-
92
+
93
93
  Don't parse the input as JSON. Instead, each line of text is
94
94
  passed to the filter as a string. If combined with `--slurp`,
95
95
  then the entire input is passed to the filter as a single long
96
96
  string.
97
-
97
+
98
98
  * `--null-input`/`-n`:
99
-
99
+
100
100
  Don't read any input at all! Instead, the filter is run once
101
101
  using `null` as the input. This is useful when using jq as a
102
102
  simple calculator or to construct JSON data from scratch.
103
-
103
+
104
104
  * `--compact-output` / `-c`:
105
-
105
+
106
106
  By default, jq pretty-prints JSON output. Using this option
107
107
  will result in more compact output by instead putting each
108
108
  JSON object on a single line.
109
-
110
- * `--colour-output` / `-C` and `--monochrome-output` / `-M`:
111
-
109
+
110
+ * `--color-output` / `-C` and `--monochrome-output` / `-M`:
111
+
112
112
  By default, jq outputs colored JSON if writing to a
113
113
  terminal. You can force it to produce color even if writing to
114
114
  a pipe or a file using `-C`, and disable color with `-M`.
115
-
115
+
116
116
  * `--ascii-output` / `-a`:
117
-
117
+
118
118
  jq usually outputs non-ASCII Unicode codepoints as UTF-8, even
119
119
  if the input specified them as escape sequences (like
120
120
  "\u03bc"). Using this option, you can force jq to produce pure
121
121
  ASCII output with every non-ASCII character replaced with the
122
122
  equivalent escape sequence.
123
-
123
+
124
124
  * `--raw-output` / `-r`:
125
-
125
+
126
126
  With this option, if the filter's result is a string then it
127
127
  will be written directly to standard output rather than being
128
128
  formatted as a JSON string with quotes. This can be useful for
@@ -138,7 +138,7 @@ sections:
138
138
  entries:
139
139
  - title: "`.`"
140
140
  body: |
141
-
141
+
142
142
  The absolute simplest (and least interesting) filter
143
143
  is `.`. This is a filter that takes its input and
144
144
  produces it unchanged as output.
@@ -154,7 +154,7 @@ sections:
154
154
 
155
155
  - title: "`.foo`"
156
156
  body: |
157
-
157
+
158
158
  The simplest *useful* filter is .foo. When given a
159
159
  JSON object (aka dictionary or hash) as input, it produces
160
160
  the value at the key "foo", or null if there's none present.
@@ -169,7 +169,7 @@ sections:
169
169
 
170
170
  - title: "`.[foo]`, `.[2]`, `.[10:15]`"
171
171
  body: |
172
-
172
+
173
173
  You can also look up fields of an object using syntax like
174
174
  `.["foo"]` (.foo above is a shorthand version of this). This
175
175
  one works for arrays as well, if the key is an
@@ -195,7 +195,7 @@ sections:
195
195
  - program: '.[2:4]'
196
196
  input: '["a","b","c","d","e"]'
197
197
  output: ['["c", "d"]']
198
-
198
+
199
199
  - program: '.[:3]'
200
200
  input: '["a","b","c","d","e"]'
201
201
  output: ['["a", "b", "c"]']
@@ -206,7 +206,7 @@ sections:
206
206
 
207
207
  - title: "`.[]`"
208
208
  body: |
209
-
209
+
210
210
  If you use the `.[foo]` syntax, but omit the index
211
211
  entirely, it will return *all* of the elements of an
212
212
  array. Running `.[]` with the input `[1,2,3]` will produce the
@@ -233,7 +233,7 @@ sections:
233
233
 
234
234
  - title: "`,`"
235
235
  body: |
236
-
236
+
237
237
  If two filters are separated by a comma, then the
238
238
  input will be fed into both and there will be multiple
239
239
  outputs: first, all of the outputs produced by the left
@@ -248,18 +248,18 @@ sections:
248
248
 
249
249
  - program: ".user, .projects[]"
250
250
  input: '{"user":"stedolan", "projects": ["jq", "wikiflow"]}'
251
- output: ['"stedolan"', '"jq"', '"wikiflow"']
252
-
251
+ output: ['"stedolan"', '"jq"', '"wikiflow"']
252
+
253
253
  - program: '.[4,2]'
254
254
  input: '["a","b","c","d","e"]'
255
255
  output: ['"e"', '"c"']
256
-
256
+
257
257
  - title: "`|`"
258
258
  body: |
259
259
  The | operator combines two filters by feeding the output(s) of
260
260
  the one on the left into the input of the one on the right. It's
261
261
  pretty much the same as the Unix shell's pipe, if you're used to
262
- that.
262
+ that.
263
263
 
264
264
  If the one on the left produces multiple results, the one on
265
265
  the right will be run for each of those results. So, the
@@ -273,7 +273,7 @@ sections:
273
273
 
274
274
  - title: Types and Values
275
275
  body: |
276
-
276
+
277
277
  jq supports the same set of datatypes as JSON - numbers,
278
278
  strings, booleans, arrays, objects (which in JSON-speak are
279
279
  hashes with only string keys), and "null".
@@ -287,7 +287,7 @@ sections:
287
287
  entries:
288
288
  - title: Array construction - `[]`
289
289
  body: |
290
-
290
+
291
291
  As in JSON, `[]` is used to construct arrays, as in
292
292
  `[1,2,3]`. The elements of the arrays can be any jq
293
293
  expression. All of the results produced by all of the
@@ -295,7 +295,7 @@ sections:
295
295
  to construct an array out of a known quantity of values (as
296
296
  in `[.foo, .bar, .baz]`) or to "collect" all the results of a
297
297
  filter into an array (as in `[.items[].name]`)
298
-
298
+
299
299
  Once you understand the "," operator, you can look at jq's array
300
300
  syntax in a different light: the expression `[1,2,3]` is not using a
301
301
  built-in syntax for comma-separated arrays, but is instead applying
@@ -315,49 +315,49 @@ sections:
315
315
 
316
316
  Like JSON, `{}` is for constructing objects (aka
317
317
  dictionaries or hashes), as in: `{"a": 42, "b": 17}`.
318
-
318
+
319
319
  If the keys are "sensible" (all alphabetic characters), then
320
320
  the quotes can be left off. The value can be any expression
321
321
  (although you may need to wrap it in parentheses if it's a
322
322
  complicated one), which gets applied to the {} expression's
323
323
  input (remember, all filters have an input and an
324
324
  output).
325
-
325
+
326
326
  {foo: .bar}
327
-
327
+
328
328
  will produce the JSON object `{"foo": 42}` if given the JSON
329
329
  object `{"bar":42, "baz":43}`. You can use this to select
330
330
  particular fields of an object: if the input is an object
331
331
  with "user", "title", "id", and "content" fields and you
332
332
  just want "user" and "title", you can write
333
-
333
+
334
334
  {user: .user, title: .title}
335
-
335
+
336
336
  Because that's so common, there's a shortcut syntax: `{user, title}`.
337
-
337
+
338
338
  If one of the expressions produces multiple results,
339
339
  multiple dictionaries will be produced. If the input's
340
-
340
+
341
341
  {"user":"stedolan","titles":["JQ Primer", "More JQ"]}
342
-
342
+
343
343
  then the expression
344
-
344
+
345
345
  {user, title: .titles[]}
346
-
347
- will produce two outputs:
348
-
346
+
347
+ will produce two outputs:
348
+
349
349
  {"user":"stedolan", "title": "JQ Primer"}
350
350
  {"user":"stedolan", "title": "More JQ"}
351
-
351
+
352
352
  Putting parentheses around the key means it will be evaluated as an
353
353
  expression. With the same input as above,
354
-
354
+
355
355
  {(.user): .titles}
356
-
356
+
357
357
  produces
358
-
358
+
359
359
  {"stedolan": ["JQ Primer", "More JQ"]}
360
-
360
+
361
361
  examples:
362
362
  - program: '{user, title: .titles[]}'
363
363
  input: '{"user":"stedolan","titles":["JQ Primer", "More JQ"]}'
@@ -376,7 +376,7 @@ sections:
376
376
  etc.). However, jq never does implicit type conversions. If you
377
377
  try to add a string to an object you'll get an error message and
378
378
  no result.
379
-
379
+
380
380
  entries:
381
381
  - title: Addition - `+`
382
382
  body: |
@@ -390,12 +390,12 @@ sections:
390
390
  - **Arrays** are added by being concatenated into a larger array.
391
391
 
392
392
  - **Strings** are added by being joined into a larger string.
393
-
393
+
394
394
  - **Objects** are added by merging, that is, inserting all
395
395
  the key-value pairs from both objects into a single
396
396
  combined object. If both objects contain a value for the
397
397
  same key, the object on the right of the `+` wins.
398
-
398
+
399
399
  `null` can be added to any value, and returns the other
400
400
  value unchanged.
401
401
 
@@ -464,7 +464,7 @@ sections:
464
464
 
465
465
  - title: `keys`
466
466
  body: |
467
-
467
+
468
468
  The builtin function `keys`, when given an object, returns
469
469
  its keys in an array.
470
470
 
@@ -487,7 +487,7 @@ sections:
487
487
 
488
488
  - title: `has`
489
489
  body: |
490
-
490
+
491
491
  The builtin function `has` returns whether the input object
492
492
  has the given key, or the input array has an element at the
493
493
  given index.
@@ -506,11 +506,11 @@ sections:
506
506
 
507
507
  - title: `to_entries`, `from_entries`, `with_entries`
508
508
  body: |
509
-
509
+
510
510
  These functions convert between an object and an array of
511
511
  key-value pairs. If `to_entries` is passed an object, then
512
512
  for each `k: v` entry in the input, the output array
513
- includes `{"key": k, "value": v}`.
513
+ includes `{"key": k, "value": v}`.
514
514
 
515
515
  `from_entries` does the opposite conversion, and
516
516
  `with_entries(foo)` is a shorthand for `to_entries |
@@ -531,7 +531,7 @@ sections:
531
531
 
532
532
  - title: `select`
533
533
  body: |
534
-
534
+
535
535
  The function `select(foo)` produces its input unchanged if
536
536
  `foo` returns true for that input, and produces no output
537
537
  otherwise.
@@ -546,7 +546,7 @@ sections:
546
546
 
547
547
  - title: `empty`
548
548
  body: |
549
-
549
+
550
550
  `empty` returns no results. None at all. Not even `null`.
551
551
 
552
552
  It's useful on occasion. You'll know if you need it :)
@@ -598,10 +598,10 @@ sections:
598
598
 
599
599
  - title: `range`
600
600
  body: |
601
-
601
+
602
602
  The `range` function produces a range of numbers. `range(4;10)`
603
603
  produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers
604
- are produced as separate outputs. Use `[range(4;10)]` to get a range as
604
+ are produced as separate outputs. Use `[range(4;10)]` to get a range as
605
605
  an array.
606
606
 
607
607
  examples:
@@ -611,7 +611,7 @@ sections:
611
611
  - program: '[range(2;4)]'
612
612
  input: 'null'
613
613
  output: ['[2,3]']
614
-
614
+
615
615
  - title: `tonumber`
616
616
  body: |
617
617
 
@@ -638,7 +638,7 @@ sections:
638
638
 
639
639
  - title: `type`
640
640
  body: |
641
-
641
+
642
642
  The `type` function returns the type of its argument as a
643
643
  string, which is one of null, boolean, number, string, array
644
644
  or object.
@@ -650,7 +650,7 @@ sections:
650
650
 
651
651
  - title: `sort, sort_by`
652
652
  body: |
653
-
653
+
654
654
  The `sort` functions sorts its input, which must be an
655
655
  array. Values are sorted in the following order:
656
656
 
@@ -682,7 +682,7 @@ sections:
682
682
 
683
683
  - title: `group_by`
684
684
  body: |
685
-
685
+
686
686
  `group_by(.foo)` takes as input an array, groups the
687
687
  elements having the same `.foo` field into separate arrays,
688
688
  and produces all of these arrays as elements of a larger
@@ -699,7 +699,7 @@ sections:
699
699
 
700
700
  - title: `min`, `max`, `min_by`, `max_by`
701
701
  body: |
702
-
702
+
703
703
  Find the minimum or maximum element of the input array. The
704
704
  `_by` versions allow you to specify a particular field or
705
705
  property to examine, e.g. `min_by(.foo)` finds the object
@@ -715,7 +715,7 @@ sections:
715
715
 
716
716
  - title: `unique`
717
717
  body: |
718
-
718
+
719
719
  The `unique` function takes as input an array and produces
720
720
  an array of the same elements, in sorted order, with
721
721
  duplicates removed.
@@ -727,7 +727,7 @@ sections:
727
727
 
728
728
  - title: `reverse`
729
729
  body: |
730
-
730
+
731
731
  This function reverses an array.
732
732
 
733
733
  examples:
@@ -766,7 +766,7 @@ sections:
766
766
 
767
767
  - title: `recurse`
768
768
  body: |
769
-
769
+
770
770
  The `recurse` function allows you to search through a
771
771
  recursive structure, and extract interesting data from all
772
772
  levels. Suppose your input represents a filesystem:
@@ -778,7 +778,7 @@ sections:
778
778
  {"name": "/home", "children": [
779
779
  {"name": "/home/stephen", "children": [
780
780
  {"name": "/home/stephen/jq", "children": []}]}]}]}
781
-
781
+
782
782
  Now suppose you want to extract all of the filenames
783
783
  present. You need to retrieve `.name`, `.children[].name`,
784
784
  `.children[].children[].name`, and so on. You can do this
@@ -789,7 +789,7 @@ sections:
789
789
  examples:
790
790
  - program: 'recurse(.foo[])'
791
791
  input: '{"foo":[{"foo": []}, {"foo":[{"foo":[]}]}]}'
792
- output:
792
+ output:
793
793
  - '{"foo":[{"foo":[]},{"foo":[{"foo":[]}]}]}'
794
794
  - '{"foo":[]}'
795
795
  - '{"foo":[{"foo":[]}]}'
@@ -807,7 +807,7 @@ sections:
807
807
  - program: '"The input was \(.), which is one less than \(.+1)"'
808
808
  input: '42'
809
809
  output: ['"The input was 42, which is one less than 43"']
810
-
810
+
811
811
  - title: "Format strings and escaping"
812
812
  body: |
813
813
 
@@ -836,17 +836,17 @@ sections:
836
836
  characters to a `%xx` sequence.
837
837
 
838
838
  * `@csv`:
839
-
839
+
840
840
  The input must be an array, and it is rendered as CSV
841
841
  with double quotes for strings, and quotes escaped by
842
842
  repetition.
843
843
 
844
844
  * `@sh`:
845
-
845
+
846
846
  The input is escaped suitable for use in a command-line
847
847
  for a POSIX shell. If the input is an array, the output
848
848
  will be a series of space-separated strings.
849
-
849
+
850
850
  * `@base64`:
851
851
 
852
852
  The input is converted to base64 as specified by RFC 4648.
@@ -879,7 +879,7 @@ sections:
879
879
  - program: '@sh "echo \(.)"'
880
880
  input: "\"O'Hara's Ale\""
881
881
  output: ["\"echo 'O'\\\\''Hara'\\\\''s Ale'\""]
882
-
882
+
883
883
  - title: Conditionals and Comparisons
884
884
  entries:
885
885
  - title: `==`, `!=`
@@ -891,7 +891,7 @@ sections:
891
891
  to numbers. If you're coming from Javascript, jq's == is like
892
892
  Javascript's === - considering values equal only when they have the
893
893
  same type as well as the same value.
894
-
894
+
895
895
  != is "not equal", and 'a != b' returns the opposite value of 'a == b'
896
896
 
897
897
  examples:
@@ -904,7 +904,7 @@ sections:
904
904
  `if A then B else C end` will act the same as `B` if `A`
905
905
  produces a value other than false or null, but act the same
906
906
  as `C` otherwise.
907
-
907
+
908
908
  Checking for false or null is a simpler notion of
909
909
  "truthiness" than is found in Javascript or Python, but it
910
910
  means that you'll sometimes have to be more explicit about
@@ -912,11 +912,11 @@ sections:
912
912
  string is empty using `if .name then A else B end`, you'll
913
913
  need something more like `if (.name | count) > 0 then A else
914
914
  B end` instead.
915
-
916
- If the condition A produces multiple results, it is
917
- considered "true" if any of those results is not false or
918
- null. If it produces zero results, it's considered false.
919
-
915
+
916
+ If the condition `A` produces multiple results, then `B` is evaluated
917
+ once for each result that is not false or null, and `C` is evaluated
918
+ once for each false or null.
919
+
920
920
  More cases can be added to an if using `elif A then B` syntax.
921
921
 
922
922
  examples:
@@ -930,10 +930,10 @@ sections:
930
930
  end
931
931
  input: 2
932
932
  output: ['"many"']
933
-
933
+
934
934
  - title: `>, >=, <=, <`
935
935
  body: |
936
-
936
+
937
937
  The comparison operators `>`, `>=`, `<=`, `<` return whether
938
938
  their left argument is greater than, greater than or equal
939
939
  to, less than or equal to or less than their right argument
@@ -960,14 +960,14 @@ sections:
960
960
  so it is called as a filter to which things can be piped
961
961
  rather than with special syntax, as in `.foo and .bar |
962
962
  not`.
963
-
963
+
964
964
  These three only produce the values "true" and "false", and
965
965
  so are only useful for genuine Boolean operations, rather
966
966
  than the common Perl/Python/Ruby idiom of
967
967
  "value_that_may_be_null or default". If you want to use this
968
968
  form of "or", picking between two values rather than
969
969
  evaluating a condition, see the "//" operator below.
970
-
970
+
971
971
  examples:
972
972
  - program: '42 and "a string"'
973
973
  input: 'null'
@@ -1005,7 +1005,7 @@ sections:
1005
1005
  - program: '.foo // 42'
1006
1006
  input: '{}'
1007
1007
  output: [42]
1008
-
1008
+
1009
1009
  - title: Advanced features
1010
1010
  body: |
1011
1011
  Variables are an absolute necessity in most programming languages, but
@@ -1030,67 +1030,67 @@ sections:
1030
1030
  entries:
1031
1031
  - title: Variables
1032
1032
  body: |
1033
-
1033
+
1034
1034
  In jq, all filters have an input and an output, so manual
1035
1035
  plumbing is not necessary to pass a value from one part of a program
1036
1036
  to the next. Many expressions, for instance `a + b`, pass their input
1037
1037
  to two distinct subexpressions (here `a` and `b` are both passed the
1038
1038
  same input), so variables aren't usually necessary in order to use a
1039
1039
  value twice.
1040
-
1040
+
1041
1041
  For instance, calculating the average value of an array of numbers
1042
1042
  requires a few variables in most languages - at least one to hold the
1043
1043
  array, perhaps one for each element or for a loop counter. In jq, it's
1044
1044
  simply `add / length` - the `add` expression is given the array and
1045
1045
  produces its sum, and the `length` expression is given the array and
1046
1046
  produces its length.
1047
-
1047
+
1048
1048
  So, there's generally a cleaner way to solve most problems in jq that
1049
1049
  defining variables. Still, sometimes they do make things easier, so jq
1050
1050
  lets you define variables using `expression as $variable`. All
1051
1051
  variable names start with `$`. Here's a slightly uglier version of the
1052
1052
  array-averaging example:
1053
-
1053
+
1054
1054
  length as $array_length | add / $array_length
1055
-
1055
+
1056
1056
  We'll need a more complicated problem to find a situation where using
1057
1057
  variables actually makes our lives easier.
1058
-
1059
-
1058
+
1059
+
1060
1060
  Suppose we have an array of blog posts, with "author" and "title"
1061
1061
  fields, and another object which is used to map author usernames to
1062
1062
  real names. Our input looks like:
1063
-
1063
+
1064
1064
  {"posts": [{"title": "Frist psot", "author": "anon"},
1065
1065
  {"title": "A well-written article", "author": "person1"}],
1066
1066
  "realnames": {"anon": "Anonymous Coward",
1067
1067
  "person1": "Person McPherson"}}
1068
-
1068
+
1069
1069
  We want to produce the posts with the author field containing a real
1070
1070
  name, as in:
1071
-
1071
+
1072
1072
  {"title": "Frist psot", "author": "Anonymous Coward"}
1073
1073
  {"title": "A well-written article", "author": "Person McPherson"}
1074
-
1074
+
1075
1075
  We use a variable, $names, to store the realnames object, so that we
1076
1076
  can refer to it later when looking up author usernames:
1077
-
1077
+
1078
1078
  .realnames as $names | .posts[] | {title, author: $names[.author]}
1079
-
1079
+
1080
1080
  The expression `exp as $x | ...` means: for each value of expression
1081
1081
  `exp`, run the rest of the pipeline with the entire original input, and
1082
- with `$x` set to that value. Thus `as` functions as something of a
1082
+ with `$x` set to that value. Thus `as` functions as something of a
1083
1083
  foreach loop.
1084
1084
 
1085
1085
  Variables are scoped over the rest of the expression that defines
1086
- them, so
1087
-
1086
+ them, so
1087
+
1088
1088
  .realnames as $names | (.posts[] | {title, author: $names[.author]})
1089
-
1090
- will work, but
1091
-
1089
+
1090
+ will work, but
1091
+
1092
1092
  (.realnames as $names | .posts[]) | {title, author: $names[.author]}
1093
-
1093
+
1094
1094
  won't.
1095
1095
 
1096
1096
  examples:
@@ -1100,11 +1100,11 @@ sections:
1100
1100
 
1101
1101
  - title: 'Defining Functions'
1102
1102
  body: |
1103
-
1103
+
1104
1104
  You can give a filter a name using "def" syntax:
1105
1105
 
1106
1106
  def increment: . + 1;
1107
-
1107
+
1108
1108
  From then on, `increment` is usable as a filter just like a
1109
1109
  builtin function (in fact, this is how some of the builtins
1110
1110
  are defined). A function may take arguments:
@@ -1135,19 +1135,19 @@ sections:
1135
1135
 
1136
1136
  - title: Reduce
1137
1137
  body: |
1138
-
1138
+
1139
1139
  The `reduce` syntax in jq allows you to combine all of the
1140
1140
  results of an expression by accumulating them into a single
1141
1141
  answer. As an example, we'll pass `[3,2,1]` to this expression:
1142
1142
 
1143
1143
  reduce .[] as $item (0; . + $item)
1144
-
1144
+
1145
1145
  For each result that `.[]` produces, `. + $item` is run to
1146
1146
  accumulate a running total, starting from 0. In this
1147
1147
  example, `.[]` produces the results 3, 2, and 1, so the
1148
1148
  effect is similar to running something like this:
1149
1149
 
1150
- 0 | (3 as $item | . + $item) |
1150
+ 0 | (3 as $item | . + $item) |
1151
1151
  (2 as $item | . + $item) |
1152
1152
  (1 as $item | . + $item)
1153
1153
 
@@ -1155,7 +1155,7 @@ sections:
1155
1155
  - program: 'reduce .[] as $item (0; . + $item)'
1156
1156
  input: '[10,2,5,3]'
1157
1157
  output: ['20']
1158
-
1158
+
1159
1159
 
1160
1160
  - title: Assignment
1161
1161
  body: |
@@ -1177,14 +1177,14 @@ sections:
1177
1177
  entries:
1178
1178
  - title: "`=`"
1179
1179
  body: |
1180
-
1180
+
1181
1181
  The filter `.foo = 1` will take as input an object
1182
1182
  and produce as output an object with the "foo" field set to
1183
1183
  1. There is no notion of "modifying" or "changing" something
1184
1184
  in jq - all jq values are immutable. For instance,
1185
-
1185
+
1186
1186
  .foo = .bar | .foo.baz = 1
1187
-
1187
+
1188
1188
  will not have the side-effect of setting .bar.baz to be set
1189
1189
  to 1, as the similar-looking program in Javascript, Python,
1190
1190
  Ruby or other languages would. Unlike these languages (but
@@ -1193,7 +1193,7 @@ sections:
1193
1193
  "the same object". They can be equal, or not equal, but if
1194
1194
  we change one of them in no circumstances will the other
1195
1195
  change behind our backs.
1196
-
1196
+
1197
1197
  This means that it's impossible to build circular values in
1198
1198
  jq (such as an array whose first element is itself). This is
1199
1199
  quite intentional, and ensures that anything a jq program
@@ -1206,14 +1206,14 @@ sections:
1206
1206
  works out the new value for the property being assigned to by running
1207
1207
  the old value through this expression. For instance, .foo |= .+1 will
1208
1208
  build an object with the "foo" field set to the input's "foo" plus 1.
1209
-
1209
+
1210
1210
  This example should show the difference between '=' and '|=':
1211
-
1211
+
1212
1212
  Provide input '{"a": {"b": 10}, "b": 20}' to the programs:
1213
-
1213
+
1214
1214
  .a = .b
1215
1215
  .a |= .b
1216
-
1216
+
1217
1217
  The former will set the "a" field of the input to the "b" field of the
1218
1218
  input, and produce the output {"a": 20}. The latter will set the "a"
1219
1219
  field of the input to the "a" field's "b" field, producing {"a": 10}.
@@ -1228,43 +1228,43 @@ sections:
1228
1228
  - program: .foo += 1
1229
1229
  input: '{"foo": 42}'
1230
1230
  output: ['{"foo": 43}']
1231
-
1231
+
1232
1232
  - title: Complex assignments
1233
1233
  body: |
1234
1234
  Lots more things are allowed on the left-hand side of a jq assignment
1235
1235
  than in most langauges. We've already seen simple field accesses on
1236
1236
  the left hand side, and it's no surprise that array accesses work just
1237
1237
  as well:
1238
-
1238
+
1239
1239
  .posts[0].title = "JQ Manual"
1240
-
1240
+
1241
1241
  What may come as a surprise is that the expression on the left may
1242
1242
  produce multiple results, referring to different points in the input
1243
1243
  document:
1244
-
1244
+
1245
1245
  .posts[].comments |= . + ["this is great"]
1246
-
1246
+
1247
1247
  That example appends the string "this is great" to the "comments"
1248
1248
  array of each post in the input (where the input is an object with a
1249
1249
  field "posts" which is an array of posts).
1250
-
1250
+
1251
1251
  When jq encounters an assignment like 'a = b', it records the "path"
1252
1252
  taken to select a part of the input document while executing a. This
1253
1253
  path is then used to find which part of the input to change while
1254
1254
  executing the assignment. Any filter may be used on the
1255
1255
  left-hand side of an equals - whichever paths it selects from the
1256
1256
  input will be where the assignment is performed.
1257
-
1257
+
1258
1258
  This is a very powerful operation. Suppose we wanted to add a comment
1259
1259
  to blog posts, using the same "blog" input above. This time, we only
1260
1260
  want to comment on the posts written by "stedolan". We can find those
1261
1261
  posts using the "select" function described earlier:
1262
-
1262
+
1263
1263
  .posts[] | select(.author == "stedolan")
1264
-
1264
+
1265
1265
  The paths provided by this operation point to each of the posts that
1266
1266
  "stedolan" wrote, and we can comment on each of them in the same way
1267
1267
  that we did before:
1268
-
1268
+
1269
1269
  (.posts[] | select(.author == "stedolan") | .comments) |=
1270
1270
  . + ["terrible."]