From 89caf46a5fb0a97274f034affbe5ec05297107b1 Mon Sep 17 00:00:00 2001 From: Stephen Dolan Date: Sun, 28 May 2023 17:06:31 +0100 Subject: Update URLs from stedolan to jqlang --- README.md | 8 +- configure.ac | 4 +- docs/build_manpage.py | 2 +- docs/content/download/default.yml | 68 +++---- docs/content/index.yml | 8 +- docs/content/manual/manual.yml | 2 +- docs/content/manual/v1.3/manual.yml | 2 +- docs/content/manual/v1.4/manual.yml | 2 +- docs/content/manual/v1.5/manual.yml | 2 +- docs/content/manual/v1.6/manual.yml | 2 +- docs/content/tutorial/default.yml | 274 +++++++++++++------------- docs/site.yml | 4 +- docs/templates/index.html.j2 | 6 +- docs/templates/shared/_head.html.j2 | 2 +- docs/templates/shared/_navbar.html.j2 | 6 +- jq.1.prebuilt | 355 +++++++++++++++++++++++++++------- jq.spec | 2 +- libjq.pc.in | 2 +- src/main.c | 4 +- 19 files changed, 490 insertions(+), 265 deletions(-) diff --git a/README.md b/README.md index dcf1e755..44acd13b 100644 --- a/README.md +++ b/README.md @@ -9,18 +9,18 @@ Windows: [![Windows build status](https://ci.appveyor.com/api/projects/status/mi If you want to learn to use jq, read the documentation at -[https://stedolan.github.io/jq](https://stedolan.github.io/jq). This +[https://jqlang.github.io/jq](https://jqlang.github.io/jq). This documentation is generated from the docs/ folder of this repository. You can also try it online at [jqplay.org](https://jqplay.org). If you want to hack on jq, feel free, but be warned that its internals are not well-documented at the moment. Bring a hard hat and a -shovel. Also, read the wiki: https://github.com/stedolan/jq/wiki, where +shovel. Also, read the wiki: https://github.com/jqlang/jq/wiki, where you will find cookbooks, discussion of advanced topics, internals, release engineering, and more. Source tarball and built executable releases can be found on the -homepage and on the github release page, https://github.com/stedolan/jq/releases +homepage and on the github release page, https://github.com/jqlang/jq/releases If you're building directly from the latest git, you'll need flex, bison (3.0 or newer), libtool, make, automake, and autoconf installed. @@ -69,7 +69,7 @@ Cross-compilation requires a clean workspace, then: Use the `--host=` and `--target=` ./configure options to select a cross-compilation environment. See also -["Cross compilation"](https://github.com/stedolan/jq/wiki/Cross-compilation) on +["Cross compilation"](https://github.com/jqlang/jq/wiki/Cross-compilation) on the wiki. Send questions to https://stackoverflow.com/questions/tagged/jq or to the #jq channel (https://web.libera.chat/#jq) on Libera.Chat (https://libera.chat/). diff --git a/configure.ac b/configure.ac index a2cd99e5..ee9094bb 100644 --- a/configure.ac +++ b/configure.ac @@ -3,8 +3,8 @@ m4_define([jq_version], (git describe --tags --dirty --match 'jq-*'|sed 's/^jq-//')) || echo `git rev-parse --abbrev-ref HEAD`-`git describe --always --dirty`]))) -AC_INIT([jq], [jq_version], [https://github.com/stedolan/jq/issues], - [jq], [https://stedolan.github.io/jq]) +AC_INIT([jq], [jq_version], [https://github.com/jqlang/jq/issues], + [jq], [https://jqlang.github.io/jq]) dnl Created autoconf implementation thompson@dtosolutions, 26NOV12 AC_PREREQ([2.64]) diff --git a/docs/build_manpage.py b/docs/build_manpage.py index a0ab4edb..88ce4e9d 100755 --- a/docs/build_manpage.py +++ b/docs/build_manpage.py @@ -187,7 +187,7 @@ class RoffWalker(object): def load_yml_file(fn): with open(fn) as f: - return yaml.load(f) + return yaml.load(f, Loader=yaml.Loader) def dedent_body(body): lines = [re.sub(r'^ (\S)', r'\1', l) for l in body.split('\n')] diff --git a/docs/content/download/default.yml b/docs/content/download/default.yml index 6d170e72..2faad212 100644 --- a/docs/content/download/default.yml +++ b/docs/content/download/default.yml @@ -35,24 +35,24 @@ body: repository. Install using `sudo pacman -S jq`. * jq 1.6 binaries for - [64-bit](https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64) + [64-bit](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64) or - [32-bit](https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux32). + [32-bit](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux32). * jq 1.5 binaries for - [64-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64) + [64-bit](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-linux64) or - [32-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux32). + [32-bit](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-linux32). * jq 1.4 binaries for - [64-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-linux-x86_64) + [64-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-linux-x86_64) or - [32-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-linux-x86). + [32-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-linux-x86). * jq 1.3 binaries for - [64-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-linux-x86_64) + [64-bit](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-linux-x86_64) or - [32-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-linux-x86). + [32-bit](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-linux-x86). ### OS X @@ -66,20 +66,20 @@ body: `port install jq`. * jq 1.6 binary for - [64-bit](https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64). + [64-bit](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-osx-amd64). * jq 1.5 binary for - [64-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64). + [64-bit](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-osx-amd64). * jq 1.4 binaries for - [64-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-osx-x86_64) + [64-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-osx-x86_64) or - [32-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-osx-x86). + [32-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-osx-x86). * jq 1.3 binaries for - [64-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-osx-x86_64) + [64-bit](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-osx-x86_64) or - [32-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-osx-x86). + [32-bit](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-osx-x86). ### FreeBSD @@ -97,9 +97,9 @@ body: 10+, Sparc and x86. * jq 1.4 binaries for Solaris 11 - [64-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-solaris11-64) + [64-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-solaris11-64) or - [32-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-solaris11-32). + [32-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-solaris11-32). ### Windows @@ -107,57 +107,57 @@ body: `chocolatey install jq`. * jq 1.6 executables for - [64-bit](https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win64.exe) + [64-bit](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-win64.exe) or - [32-bit](https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win32.exe). + [32-bit](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-win32.exe). * jq 1.5 executables for - [64-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-win64.exe) + [64-bit](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-win64.exe) or - [32-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-win32.exe). + [32-bit](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-win32.exe). * jq 1.4 executables for - [64-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-win64.exe) + [64-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-win64.exe) or - [32-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-win32.exe). + [32-bit](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-win32.exe). * jq 1.3 executables for - [64-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-win64.exe) + [64-bit](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-win64.exe) or - [32-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-win32.exe). + [32-bit](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-win32.exe). ### Checksums and signatures SHA-256 checksums are provided for all release and pre-release binaries. They can be found under - [sig/v1.x/sha256sum.txt](https://github.com/stedolan/jq/tree/master/sig). + [sig/v1.x/sha256sum.txt](https://github.com/jqlang/jq/tree/master/sig). The checksums for jq 1.6 are in - [sig/v1.6/sha256sum.txt](https://raw.githubusercontent.com/stedolan/jq/master/sig/v1.6/sha256sum.txt). + [sig/v1.6/sha256sum.txt](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.6/sha256sum.txt). The checksums for jq 1.5 are in - [sig/v1.5/sha256sum.txt](https://raw.githubusercontent.com/stedolan/jq/master/sig/v1.5/sha256sum.txt). + [sig/v1.5/sha256sum.txt](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.5/sha256sum.txt). Additionally, all binaries are signed by the - [jq Package Signing Key](https://raw.githubusercontent.com/stedolan/jq/master/sig/jq-release.key). + [jq Package Signing Key](https://raw.githubusercontent.com/jqlang/jq/master/sig/jq-release.key). The signatures can be found under - [sig/v1.x/\*.asc](https://github.com/stedolan/jq/tree/master/sig). + [sig/v1.x/\*.asc](https://github.com/jqlang/jq/tree/master/sig). The signatures for jq 1.6 are in - [sig/v1.5/\*.asc](https://github.com/stedolan/jq/tree/master/sig/v1.6). + [sig/v1.5/\*.asc](https://github.com/jqlang/jq/tree/master/sig/v1.6). The signatures for jq 1.5 are in - [sig/v1.5/\*.asc](https://github.com/stedolan/jq/tree/master/sig/v1.5). + [sig/v1.5/\*.asc](https://github.com/jqlang/jq/tree/master/sig/v1.5). You can use [GnuPG](https://gnupg.org/) to verify a signature by downloading the signature and running `gpg --verify signature.asc`. ### From source on Linux, OS X, Cygwin, and other POSIX-like operating systems - * [Source tarball for jq 1.6](https://github.com/stedolan/jq/releases/download/jq-1.6/jq-1.6.tar.gz) - * [Source tarball for jq 1.5](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz) + * [Source tarball for jq 1.6](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-1.6.tar.gz) + * [Source tarball for jq 1.5](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-1.5.tar.gz) You can build it using the usual `./configure && make && sudo make install` rigmarole. If you're interested in using the lastest development version, try: - git clone --recursive https://github.com/stedolan/jq.git + git clone --recursive https://github.com/jqlang/jq.git cd jq autoreconf -i ./configure --disable-maintainer-mode diff --git a/docs/content/index.yml b/docs/content/index.yml index ee738be9..63d5e263 100644 --- a/docs/content/index.yml +++ b/docs/content/index.yml @@ -35,7 +35,7 @@ news: - date: 1 November 2018 body: | jq 1.6 released. See installation options on the [download](/jq/download/) - page, and the [release notes](https://github.com/stedolan/jq/releases/tag/jq-1.6) + page, and the [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.6) for details. - date: 15 August 2015 @@ -45,20 +45,20 @@ news: try/catch syntax, array and object destructuring, a streaming parser, and a module system. See installation options on the [download](/jq/download/) page, and the - [release notes](https://github.com/stedolan/jq/releases/tag/jq-1.5) + [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.5) for details. - date: 26 July 2015 body: | jq 1.5rc2 is available. Get it on the - [releases](https://github.com/stedolan/jq/releases) page. + [releases](https://github.com/jqlang/jq/releases) page. - date: 01 January 2015 body: | jq 1.5rc1 is available. Get it on the - [releases](https://github.com/stedolan/jq/releases) page. + [releases](https://github.com/jqlang/jq/releases) page. - date: 09 June 2014 body: | diff --git a/docs/content/manual/manual.yml b/docs/content/manual/manual.yml index 442fc0d4..a81cf758 100644 --- a/docs/content/manual/manual.yml +++ b/docs/content/manual/manual.yml @@ -66,7 +66,7 @@ manpage_epilogue: | Presumably. Report them or discuss them at: - https://github.com/stedolan/jq/issues + https://github.com/jqlang/jq/issues ## AUTHOR diff --git a/docs/content/manual/v1.3/manual.yml b/docs/content/manual/v1.3/manual.yml index 3e63f76d..561629da 100644 --- a/docs/content/manual/v1.3/manual.yml +++ b/docs/content/manual/v1.3/manual.yml @@ -63,7 +63,7 @@ manpage_epilogue: | Presumably. Report them or discuss them at: - https://github.com/stedolan/jq/issues + https://github.com/jqlang/jq/issues ## AUTHOR diff --git a/docs/content/manual/v1.4/manual.yml b/docs/content/manual/v1.4/manual.yml index 25e28c31..ec1c4c12 100644 --- a/docs/content/manual/v1.4/manual.yml +++ b/docs/content/manual/v1.4/manual.yml @@ -63,7 +63,7 @@ manpage_epilogue: | Presumably. Report them or discuss them at: - https://github.com/stedolan/jq/issues + https://github.com/jqlang/jq/issues ## AUTHOR diff --git a/docs/content/manual/v1.5/manual.yml b/docs/content/manual/v1.5/manual.yml index 62a68e9a..bdcae54c 100644 --- a/docs/content/manual/v1.5/manual.yml +++ b/docs/content/manual/v1.5/manual.yml @@ -65,7 +65,7 @@ manpage_epilogue: | Presumably. Report them or discuss them at: - https://github.com/stedolan/jq/issues + https://github.com/jqlang/jq/issues ## AUTHOR diff --git a/docs/content/manual/v1.6/manual.yml b/docs/content/manual/v1.6/manual.yml index 1958b693..0f0da783 100644 --- a/docs/content/manual/v1.6/manual.yml +++ b/docs/content/manual/v1.6/manual.yml @@ -65,7 +65,7 @@ manpage_epilogue: | Presumably. Report them or discuss them at: - https://github.com/stedolan/jq/issues + https://github.com/jqlang/jq/issues ## AUTHOR diff --git a/docs/content/tutorial/default.yml b/docs/content/tutorial/default.yml index 5a2dcb83..cad4a6b0 100644 --- a/docs/content/tutorial/default.yml +++ b/docs/content/tutorial/default.yml @@ -5,35 +5,41 @@ body: GitHub has a JSON API, so let's play with that. This URL gets us the last 5 commits from the jq repo. - - command: "curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5'" + - command: "curl 'https://api.github.com/repos/jqlang/jq/commits?per_page=5'" result: | [ { - "sha": "d25341478381063d1c76e81b3a52e0592a7c997f", + "sha": "cff5336ec71b6fee396a95bb0e4bea365e0cd1e8", + "node_id": "C_kwDOAE3WVdoAKGNmZjUzMzZlYzcxYjZmZWUzOTZhOTViYjBlNGJlYTM2NWUwY2QxZTg", "commit": { "author": { - "name": "Stephen Dolan", - "email": "mu@netsoc.tcd.ie", - "date": "2013-06-22T16:30:59Z" + "name": "Mattias Wadman", + "email": "mattias.wadman@gmail.com", + "date": "2021-06-09T14:02:22Z" }, "committer": { - "name": "Stephen Dolan", - "email": "mu@netsoc.tcd.ie", - "date": "2013-06-22T16:30:59Z" + "name": "Nico Williams", + "email": "nico@cryptonector.com", + "date": "2022-05-26T21:04:32Z" }, - "message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161", + "message": "docs: Document repeat(exp)", "tree": { - "sha": "6ab697a8dfb5a96e124666bf6d6213822599fb40", - "url": "https://api.github.com/repos/stedolan/jq/git/trees/6ab697a8dfb5a96e124666bf6d6213822599fb40" + "sha": "d67d5542df1f16d1a48e1fb75749f60482cd874b", + "url": "https://api.github.com/repos/jqlang/jq/git/trees/d67d5542df1f16d1a48e1fb75749f60482cd874b" }, - "url": "https://api.github.com/repos/stedolan/jq/git/commits/d25341478381063d1c76e81b3a52e0592a7c997f", - "comment_count": 0 + "url": "https://api.github.com/repos/jqlang/jq/git/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8", + "comment_count": 0, + "verification": { + "verified": false, + "reason": "unsigned", + "signature": null, + "payload": null + } }, - "url": "https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f", - "html_url": "https://github.com/stedolan/jq/commit/d25341478381063d1c76e81b3a52e0592a7c997f", - "comments_url": "https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f/comments", + "url": "https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8", + "html_url": "https://github.com/jqlang/jq/commit/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8", + "comments_url": "https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8/comments", "author": { - "login": "stedolan", ... - text: | @@ -43,115 +49,125 @@ body: jq program is the expression `.`, which takes the input and produces it unchanged as output. - - command: "curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | jq '.'" + - command: "curl 'https://api.github.com/repos/jqlang/jq/commits?per_page=5' | jq '.'" result: | [ { - "sha": "d25341478381063d1c76e81b3a52e0592a7c997f", + "sha": "cff5336ec71b6fee396a95bb0e4bea365e0cd1e8", + "node_id": "C_kwDOAE3WVdoAKGNmZjUzMzZlYzcxYjZmZWUzOTZhOTViYjBlNGJlYTM2NWUwY2QxZTg", "commit": { "author": { - "name": "Stephen Dolan", - "email": "mu@netsoc.tcd.ie", - "date": "2013-06-22T16:30:59Z" + "name": "Mattias Wadman", + "email": "mattias.wadman@gmail.com", + "date": "2021-06-09T14:02:22Z" }, "committer": { - "name": "Stephen Dolan", - "email": "mu@netsoc.tcd.ie", - "date": "2013-06-22T16:30:59Z" + "name": "Nico Williams", + "email": "nico@cryptonector.com", + "date": "2022-05-26T21:04:32Z" }, - "message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161", + "message": "docs: Document repeat(exp)", "tree": { - "sha": "6ab697a8dfb5a96e124666bf6d6213822599fb40", - "url": "https://api.github.com/repos/stedolan/jq/git/trees/6ab697a8dfb5a96e124666bf6d6213822599fb40" + "sha": "d67d5542df1f16d1a48e1fb75749f60482cd874b", + "url": "https://api.github.com/repos/jqlang/jq/git/trees/d67d5542df1f16d1a48e1fb75749f60482cd874b" }, - "url": "https://api.github.com/repos/stedolan/jq/git/commits/d25341478381063d1c76e81b3a52e0592a7c997f", - "comment_count": 0 + "url": "https://api.github.com/repos/jqlang/jq/git/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8", + "comment_count": 0, + "verification": { + "verified": false, + "reason": "unsigned", + "signature": null, + "payload": null + } }, - "url": "https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f", - "html_url": "https://github.com/stedolan/jq/commit/d25341478381063d1c76e81b3a52e0592a7c997f", - "comments_url": "https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f/comments", + "url": "https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8", + "html_url": "https://github.com/jqlang/jq/commit/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8", + "comments_url": "https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8/comments", "author": { - "login": "stedolan", ... - text: | We can use jq to extract just the first commit. - - command: "curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | jq '.[0]'" + - command: "curl 'https://api.github.com/repos/jqlang/jq/commits?per_page=5' | jq '.[0]'" result: | { - "sha": "d25341478381063d1c76e81b3a52e0592a7c997f", + "sha": "cff5336ec71b6fee396a95bb0e4bea365e0cd1e8", + "node_id": "C_kwDOAE3WVdoAKGNmZjUzMzZlYzcxYjZmZWUzOTZhOTViYjBlNGJlYTM2NWUwY2QxZTg", "commit": { "author": { - "name": "Stephen Dolan", - "email": "mu@netsoc.tcd.ie", - "date": "2013-06-22T16:30:59Z" + "name": "Mattias Wadman", + "email": "mattias.wadman@gmail.com", + "date": "2021-06-09T14:02:22Z" }, "committer": { - "name": "Stephen Dolan", - "email": "mu@netsoc.tcd.ie", - "date": "2013-06-22T16:30:59Z" + "name": "Nico Williams", + "email": "nico@cryptonector.com", + "date": "2022-05-26T21:04:32Z" }, - "message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161", + "message": "docs: Document repeat(exp)", "tree": { - "sha": "6ab697a8dfb5a96e124666bf6d6213822599fb40", - "url": "https://api.github.com/repos/stedolan/jq/git/trees/6ab697a8dfb5a96e124666bf6d6213822599fb40" + "sha": "d67d5542df1f16d1a48e1fb75749f60482cd874b", + "url": "https://api.github.com/repos/jqlang/jq/git/trees/d67d5542df1f16d1a48e1fb75749f60482cd874b" }, - "url": "https://api.github.com/repos/stedolan/jq/git/commits/d25341478381063d1c76e81b3a52e0592a7c997f", - "comment_count": 0 + "url": "https://api.github.com/repos/jqlang/jq/git/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8", + "comment_count": 0, + "verification": { + "verified": false, + "reason": "unsigned", + "signature": null, + "payload": null + } }, - "url": "https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f", - "html_url": "https://github.com/stedolan/jq/commit/d25341478381063d1c76e81b3a52e0592a7c997f", - "comments_url": "https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f/comments", + "url": "https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8", + "html_url": "https://github.com/jqlang/jq/commit/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8", + "comments_url": "https://api.github.com/repos/jqlang/jq/commits/cff5336ec71b6fee396a95bb0e4bea365e0cd1e8/comments", "author": { - "login": "stedolan", - "id": 79765, - "avatar_url": "https://avatars.githubusercontent.com/u/79765?v=3", + "login": "wader", + "id": 185566, + "node_id": "MDQ6VXNlcjE4NTU2Ng==", + "avatar_url": "https://avatars.githubusercontent.com/u/185566?v=4", "gravatar_id": "", - "url": "https://api.github.com/users/stedolan", - "html_url": "https://github.com/stedolan", - "followers_url": "https://api.github.com/users/stedolan/followers", - "following_url": "https://api.github.com/users/stedolan/following{/other_user}", - "gists_url": "https://api.github.com/users/stedolan/gists{/gist_id}", - "starred_url": "https://api.github.com/users/stedolan/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/stedolan/subscriptions", - "organizations_url": "https://api.github.com/users/stedolan/orgs", - "repos_url": "https://api.github.com/users/stedolan/repos", - "events_url": "https://api.github.com/users/stedolan/events{/privacy}", - "received_events_url": "https://api.github.com/users/stedolan/received_events", + "url": "https://api.github.com/users/wader", + "html_url": "https://github.com/wader", + "followers_url": "https://api.github.com/users/wader/followers", + "following_url": "https://api.github.com/users/wader/following{/other_user}", + "gists_url": "https://api.github.com/users/wader/gists{/gist_id}", + "starred_url": "https://api.github.com/users/wader/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/wader/subscriptions", + "organizations_url": "https://api.github.com/users/wader/orgs", + "repos_url": "https://api.github.com/users/wader/repos", + "events_url": "https://api.github.com/users/wader/events{/privacy}", + "received_events_url": "https://api.github.com/users/wader/received_events", "type": "User", "site_admin": false }, "committer": { - "login": "stedolan", - "id": 79765, - "avatar_url": "https://avatars.githubusercontent.com/u/79765?v=3", + "login": "nicowilliams", + "id": 604851, + "node_id": "MDQ6VXNlcjYwNDg1MQ==", + "avatar_url": "https://avatars.githubusercontent.com/u/604851?v=4", "gravatar_id": "", - "url": "https://api.github.com/users/stedolan", - "html_url": "https://github.com/stedolan", - "followers_url": "https://api.github.com/users/stedolan/followers", - "following_url": "https://api.github.com/users/stedolan/following{/other_user}", - "gists_url": "https://api.github.com/users/stedolan/gists{/gist_id}", - "starred_url": "https://api.github.com/users/stedolan/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/stedolan/subscriptions", - "organizations_url": "https://api.github.com/users/stedolan/orgs", - "repos_url": "https://api.github.com/users/stedolan/repos", - "events_url": "https://api.github.com/users/stedolan/events{/privacy}", - "received_events_url": "https://api.github.com/users/stedolan/received_events", + "url": "https://api.github.com/users/nicowilliams", + "html_url": "https://github.com/nicowilliams", + "followers_url": "https://api.github.com/users/nicowilliams/followers", + "following_url": "https://api.github.com/users/nicowilliams/following{/other_user}", + "gists_url": "https://api.github.com/users/nicowilliams/gists{/gist_id}", + "starred_url": "https://api.github.com/users/nicowilliams/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/nicowilliams/subscriptions", + "organizations_url": "https://api.github.com/users/nicowilliams/orgs", + "repos_url": "https://api.github.com/users/nicowilliams/repos", + "events_url": "https://api.github.com/users/nicowilliams/events{/privacy}", + "received_events_url": "https://api.github.com/users/nicowilliams/received_events", "type": "User", "site_admin": false }, "parents": [ { - "sha": "54b9c9bdb225af5d886466d72f47eafc51acb4f7", - "url": "https://api.github.com/repos/stedolan/jq/commits/54b9c9bdb225af5d886466d72f47eafc51acb4f7", - "html_url": "https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7" - }, - { - "sha": "8b1b503609c161fea4b003a7179b3fbb2dd4345a", - "url": "https://api.github.com/repos/stedolan/jq/commits/8b1b503609c161fea4b003a7179b3fbb2dd4345a", - "html_url": "https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a" + "sha": "f2ad9517c72f6267ae317639ab56bbfd4a8653d4", + "url": "https://api.github.com/repos/jqlang/jq/commits/f2ad9517c72f6267ae317639ab56bbfd4a8653d4", + "html_url": "https://github.com/jqlang/jq/commit/f2ad9517c72f6267ae317639ab56bbfd4a8653d4" } ] } @@ -167,8 +183,8 @@ body: - command: "jq '.[0] | {message: .commit.message, name: .commit.committer.name}'" result: | { - "message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161", - "name": "Stephen Dolan" + "message": "docs: Document repeat(exp)", + "name": "Nico Williams" } - text: | @@ -183,24 +199,24 @@ body: - command: "jq '.[] | {message: .commit.message, name: .commit.committer.name}'" result: | { - "message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161", - "name": "Stephen Dolan" + "message": "docs: Document repeat(exp)", + "name": "Nico Williams" } { - "message": "Reject all overlong UTF8 sequences.", - "name": "Stephen Dolan" + "message": "Mention -n in IO-section and for input/inputs", + "name": "Nico Williams" } { - "message": "Fix various UTF8 parsing bugs.\n\nIn particular, parse bad UTF8 by replacing the broken bits with U+FFFD\nand resychronise correctly after broken sequences.", - "name": "Stephen Dolan" + "message": "Fix iterration problem for non decimal string\n\nWhen the string transformation to number failed, all following\ntransformation failed too.\n\nThis happend because status in decNumberFromString function is\nupdated just in error case. Reusing the DEC_CONTEXT that failed\nbefore results into error even if the string is valid number.", + "name": "Nico Williams" } { - "message": "Fix example in manual for `floor`. See #155.", - "name": "Stephen Dolan" + "message": "docs: point to Libera.Chat instead of Freenode", + "name": "Nico Williams" } { - "message": "Document floor", - "name": "Nicolas Williams" + "message": "Missing \"va_end\" call. This was found by running the cppcheck static analysis where it shows as error.", + "name": "Nico Williams" } - text: | @@ -225,24 +241,24 @@ body: result: | [ { - "message": "Merge pull request #163 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161", - "name": "Stephen Dolan" + "message": "docs: Document repeat(exp)", + "name": "Nico Williams" }, { - "message": "Reject all overlong UTF8 sequences.", - "name": "Stephen Dolan" + "message": "Mention -n in IO-section and for input/inputs", + "name": "Nico Williams" }, { - "message": "Fix various UTF8 parsing bugs.\n\nIn particular, parse bad UTF8 by replacing the broken bits with U+FFFD\nand resychronise correctly after broken sequences.", - "name": "Stephen Dolan" + "message": "Fix iterration problem for non decimal string\n\nWhen the string transformation to number failed, all following\ntransformation failed too.\n\nThis happend because status in decNumberFromString function is\nupdated just in error case. Reusing the DEC_CONTEXT that failed\nbefore results into error even if the string is valid number.", + "name": "Nico Williams" }, { - "message": "Fix example in manual for `floor`. See #155.", - "name": "Stephen Dolan" + "message": "docs: point to Libera.Chat instead of Freenode", + "name": "Nico Williams" }, { - "message": "Document floor", - "name": "Nicolas Williams" + "message": "Missing \"va_end\" call. This was found by running the cppcheck static analysis where it shows as error.", + "name": "Nico Williams" } ] @@ -256,14 +272,9 @@ body: "parents": [ { - "sha": "54b9c9bdb225af5d886466d72f47eafc51acb4f7", - "url": "https://api.github.com/repos/stedolan/jq/commits/54b9c9bdb225af5d886466d72f47eafc51acb4f7", - "html_url": "https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7" - }, - { - "sha": "8b1b503609c161fea4b003a7179b3fbb2dd4345a", - "url": "https://api.github.com/repos/stedolan/jq/commits/8b1b503609c161fea4b003a7179b3fbb2dd4345a", - "html_url": "https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a" + "sha": "f2ad9517c72f6267ae317639ab56bbfd4a8653d4", + "url": "https://api.github.com/repos/jqlang/jq/commits/f2ad9517c72f6267ae317639ab56bbfd4a8653d4", + "html_url": "https://github.com/jqlang/jq/commit/f2ad9517c72f6267ae317639ab56bbfd4a8653d4" } ] @@ -275,39 +286,38 @@ body: result: | [ { - "message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161", - "name": "Stephen Dolan", + "message": "docs: Document repeat(exp)", + "name": "Nico Williams", "parents": [ - "https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7", - "https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a" + "https://github.com/jqlang/jq/commit/f2ad9517c72f6267ae317639ab56bbfd4a8653d4" ] }, { - "message": "Reject all overlong UTF8 sequences.", - "name": "Stephen Dolan", + "message": "Mention -n in IO-section and for input/inputs", + "name": "Nico Williams", "parents": [ - "https://github.com/stedolan/jq/commit/ff48bd6ec538b01d1057be8e93b94eef6914e9ef" + "https://github.com/jqlang/jq/commit/c4d39c4d22f2b12225ca1b311708f7e084ad9ff8" ] }, { - "message": "Fix various UTF8 parsing bugs.\n\nIn particular, parse bad UTF8 by replacing the broken bits with U+FFFD\nand resychronise correctly after broken sequences.", - "name": "Stephen Dolan", + "message": "Fix iterration problem for non decimal string\n\nWhen the string transformation to number failed, all following\ntransformation failed too.\n\nThis happend because status in decNumberFromString function is\nupdated just in error case. Reusing the DEC_CONTEXT that failed\nbefore results into error even if the string is valid number.", + "name": "Nico Williams", "parents": [ - "https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7" + "https://github.com/jqlang/jq/commit/174db0f93552bdb551ae1f3c5c64744df0ad8e2f" ] }, { - "message": "Fix example in manual for `floor`. See #155.", - "name": "Stephen Dolan", + "message": "docs: point to Libera.Chat instead of Freenode", + "name": "Nico Williams", "parents": [ - "https://github.com/stedolan/jq/commit/3dcdc582ea993afea3f5503a78a77675967ecdfa" + "https://github.com/jqlang/jq/commit/29cf77977ef52eec708982b19bf9d2ec17443337" ] }, { - "message": "Document floor", - "name": "Nicolas Williams", + "message": "Missing \"va_end\" call. This was found by running the cppcheck static analysis where it shows as error.", + "name": "Nico Williams", "parents": [ - "https://github.com/stedolan/jq/commit/7c4171d414f647ab08bcd20c76a4d8ed68d9c602" + "https://github.com/jqlang/jq/commit/55e6e2c21829bd866bd4b18ee254b05c9020320a" ] } ] diff --git a/docs/site.yml b/docs/site.yml index 69a7c397..e4990aeb 100644 --- a/docs/site.yml +++ b/docs/site.yml @@ -1,9 +1,9 @@ # The key value pairs found below are available within the templates. -url: https://stedolan.github.io/jq +url: https://jqlang.github.io/jq # This line is modified by the Makefile. To change the version number, # edit the Autoconf version number at the top of configure.ac -jq_version: "1.4-2-g15c4a7f-dirty" +jq_version: "1.6-159-gcff5336-dirty" root: '/jq' diff --git a/docs/templates/index.html.j2 b/docs/templates/index.html.j2 index 4567ef55..ab262c26 100644 --- a/docs/templates/index.html.j2 +++ b/docs/templates/index.html.j2 @@ -24,9 +24,9 @@ diff --git a/docs/templates/shared/_head.html.j2 b/docs/templates/shared/_head.html.j2 index f7242627..96c3c4dc 100644 --- a/docs/templates/shared/_head.html.j2 +++ b/docs/templates/shared/_head.html.j2 @@ -1,6 +1,6 @@ diff --git a/docs/templates/shared/_navbar.html.j2 b/docs/templates/shared/_navbar.html.j2 index be1eb377..a3adb3ad 100644 --- a/docs/templates/shared/_navbar.html.j2 +++ b/docs/templates/shared/_navbar.html.j2 @@ -17,10 +17,10 @@ {{item | capitalize}} {% endfor %} -
  • Issues
  • -
  • Source
  • +
  • Issues
  • +
  • Source
  • Try online!
  • -
  • News
  • +
  • News
  • diff --git a/jq.1.prebuilt b/jq.1.prebuilt index 0049b2c3..e8a33e40 100644 --- a/jq.1.prebuilt +++ b/jq.1.prebuilt @@ -1,7 +1,5 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "JQ" "1" "December 2017" "" "" +.TH "JQ" "1" "May 2023" "" "" . .SH "NAME" \fBjq\fR \- Command\-line JSON processor @@ -16,7 +14,7 @@ \fBjq\fR can accept text input as well, but by default, \fBjq\fR reads a stream of JSON entities (including numbers and other literals) from \fBstdin\fR\. Whitespace is only needed to separate entities such as 1 and 2, and true and false\. One or more \fIfiles\fR may be specified, in which case \fBjq\fR will read input from those instead\. . .P -The \fIoptions\fR are described in the \fIINVOKING JQ\fR section; they mostly concern input and output formatting\. The \fIfilter\fR is written in the jq language and specifies how to transform the input file or document\. +The \fIoptions\fR are described in the [INVOKING JQ] section; they mostly concern input and output formatting\. The \fIfilter\fR is written in the jq language and specifies how to transform the input file or document\. . .SH "FILTERS" A jq program is a "filter": it takes an input, and produces an output\. There are a lot of builtin filters for extracting a particular field of an object, or converting a number to a string, or various other standard tasks\. @@ -42,64 +40,64 @@ Note: it is important to mind the shell\'s quoting rules\. As a general rule it\ .P You can affect how jq reads and writes its input and output using some command\-line options: . -.IP "\(bu" 4 +.TP \fB\-\-version\fR: . .IP Output the jq version and exit with zero\. . -.IP "\(bu" 4 +.TP \fB\-\-seq\fR: . .IP Use the \fBapplication/json\-seq\fR MIME type scheme for separating JSON texts in jq\'s input and output\. This means that an ASCII RS (record separator) character is printed before each value on output and an ASCII LF (line feed) is printed after every output\. Input JSON texts that fail to parse are ignored (but warned about), discarding all subsequent input until the next RS\. This mode also parses the output of jq without the \fB\-\-seq\fR option\. . -.IP "\(bu" 4 +.TP \fB\-\-stream\fR: . .IP -Parse the input in streaming fashion, outputting arrays of path and leaf values (scalars and empty arrays or empty objects)\. For example, \fB"a"\fR becomes \fB[[],"a"]\fR, and \fB[[],"a",["b"]]\fR becomes \fB[[0],[]]\fR, \fB[[1],"a"]\fR, and \fB[[1,0],"b"]\fR\. +Parse the input in streaming fashion, outputting arrays of path and leaf values (scalars and empty arrays or empty objects)\. For example, \fB"a"\fR becomes \fB[[],"a"]\fR, and \fB[[],"a",["b"]]\fR becomes \fB[[0],[]]\fR, \fB[[1],"a"]\fR, and \fB[[2,0],"b"]\fR\. . .IP This is useful for processing very large inputs\. Use this in conjunction with filtering and the \fBreduce\fR and \fBforeach\fR syntax to reduce large inputs incrementally\. . -.IP "\(bu" 4 +.TP \fB\-\-slurp\fR/\fB\-s\fR: . .IP Instead of running the filter for each JSON object in the input, read the entire input stream into a large array and run the filter just once\. . -.IP "\(bu" 4 +.TP \fB\-\-raw\-input\fR/\fB\-R\fR: . .IP Don\'t parse the input as JSON\. Instead, each line of text is passed to the filter as a string\. If combined with \fB\-\-slurp\fR, then the entire input is passed to the filter as a single long string\. . -.IP "\(bu" 4 +.TP \fB\-\-null\-input\fR/\fB\-n\fR: . .IP Don\'t read any input at all! Instead, the filter is run once using \fBnull\fR as the input\. This is useful when using jq as a simple calculator or to construct JSON data from scratch\. . -.IP "\(bu" 4 +.TP \fB\-\-compact\-output\fR / \fB\-c\fR: . .IP By default, jq pretty\-prints JSON output\. Using this option will result in more compact output by instead putting each JSON object on a single line\. . -.IP "\(bu" 4 +.TP \fB\-\-tab\fR: . .IP Use a tab for each indentation level instead of two spaces\. . -.IP "\(bu" 4 +.TP \fB\-\-indent n\fR: . .IP Use the given number of spaces (no more than 7) for indentation\. . -.IP "\(bu" 4 +.TP \fB\-\-color\-output\fR / \fB\-C\fR and \fB\-\-monochrome\-output\fR / \fB\-M\fR: . .IP @@ -108,49 +106,61 @@ By default, jq outputs colored JSON if writing to a terminal\. You can force it .IP Colors can be configured with the \fBJQ_COLORS\fR environment variable (see below)\. . -.IP "\(bu" 4 +.TP +\fB\-\-binary\fR / \fB\-b\fR: +. +.IP +Windows users using WSL, MSYS2, or Cygwin, should use this option when using a native jq\.exe, otherwise jq will turn newlines (LFs) into carriage\-return\-then\-newline (CRLF)\. +. +.TP \fB\-\-ascii\-output\fR / \fB\-a\fR: . .IP jq usually outputs non\-ASCII Unicode codepoints as UTF\-8, even if the input specified them as escape sequences (like "\eu03bc")\. Using this option, you can force jq to produce pure ASCII output with every non\-ASCII character replaced with the equivalent escape sequence\. . -.IP "\(bu" 4 -\fB\-\-unbuffered\fR +.TP +\fB\-\-unbuffered\fR: . .IP Flush the output after each JSON object is printed (useful if you\'re piping a slow data source into jq and piping jq\'s output elsewhere)\. . -.IP "\(bu" 4 +.TP \fB\-\-sort\-keys\fR / \fB\-S\fR: . .IP Output the fields of each object with the keys in sorted order\. . -.IP "\(bu" 4 +.TP \fB\-\-raw\-output\fR / \fB\-r\fR: . .IP With this option, if the filter\'s result is a string then it will be written directly to standard output rather than being formatted as a JSON string with quotes\. This can be useful for making jq filters talk to non\-JSON\-based systems\. . -.IP "\(bu" 4 +.TP \fB\-\-join\-output\fR / \fB\-j\fR: . .IP Like \fB\-r\fR but jq won\'t print a newline after each output\. . -.IP "\(bu" 4 +.TP +\fB\-\-nul\-output\fR / \fB\-0\fR: +. +.IP +Like \fB\-r\fR but jq will print NUL instead of newline after each output\. This can be useful when the values being output can contain newlines\. +. +.TP \fB\-f filename\fR / \fB\-\-from\-file filename\fR: . .IP Read filter from the file rather than from a command line, like awk\'s \-f option\. You can also use \'#\' to make comments\. . -.IP "\(bu" 4 +.TP \fB\-Ldirectory\fR / \fB\-L directory\fR: . .IP Prepend \fBdirectory\fR to the search list for modules\. If this option is used then no builtin search list is used\. See the section on modules below\. . -.IP "\(bu" 4 +.TP \fB\-e\fR / \fB\-\-exit\-status\fR: . .IP @@ -159,7 +169,7 @@ Sets the exit status of jq to 0 if the last output values was neither \fBfalse\f .IP Another way to set the exit status is with the \fBhalt_error\fR builtin function\. . -.IP "\(bu" 4 +.TP \fB\-\-arg name value\fR: . .IP @@ -168,19 +178,25 @@ This option passes a value to the jq program as a predefined variable\. If you r .IP Named arguments are also available to the jq program as \fB$ARGS\.named\fR\. . -.IP "\(bu" 4 +.TP \fB\-\-argjson name JSON\-text\fR: . .IP This option passes a JSON\-encoded value to the jq program as a predefined variable\. If you run jq with \fB\-\-argjson foo 123\fR, then \fB$foo\fR is available in the program and has the value \fB123\fR\. . -.IP "\(bu" 4 +.TP \fB\-\-slurpfile variable\-name filename\fR: . .IP -This option reads all the JSON texts in the named file and binds an array of the parsed JSON values to the given global variable\. If you run jq with \fB\-\-argfile foo bar\fR, then \fB$foo\fR is available in the program and has an array whose elements correspond to the texts in the file named \fBbar\fR\. +This option reads all the JSON texts in the named file and binds an array of the parsed JSON values to the given global variable\. If you run jq with \fB\-\-slurpfile foo bar\fR, then \fB$foo\fR is available in the program and has an array whose elements correspond to the texts in the file named \fBbar\fR\. . -.IP "\(bu" 4 +.TP +\fB\-\-rawfile variable\-name filename\fR: +. +.IP +This option reads in the named file and binds its contents to the given global variable\. If you run jq with \fB\-\-rawfile foo bar\fR, then \fB$foo\fR is available in the program and has a string whose contents are to the texts in the file named \fBbar\fR\. +. +.TP \fB\-\-argfile variable\-name filename\fR: . .IP @@ -189,19 +205,19 @@ Do not use\. Use \fB\-\-slurpfile\fR instead\. .IP (This option is like \fB\-\-slurpfile\fR, but when the file has just one text, then that is used, else an array of texts is used as in \fB\-\-slurpfile\fR\.) . -.IP "\(bu" 4 +.TP \fB\-\-args\fR: . .IP Remaining arguments are positional string arguments\. These are available to the jq program as \fB$ARGS\.positional[]\fR\. . -.IP "\(bu" 4 +.TP \fB\-\-jsonargs\fR: . .IP Remaining arguments are positional JSON text arguments\. These are available to the jq program as \fB$ARGS\.positional[]\fR\. . -.IP "\(bu" 4 +.TP \fB\-\-run\-tests [filename]\fR: . .IP @@ -210,8 +226,6 @@ Runs the tests in the given file or standard input\. This must be the last optio .IP Be warned that this option can change backwards\-incompatibly\. . -.IP "" 0 -. .SH "BASIC FILTERS" . .SS "Identity: \." @@ -220,6 +234,15 @@ The absolute simplest filter is \fB\.\fR \. This is a filter that takes its inpu .P Since jq by default pretty\-prints all output, this trivial program can be a useful way of formatting JSON output from, say, \fBcurl\fR\. . +.P +An important point about the identity filter is that it guarantees to preserve the literal decimal representation of values\. This is particularly important when dealing with numbers which can\'t be losslessly converted to an IEEE754 double precision representation\. +. +.P +jq doesn\'t truncate the literal numbers to double unless there is a need to make arithmetic operations with the number\. Comparisions are carried out over the untruncated big decimal representation of the number\. +. +.P +jq will also try to maintain the original decimal precision of the provided number literal\. See below for examples\. +. .IP "" 4 . .nf @@ -227,6 +250,18 @@ Since jq by default pretty\-prints all output, this trivial program can be a use jq \'\.\' "Hello, world!" => "Hello, world!" + +jq \'\. | tojson\' + 12345678909876543212345 +=> "12345678909876543212345" + +jq \'map([\., \. == 1]) | tojson\' + [1, 1\.000, 1\.0, 100e\-2] +=> "[[1,true],[1\.000,true],[1\.0,true],[1\.00,true]]" + +jq \'\. as $big | [$big, $big + 1] | map(\. > 10000000000000000000000000000000)\' + 10000000000000000000000000000001 +=> [true, false] . .fi . @@ -242,7 +277,7 @@ A filter of the form \fB\.foo\.bar\fR is equivalent to \fB\.foo|\.bar\fR\. This syntax only works for simple, identifier\-like keys, that is, keys that are all made of alphanumeric characters and underscore, and which do not start with a digit\. . .P -If the key contains special characters, you need to surround it with double quotes like this: \fB\."foo$"\fR, or else \fB\.["foo$"]\fR\. +If the key contains special characters or starts with a digit, you need to surround it with double quotes like this: \fB\."foo$"\fR, or else \fB\.["foo$"]\fR\. . .P For example \fB\.["foo::bar"]\fR and \fB\.["foo\.bar"]\fR work while \fB\.foo::bar\fR does not, and \fB\.foo\.bar\fR means \fB\.["foo"]\.["bar"]\fR\. @@ -366,7 +401,7 @@ jq \'\.[]\' jq \'\.[]\' [] -=> +=> jq \'\.[]\' {"a": 1, "b": 1} @@ -447,6 +482,12 @@ jq supports the same set of datatypes as JSON \- numbers, strings, booleans, arr .P Booleans, null, strings and numbers are written the same way as in javascript\. Just like everything else in jq, these simple values take an input and produce an output \- \fB42\fR is a valid jq expression that takes an input, ignores it, and returns 42 instead\. . +.P +Numbers in jq are internally represented by their IEEE754 double precision approximation\. Any arithmetic operation with numbers, whether they are literals or results of previous filters, will produce a double precision floating point result\. +. +.P +However, when parsing a literal jq will store the original literal string\. If no mutation is applied to this value then it will make to the output in its original form, even if conversion to double would result in a loss\. +. .SS "Array construction: []" As in JSON, \fB[]\fR is used to construct arrays, as in \fB[1,2,3]\fR\. The elements of the arrays can be any jq expression, including a pipeline\. All of the results produced by all of the expressions are collected into one big array\. You can use it to construct an array out of a known quantity of values (as in \fB[\.foo, \.bar, \.baz]\fR) or to "collect" all the results of a filter into an array (as in \fB[\.items[]\.name]\fR) . @@ -476,10 +517,10 @@ jq \'[ \.[] | \. * 2]\' Like JSON, \fB{}\fR is for constructing objects (aka dictionaries or hashes), as in: \fB{"a": 42, "b": 17}\fR\. . .P -If the keys are "identifier\-like", then the quotes can be left off, as in \fB{a:42, b:17}\fR\. Keys generated by expressions need to be parenthesized, e\.g\., \fB{("a"+"b"):59}\fR\. +If the keys are "identifier\-like", then the quotes can be left off, as in \fB{a:42, b:17}\fR\. Variable references as key expressions use the value of the variable as the key\. Key expressions other than constant literals, identifiers, or variable references, need to be parenthesized, e\.g\., \fB{("a"+"b"):59}\fR\. . .P -The value can be any expression (although you may need to wrap it in parentheses if it\'s a complicated one), which gets applied to the {} expression\'s input (remember, all filters have an input and an output)\. +The value can be any expression (although you may need to wrap it in parentheses if, for example, it contains colons), which gets applied to the {} expression\'s input (remember, all filters have an input and an output)\. . .IP "" 4 . @@ -568,6 +609,32 @@ produces .nf {"stedolan": ["JQ Primer", "More JQ"]} +. +.fi +. +.IP "" 0 +. +.P +Variable references as keys use the value of the variable as the key\. Without a value then the variable\'s name becomes the key and its value becomes the value, +. +.IP "" 4 +. +.nf + +"f o o" as $foo | "b a r" as $bar | {$foo, $bar:$foo} +. +.fi +. +.IP "" 0 +. +.P +produces +. +.IP "" 4 +. +.nf + +{"f o o":"f o o","b a r":"f o o"} jq \'{user, title: \.titles[]}\' {"user":"stedolan","titles":["JQ Primer", "More JQ"]} @@ -602,6 +669,12 @@ jq \'\.\.|\.a?\' .SH "BUILTIN OPERATORS AND FUNCTIONS" Some jq operator (for instance, \fB+\fR) do different things depending on the type of their arguments (arrays, numbers, etc\.)\. However, jq never does implicit type conversions\. If you try to add a string to an object you\'ll get an error message and no result\. . +.P +Please note that all numbers are converted to IEEE754 double precision floating point representation\. Arithmetic and logical operators are working with these converted doubles\. Results of all such operations are also limited to the double precision\. +. +.P +The only exception to this behaviour of number is a snapshot of original number literal\. When a number which originally was provided as a literal is never mutated until the end of the program then it is printed to the output in its original literal form\. This also includes cases when the original literal would be truncated when converted to the IEEE754 double precision floating point number\. +. .SS "Addition: +" The operator \fB+\fR takes two filters, applies them both to the same input, and adds the results together\. What "adding" means depends on the types involved: . @@ -720,8 +793,15 @@ The length of an \fBobject\fR is the number of key\-value pairs\. .IP "\(bu" 4 The length of \fBnull\fR is zero\. . -.IP -jq \'\.[] | length\' [[1,2], "string", {"a":2}, null] => 2, 6, 1, 0 +.IP "" 4 +. +.nf + +jq \'\.[] | length\' + [[1,2], "string", {"a":2}, null] +=> 2, 6, 1, 0 +. +.fi . .IP "" 0 . @@ -1039,7 +1119,7 @@ Stops the jq program with no further outputs\. The input will be printed on \fBs The given \fBexit_code\fR (defaulting to \fB5\fR) will be jq\'s exit status\. . .P -For example, \fB"Error: something went wrong\en"|halt_error(1)\fR\. +For example, \fB"Error: somthing went wrong\en"|halt_error(1)\fR\. . .SS "$__loc__" Produces an object with a "file" key and a "line" key, with the filename and line number where \fB$__loc__\fR occurs, as values\. @@ -1201,7 +1281,7 @@ jq \'flatten\' . .IP "" 0 . -.SS "range(upto), range(from;upto) range(from;upto;by)" +.SS "range(upto), range(from;upto), range(from;upto;by)" The \fBrange\fR function produces a range of numbers\. \fBrange(4;10)\fR produces 6 numbers, from 4 (inclusive) to 10 (exclusive)\. The numbers are produced as separate outputs\. Use \fB[range(4;10)]\fR to get a range as an array\. . .P @@ -1748,6 +1828,24 @@ jq \'[while(\.<100; \.*2)]\' . .IP "" 0 . +.SS "repeat(exp)" +The \fBrepeat(exp)\fR function allows you to repeatedly apply expression \fBexp\fR to \fB\.\fR until an error is raised\. +. +.P +Note that \fBrepeat(exp)\fR is internally defined as a recursive jq function\. Recursive calls within \fBrepeat\fR will not consume additional memory if \fBexp\fR produces at most one output for each input\. See advanced topics below\. +. +.IP "" 4 +. +.nf + +jq \'[repeat(\.*2, error)?]\' + 1 +=> [2] +. +.fi +. +.IP "" 0 +. .SS "until(cond; next)" The \fBuntil(cond; next)\fR function allows you to repeatedly apply the expression \fBnext\fR, initially to \fB\.\fR then to its own output, until \fBcond\fR is true\. For example, this can be used to implement a factorial function (see below)\. . @@ -1893,7 +1991,7 @@ jq \'transpose\' .IP "" 0 . .SS "bsearch(x)" -bsearch(x) conducts a binary search for x in the input array\. If the input is sorted and contains x, then bsearch(x) will return its index in the array; otherwise, if the array is sorted, it will return (\-1 \- ix) where ix is an insertion point such that the array would still be sorted after the insertion of x at ix\. If the array is not sorted, bsearch(x) will return an integer that is probably of no interest\. +\fBbsearch(x)\fR conducts a binary search for x in the input array\. If the input is sorted and contains x, then \fBbsearch(x)\fR will return its index in the array; otherwise, if the array is sorted, it will return (\-1 \- ix) where ix is an insertion point such that the array would still be sorted after the insertion of x at ix\. If the array is not sorted, \fBbsearch(x)\fR will return an integer that is probably of no interest\. . .IP "" 4 . @@ -1931,7 +2029,7 @@ jq \'"The input was \e(\.), which is one less than \e(\.+1)"\' .IP "" 0 . .SS "Convert to/from JSON" -The \fBtojson\fR and \fBfromjson\fR builtins dump values as JSON texts or parse JSON texts into values, respectively\. The tojson builtin differs from tostring in that tostring returns strings unmodified, while tojson encodes strings as JSON strings\. +The \fBtojson\fR and \fBfromjson\fR builtins dump values as JSON texts or parse JSON texts into values, respectively\. The \fBtojson\fR builtin differs from \fBtostring\fR in that \fBtostring\fR returns strings unmodified, while \fBtojson\fR encodes strings as JSON strings\. . .IP "" 4 . @@ -2008,7 +2106,7 @@ The input is converted to base64 as specified by RFC 4648\. \fB@base64d\fR: . .IP -The inverse of \fB@base64\fR, input is decoded as specified by RFC 4648\. Note: If the decoded string is not UTF\-8, the results are undefined\. +The inverse of \fB@base64\fR, input is decoded as specified by RFC 4648\. Note\e: If the decoded string is not UTF\-8, the results are undefined\. . .P This syntax can be combined with string interpolation in a useful way\. You can follow a \fB@foo\fR token with a string literal\. The contents of the string literal will \fInot\fR be escaped\. However, all interpolations made inside that string literal will be escaped\. For instance, @@ -2188,7 +2286,10 @@ jq \'\.[] == 1\' \fBif A then B else C end\fR will act the same as \fBB\fR if \fBA\fR produces a value other than false or null, but act the same as \fBC\fR otherwise\. . .P -Checking for false or null is a simpler notion of "truthiness" than is found in Javascript or Python, but it means that you\'ll sometimes have to be more explicit about the condition you want: you can\'t test whether, e\.g\. a string is empty using \fBif \.name then A else B end\fR, you\'ll need something more like \fBif (\.name | length) > 0 then A else B end\fR instead\. +\fBif A then B end\fR is the same as \fBif A then B else \. end\fR\. That is, the \fBelse\fR branch is optional, and if absent is the same as \fB\.\fR\. +. +.P +Checking for false or null is a simpler notion of "truthiness" than is found in Javascript or Python, but it means that you\'ll sometimes have to be more explicit about the condition you want\. You can\'t test whether, e\.g\. a string is empty using \fBif \.name then A else B end\fR, you\'ll need something more like \fBif \.name == "" then A else B end\fR instead\. . .P If the condition \fBA\fR produces multiple results, then \fBB\fR is evaluated once for each result that is not false or null, and \fBC\fR is evaluated once for each false or null\. @@ -2200,15 +2301,14 @@ More cases can be added to an if using \fBelif A then B\fR syntax\. . .nf -jq \'if \. == 0 then +jq \'if \. == 0 then "zero" elif \. == 1 then "one" else "many" end\' + 2 +=> "many" . .fi . .IP "" 0 . -.P -"zero" elif \. == 1 then "one" else "many" end\' 2 => "many" -. .SS ">, >=, <=, <" The comparison operators \fB>\fR, \fB>=\fR, \fB<=\fR, \fB<\fR return whether their left argument is greater than, greater than or equal to, less than or equal to or less than their right argument (respectively)\. . @@ -2413,7 +2513,18 @@ STRING | FILTER( [REGEX, FLAGS] ) .IP "" 0 . .P -where: * STRING, REGEX and FLAGS are jq strings and subject to jq string interpolation; * REGEX, after string interpolation, should be a valid PCRE regex; * FILTER is one of \fBtest\fR, \fBmatch\fR, or \fBcapture\fR, as described below\. +where: +. +.IP "\(bu" 4 +STRING, REGEX and FLAGS are jq strings and subject to jq string interpolation; +. +.IP "\(bu" 4 +REGEX, after string interpolation, should be a valid PCRE regex; +. +.IP "\(bu" 4 +FILTER is one of \fBtest\fR, \fBmatch\fR, or \fBcapture\fR, as described below\. +. +.IP "" 0 . .P FLAGS is a string consisting of one of more of the supported flags: @@ -2448,7 +2559,7 @@ FLAGS is a string consisting of one of more of the supported flags: To match whitespace in an x pattern use an escape such as \es, e\.g\. . .IP "\(bu" 4 -test( "a\esb", "x" )\. +test( "a\e\esb"; "x" ) . .IP "" 0 . @@ -2571,7 +2682,7 @@ For backwards compatibility, \fBsplit\fR splits on a string, not a regex\. .SS "splits(regex), splits(regex; flags)" These provide the same results as their \fBsplit\fR counterparts, but as a stream instead of an array\. . -.SS "sub(regex; tostring) sub(regex; string; flags)" +.SS "sub(regex; tostring), sub(regex; string; flags)" Emit the string obtained by replacing the first match of regex in the input string with \fBtostring\fR, after interpolation\. \fBtostring\fR should be a jq string, and may contain references to named captures\. The named captures are, in effect, presented as a JSON object (as constructed by \fBcapture\fR) to \fBtostring\fR, so a reference to a captured variable named "x" would take the form: "(\.x)"\. . .SS "gsub(regex; string), gsub(regex; string; flags)" @@ -2657,7 +2768,7 @@ We use a variable, $names, to store the realnames object, so that we can refer t . .nf -\&\.realnames as $names | \.posts[] | {title, author: $names[\.author]} +\&.realnames as $names | \.posts[] | {title, author: $names[\.author]} . .fi . @@ -2676,7 +2787,7 @@ Multiple variables may be declared using a single \fBas\fR expression by providi . .nf -\&\. as {realnames: $names, posts: [$first, $second]} | \.\.\. +\&. as {realnames: $names, posts: [$first, $second]} | \.\.\. . .fi . @@ -2692,7 +2803,7 @@ Variables are scoped over the rest of the expression that defines them, so . .nf -\&\.realnames as $names | (\.posts[] | {title, author: $names[\.author]}) +\&.realnames as $names | (\.posts[] | {title, author: $names[\.author]}) . .fi . @@ -2741,6 +2852,87 @@ jq \'\.[] as [$a, $b] | {a: $a, b: $b}\' . .IP "" 0 . +.SS "Destructuring Alternative Operator: ?//" +The destructuring alternative operator provides