summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Langford <wlangfor@gmail.com>2020-03-02 10:46:27 -0500
committerWilliam Langford <wlangfor@gmail.com>2020-03-02 10:46:51 -0500
commit76c044f301c3d33b122974e405a80f2b0775dce7 (patch)
tree65c12cf01320bab3a4f1cd2d9e82a010c7b0f9da
parentc084d78c14df549d90f34c0bd20ddf22ac3e4de8 (diff)
downloadjq-gh-pages.tar.gz
Regenerate websitegh-pages
-rw-r--r--css/base.css174
-rw-r--r--download/index.html236
-rw-r--r--index.html51
-rw-r--r--js/manual-search.js53
-rw-r--r--manual/index.html3734
-rw-r--r--manual/v1.3/index.html1406
-rw-r--r--manual/v1.4/index.html1877
-rw-r--r--manual/v1.5/index.html3182
-rw-r--r--manual/v1.6/index.html3785
-rw-r--r--tutorial/index.html410
10 files changed, 7476 insertions, 7432 deletions
diff --git a/css/base.css b/css/base.css
index 2d6abb3..e9bb818 100644
--- a/css/base.css
+++ b/css/base.css
@@ -1 +1,173 @@
-body{padding-top:80px}.container{max-width:970px}#blurb{padding-top:40px}#blurb p{font-size:1.9em}#blurb .btn-group{margin:4px}#multiblurb{line-height:1.7;text-align:center;font-size:12pt}#multiblurb code{border:0;font-size:12pt}#news{font-size:12pt}#news .date{font-style:italic}.tutorial-example{position:relative;margin-bottom:10px}.tutorial-example pre{margin-bottom:0}.tutorial-example a{position:absolute;top:0;right:0;padding:15px 8px;color:#777;font-weight:bold;line-height:10px;font-size:12px;border-left:1px solid #ddd;display:block}.tutorial-example .accordion-body pre{margin:0 4px;border-top:0;border-top-left-radius:0;border-top-right-radius:0}@media print{.tutorial-example a{display:none}}section{padding-top:24px}h3 code{border:0;font-size:20px}@media(max-width:991px){#navcolumn{position:relative !important;margin-bottom:60px}}@media(min-width:992px){#manualcontent{padding-left:280px}}.nav-pills{margin-bottom:20px}.nav-pills li a{padding:8px 12px}.manual-example table{border-top:1px solid #e5e5e5}.manual-example table td{white-space:pre-wrap;font-family:Monaco,Menlo,Consolas,"Courier New",monospace}.manual-example table td.jqprogram{font-weight:bold}.manual-example table th{text-align:right;padding-right:10px}@media print{#navcolumn{display:none !important}.manual-example{display:block !important;height:auto !important}.jqplay-btn{display:none !important}}footer{background-color:#f5f5f5;padding:20px 0;margin-top:40px;color:#999;text-align:center}footer p{margin:8px 0}.twitter-typeahead{width:100%}.tt-menu{width:100%;background-color:#fff;padding:8px 0;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2)}.tt-suggestion{padding:3px 20px}.tt-suggestion:hover{cursor:pointer;color:#fff;background-color:#446e9b}.tt-suggestion.tt-cursor{color:#fff;background-color:#446e9b}.tt-suggestion p{margin:0} \ No newline at end of file
+body {
+ padding-top: 80px;
+}
+
+.container {
+ max-width: 970px;
+}
+
+/* index.liquid *******************************************/
+#blurb {
+ padding-top: 40px;
+}
+#blurb p {
+ font-size: 1.9em;
+}
+#blurb .btn-group {
+ margin: 4px;
+}
+
+#multiblurb {
+ line-height: 1.7;
+ text-align: center;
+ font-size: 12pt;
+}
+#multiblurb code {
+ border: 0;
+ font-size: 12pt;
+}
+
+#news {
+ font-size: 12pt;
+}
+#news .date {
+ font-style: italic;
+}
+
+/* default.liquid *****************************************/
+.tutorial-example {
+ position: relative;
+ margin-bottom: 10px;
+}
+.tutorial-example pre {
+ margin-bottom: 0px;
+}
+.tutorial-example a {
+ position: absolute;
+ top: 0px;
+ right: 0px;
+ padding: 15px 8px;
+ color: #777777;
+ font-weight: bold;
+ line-height: 10px;
+ font-size: 12px;
+ border-left: 1px solid #DDDDDD;
+ display: block;
+}
+.tutorial-example .accordion-body pre {
+ margin: 0 4px;
+ border-top: 0;
+ border-top-left-radius: 0;
+ border-top-right-radius: 0;
+}
+
+@media print {
+ .tutorial-example a {
+ display: none;
+ }
+}
+/* manual.liquid ******************************************/
+section {
+ padding-top: 24px;
+}
+
+h3 code {
+ border: 0;
+ font-size: 20px;
+}
+
+@media (max-width: 991px) {
+ #navcolumn {
+ /* Put nav column above manual content */
+ position: relative !important;
+ margin-bottom: 60px;
+ }
+}
+@media (min-width: 992px) {
+ #manualcontent {
+ /* Put nav column left of manual content */
+ padding-left: 280px;
+ }
+}
+.nav-pills {
+ margin-bottom: 20px;
+}
+ .nav-pills li a {
+ padding: 8px 12px;
+}
+
+.manual-example table {
+ border-top: 1px solid #E5E5E5;
+}
+.manual-example table td {
+ white-space: pre-wrap;
+ font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
+}
+.manual-example table td.jqprogram {
+ font-weight: bold;
+}
+.manual-example table th {
+ text-align: right;
+ padding-right: 10px;
+}
+
+@media print {
+ #navcolumn {
+ display: none !important;
+ }
+
+ .manual-example {
+ display: block !important;
+ height: auto !important;
+ }
+
+ .jqplay-btn {
+ display: none !important;
+ }
+}
+/* shared/_footer.liquid **********************************/
+footer {
+ background-color: #F5F5F5;
+ padding: 20px 0;
+ margin-top: 40px;
+ color: #999999;
+ text-align: center;
+}
+footer p {
+ margin: 8px 0;
+}
+
+/* typeahead **********************************************/
+.twitter-typeahead {
+ width: 100%;
+}
+
+.tt-menu {
+ width: 100%;
+ background-color: #fff;
+ padding: 8px 0;
+ border: 1px solid #ccc;
+ border: 1px solid rgba(0, 0, 0, 0.2);
+ -webkit-border-radius: 8px;
+ -moz-border-radius: 8px;
+ border-radius: 8px;
+ -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+}
+
+.tt-suggestion {
+ padding: 3px 20px;
+}
+.tt-suggestion:hover {
+ cursor: pointer;
+ color: #fff;
+ background-color: #446e9b;
+}
+.tt-suggestion.tt-cursor {
+ color: #fff;
+ background-color: #446e9b;
+}
+.tt-suggestion p {
+ margin: 0;
+}
diff --git a/download/index.html b/download/index.html
index 863c5c8..f96d23e 100644
--- a/download/index.html
+++ b/download/index.html
@@ -18,7 +18,6 @@
<![endif]-->
</head>
-
<body id="download">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
@@ -56,175 +55,217 @@
</div>
</div>
-
<div class="container">
<div class="row">
<h1>Download jq</h1>
-
-<p>jq is written in C and has no runtime dependencies, so it should be possible to build it for nearly any platform. Prebuilt binaries are available for Linux, OS X and Windows.</p>
-
-<p>The binaries should just run, but on OS X and Linux you may need to make them executable first using <code>chmod +x jq</code>.</p>
-
-<p>jq is licensed under the MIT license. For all of the gory details, read the file <code>COPYING</code> in the source distribution.</p>
-
-<h3 id="linux">Linux</h3>
-
+ <p>jq is written in C and has no runtime dependencies, so it should be
+possible to build it for nearly any platform. Prebuilt binaries are
+available for Linux, OS X and Windows.</p>
+<p>The binaries should just run, but on OS X and Linux you may need
+to make them executable first using <code>chmod +x jq</code>.</p>
+<p>jq is licensed under the MIT license. For all of the gory
+details, read the file <code>COPYING</code> in the source distribution.</p>
+<p>jq uses a C library for decimal number support. This is an ICU 1.8.1
+licensed code obtained from the ICU downloads archive
+http://download.icu-project.org/files/decNumber/decNumber-icu-368.zip.</p>
+<h3>Linux</h3>
<ul>
<li>
-<p>jq 1.5 is in the official <a href="https://packages.debian.org/jq">Debian</a> and <a href="http://packages.ubuntu.com/jq">Ubuntu</a> repositories. Install using <code>sudo apt-get install jq</code>.</p>
+<p>jq 1.5 is in the official <a href="https://packages.debian.org/jq">Debian</a> and
+ <a href="http://packages.ubuntu.com/jq">Ubuntu</a> repositories. Install using
+ <code>sudo apt-get install jq</code>.</p>
</li>
-
<li>
-<p>jq 1.5 is in the official <a href="http://pkgs.fedoraproject.org/cgit/jq.git/">Fedora</a> repository. Install using <code>sudo dnf install jq</code>.</p>
+<p>jq 1.5 is in the official
+ <a href="http://pkgs.fedoraproject.org/cgit/jq.git/">Fedora</a> repository.
+ Install using <code>sudo dnf install jq</code>.</p>
</li>
-
<li>
-<p>jq 1.4 is in the official <a href="https://software.opensuse.org/package/jq">openSUSE</a> repository. Install using <code>sudo zypper install jq</code>.</p>
+<p>jq 1.4 is in the official <a href="https://software.opensuse.org/package/jq">openSUSE</a>
+ repository. Install using <code>sudo zypper install jq</code>.</p>
</li>
-
<li>
-<p>jq 1.5 is in the official <a href="https://www.archlinux.org/packages/?sort=&q=jq&maintainer=&flagged=">Arch</a> repository. Install using <code>sudo pacman -Sy jq</code>.</p>
+<p>jq 1.5 is in the official
+ <a href="https://www.archlinux.org/packages/?sort=&amp;q=jq&amp;maintainer=&amp;flagged=">Arch</a>
+ repository. Install using <code>sudo pacman -S jq</code>.</p>
</li>
-
<li>
-<p>jq 1.6 binaries for <a href="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64">64-bit</a> or <a href="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux32">32-bit</a>.</p>
+<p>jq 1.6 binaries for
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64">64-bit</a>
+ or
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux32">32-bit</a>.</p>
</li>
-
<li>
-<p>jq 1.5 binaries for <a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64">64-bit</a> or <a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux32">32-bit</a>.</p>
+<p>jq 1.5 binaries for
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64">64-bit</a>
+ or
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux32">32-bit</a>.</p>
</li>
-
<li>
-<p>jq 1.4 binaries for <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-linux-x86_64">64-bit</a> or <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-linux-x86">32-bit</a>.</p>
+<p>jq 1.4 binaries for
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-linux-x86_64">64-bit</a>
+ or
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-linux-x86">32-bit</a>.</p>
</li>
-
<li>
-<p>jq 1.3 binaries for <a href="https://github.com/stedolan/jq/releases/download/jq-1.3/jq-linux-x86_64">64-bit</a> or <a href="https://github.com/stedolan/jq/releases/download/jq-1.3/jq-linux-x86">32-bit</a>.</p>
+<p>jq 1.3 binaries for
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.3/jq-linux-x86_64">64-bit</a>
+ or
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.3/jq-linux-x86">32-bit</a>.</p>
</li>
</ul>
-
-<h3 id="os_x">OS X</h3>
-
+<h3>OS X</h3>
<ul>
<li>
-<p>Use <a href="http://brew.sh/">Homebrew</a> to install jq 1.6 with <code>brew install jq</code>.</p>
+<p>Use <a href="http://brew.sh/">Homebrew</a> to install jq 1.6 with
+ <code>brew install jq</code>.</p>
</li>
-
<li>
-<p>jq 1.6 binary for <a href="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64">64-bit</a>.</p>
+<p>Use <a href="https://www.macports.org">MacPorts</a> to install jq 1.6 with
+ <code>port install jq</code>.</p>
</li>
-
<li>
-<p>jq 1.5 binary for <a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64">64-bit</a>.</p>
+<p>jq 1.6 binary for
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64">64-bit</a>.</p>
</li>
-
<li>
-<p>jq 1.4 binaries for <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-osx-x86_64">64-bit</a> or <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-osx-x86">32-bit</a>.</p>
+<p>jq 1.5 binary for
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64">64-bit</a>.</p>
+</li>
+<li>
+<p>jq 1.4 binaries for
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-osx-x86_64">64-bit</a>
+ or
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-osx-x86">32-bit</a>.</p>
</li>
-
<li>
-<p>jq 1.3 binaries for <a href="https://github.com/stedolan/jq/releases/download/jq-1.3/jq-osx-x86_64">64-bit</a> or <a href="https://github.com/stedolan/jq/releases/download/jq-1.3/jq-osx-x86">32-bit</a>.</p>
+<p>jq 1.3 binaries for
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.3/jq-osx-x86_64">64-bit</a>
+ or
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.3/jq-osx-x86">32-bit</a>.</p>
</li>
</ul>
-
-<h3 id="freebsd">FreeBSD</h3>
-
+<h3>FreeBSD</h3>
<ul>
<li>
-<p><code>pkg install jq</code> as root installs a pre-built <a href="https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/pkgng-intro.html">binary package</a>.</p>
+<p><code>pkg install jq</code> as root installs a pre-built
+ <a href="https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/pkgng-intro.html">binary package</a>.</p>
</li>
-
<li>
-<p><code>make -C /usr/ports/textproc/jq install clean</code> as root installs the <a href="https://www.freshports.org/textproc/jq/">jq</a> <a href="https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html">port</a> from source.</p>
+<p><code>make -C /usr/ports/textproc/jq install clean</code> as root installs the
+ <a href="https://www.freshports.org/textproc/jq/">jq</a>
+ <a href="https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html">port</a>
+ from source.</p>
</li>
</ul>
-
-<h3 id="solaris">Solaris</h3>
-
+<h3>Solaris</h3>
<ul>
<li>
-<p><code>pkgutil -i jq</code> in <a href="https://www.opencsw.org/p/jq">OpenCSW</a> for Solaris 10+, Sparc and x86.</p>
+<p><code>pkgutil -i jq</code> in <a href="https://www.opencsw.org/p/jq">OpenCSW</a> for Solaris
+ 10+, Sparc and x86.</p>
</li>
-
<li>
-<p>jq 1.4 binaries for Solaris 11 <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-solaris11-64">64-bit</a> or <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-solaris11-32">32-bit</a>.</p>
+<p>jq 1.4 binaries for Solaris 11
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-solaris11-64">64-bit</a>
+ or
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-solaris11-32">32-bit</a>.</p>
</li>
</ul>
-
-<h3 id="windows">Windows</h3>
-
+<h3>Windows</h3>
<ul>
<li>
-<p>Use <a href="https://chocolatey.org/">Chocolatey NuGet</a> to install jq 1.5 with <code>chocolatey install jq</code>.</p>
+<p>Use <a href="https://chocolatey.org/">Chocolatey NuGet</a> to install jq 1.5 with
+ <code>chocolatey install jq</code>.</p>
</li>
-
<li>
-<p>jq 1.6 executables for <a href="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win64.exe">64-bit</a> or <a href="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win32.exe">32-bit</a>.</p>
+<p>jq 1.6 executables for
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win64.exe">64-bit</a>
+ or
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win32.exe">32-bit</a>.</p>
</li>
-
<li>
-<p>jq 1.5 executables for <a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-win64.exe">64-bit</a> or <a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-win32.exe">32-bit</a>.</p>
+<p>jq 1.5 executables for
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-win64.exe">64-bit</a>
+ or
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-win32.exe">32-bit</a>.</p>
</li>
-
<li>
-<p>jq 1.4 executables for <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-win64.exe">64-bit</a> or <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-win32.exe">32-bit</a>.</p>
+<p>jq 1.4 executables for
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-win64.exe">64-bit</a>
+ or
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.4/jq-win32.exe">32-bit</a>.</p>
</li>
-
<li>
-<p>jq 1.3 executables for <a href="https://github.com/stedolan/jq/releases/download/jq-1.3/jq-win64.exe">64-bit</a> or <a href="https://github.com/stedolan/jq/releases/download/jq-1.3/jq-win32.exe">32-bit</a>.</p>
+<p>jq 1.3 executables for
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.3/jq-win64.exe">64-bit</a>
+ or
+ <a href="https://github.com/stedolan/jq/releases/download/jq-1.3/jq-win32.exe">32-bit</a>.</p>
</li>
</ul>
-
-<h3 id="checksums_and_signatures">Checksums and signatures</h3>
-
-<p>SHA-256 checksums are provided for all release and pre-release binaries. They can be found under <a href="https://github.com/stedolan/jq/tree/master/sig">sig/v1.x/sha256sum.txt</a>. The checksums for jq 1.6 are in <a href="https://raw.githubusercontent.com/stedolan/jq/master/sig/v1.6/sha256sum.txt">sig/v1.6/sha256sum.txt</a>. The checksums for jq 1.5 are in <a href="https://raw.githubusercontent.com/stedolan/jq/master/sig/v1.5/sha256sum.txt">sig/v1.5/sha256sum.txt</a>.</p>
-
-<p>Additionally, all binaries are signed by the <a href="https://raw.githubusercontent.com/stedolan/jq/master/sig/jq-release.key">jq Package Signing Key</a>. The signatures can be found under <a href="https://github.com/stedolan/jq/tree/master/sig">sig/v1.x/*.asc</a>. The signatures for jq 1.6 are in <a href="https://github.com/stedolan/jq/tree/master/sig/v1.6">sig/v1.5/*.asc</a>. The signatures for jq 1.5 are in <a href="https://github.com/stedolan/jq/tree/master/sig/v1.5">sig/v1.5/*.asc</a>. You can use <a href="https://gnupg.org/">GnuPG</a> to verify a signature by downloading the signature and running <code>gpg --verify signature.asc</code>.</p>
-
-<h3 id="from_source_on_linux_os_x_cygwin_and_other_posixlike_operating_systems">From source on Linux, OS X, Cygwin, and other POSIX-like operating systems</h3>
-
+<h3>Checksums and signatures</h3>
+<p>SHA-256 checksums are provided for all release and pre-release binaries.
+They can be found under
+<a href="https://github.com/stedolan/jq/tree/master/sig">sig/v1.x/sha256sum.txt</a>.
+The checksums for jq 1.6 are in
+<a href="https://raw.githubusercontent.com/stedolan/jq/master/sig/v1.6/sha256sum.txt">sig/v1.6/sha256sum.txt</a>.
+The checksums for jq 1.5 are in
+<a href="https://raw.githubusercontent.com/stedolan/jq/master/sig/v1.5/sha256sum.txt">sig/v1.5/sha256sum.txt</a>.</p>
+<p>Additionally, all binaries are signed by the
+<a href="https://raw.githubusercontent.com/stedolan/jq/master/sig/jq-release.key">jq Package Signing Key</a>.
+The signatures can be found under
+<a href="https://github.com/stedolan/jq/tree/master/sig">sig/v1.x/*.asc</a>.
+The signatures for jq 1.6 are in
+<a href="https://github.com/stedolan/jq/tree/master/sig/v1.6">sig/v1.5/*.asc</a>.
+The signatures for jq 1.5 are in
+<a href="https://github.com/stedolan/jq/tree/master/sig/v1.5">sig/v1.5/*.asc</a>.
+You can use <a href="https://gnupg.org/">GnuPG</a> to verify a signature by downloading
+the signature and running <code>gpg --verify signature.asc</code>.</p>
+<h3>From source on Linux, OS X, Cygwin, and other POSIX-like operating systems</h3>
<ul>
<li><a href="https://github.com/stedolan/jq/releases/download/jq-1.6/jq-1.6.tar.gz">Source tarball for jq 1.6</a></li>
-
<li><a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz">Source tarball for jq 1.5</a></li>
</ul>
-
<p>You can build it using the usual <code>./configure &amp;&amp; make &amp;&amp; sudo
make install</code> rigmarole.</p>
-
-<p>If you’re interested in using the lastest development version, try:</p>
-
+<p>If you're interested in using the lastest development version, try:</p>
<pre><code>git clone https://github.com/stedolan/jq.git
cd jq
autoreconf -i
./configure --disable-maintainer-mode
make
-sudo make install</code></pre>
-
-<p>To build it from a git clone, you’ll need to install a few packages first:</p>
-
+sudo make install
+</code></pre>
+<p>To build it from a git clone, you'll need to install a few
+packages first:</p>
<ul>
<li><a href="https://gcc.gnu.org">GCC</a></li>
-
<li><a href="https://www.gnu.org/software/make/">Make</a></li>
-
<li><a href="https://www.gnu.org/software/automake/">Autotools</a></li>
</ul>
-
-<p>For Linux systems, these will all be in your system’s package manager, and if you do development on the machine they’re most likely already installed.</p>
-
-<p>On OS X, these are all included in Apple’s command line tools, which can be installed from <a href="https://developer.apple.com/xcode/">Xcode</a>. However, you may find that you need a newer version of Bison than the one provided by Apple. This can be found in <a href="http://brew.sh">Homebrew</a> or <a href="https://macports.org/">MacPorts</a>.</p>
-
-<p>The <code>--disable-maintainer-mode</code> flag says to use the pre-generated lexer and parser that come with the code. To compile the lexer and parser also from source, leave out this flag. You will need to install <a href="http://flex.sourceforge.net/">Flex</a> and <a href="https://www.gnu.org/software/bison/">Bison</a>.</p>
-
-<h4 id="building_the_documentation">Building the documentation</h4>
-
-<p>jq’s documentation is compiled into static HTML using <a href="http://www.tinytree.info">Bonsai</a>. To view the documentation locally, run <code>rake serve</code> (or <code>bundle exec rake serve</code>) from the docs/ subdirectory. To build the docs just <code>rake build</code> from the docs subdirectory. You’ll need a few Ruby dependencies, which can be installed by following the instructions in <code>docs/README.md</code>.</p>
-
-<p>The man page is built by <code>make jq.1</code>, or just <code>make</code>, also from the YAML docs, and you’ll still need the Ruby dependencies to build the manpage.</p>
-
+<p>For Linux systems, these will all be in your system's package
+manager, and if you do development on the machine they're most
+likely already installed.</p>
+<p>On OS X, these are all included in Apple's command line tools, which can
+be installed from <a href="https://developer.apple.com/xcode/">Xcode</a>. However,
+you may find that you need a newer version of Bison than the one provided
+by Apple. This can be found in <a href="http://brew.sh">Homebrew</a> or
+<a href="https://macports.org/">MacPorts</a>.</p>
+<p>The <code>--disable-maintainer-mode</code> flag says to use the pre-generated lexer
+and parser that come with the code. To compile the lexer and parser also
+from source, leave out this flag. You will need to install
+<a href="http://flex.sourceforge.net/">Flex</a> and
+<a href="https://www.gnu.org/software/bison/">Bison</a>.</p>
+<h4>Building the documentation</h4>
+<p>jq's documentation is compiled into static HTML using Python.
+To build the docs, run <code>pipenv run python3 build_website.py</code> from
+the docs/ subdirectory. To serve them locally, you can run
+<code>python3 -m SimpleHTTPServer</code>. You'll need a few Python dependencies,
+which can be installed by following the instructions in <code>docs/README.md</code>.</p>
+<p>The man page is built by <code>make jq.1</code>, or just <code>make</code>, also from
+the YAML docs, and you'll still need the Python dependencies to
+build the manpage.</p>
@@ -234,7 +275,7 @@ sudo make install</code></pre>
<footer>
<div class="container">
- <p>This website is made with <a href="http://www.tinytree.info">Bonsai</a> and <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
+ <p>This website is made with <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
<p>jq is licensed under the MIT license (code) and the <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a> license (docs).</p>
</div>
</footer>
@@ -242,6 +283,5 @@ sudo make install</code></pre>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<script src="https://twitter.github.io/typeahead.js/releases/0.11.1/typeahead.bundle.js"></script>
-
</body>
-</html>
+</html> \ No newline at end of file
diff --git a/index.html b/index.html
index ff7646e..6cd76ec 100644
--- a/index.html
+++ b/index.html
@@ -18,7 +18,6 @@
<![endif]-->
</head>
-
<body id="index">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
@@ -56,7 +55,6 @@
</div>
</div>
-
<div class="container">
<div class="row">
<div class="jumbotron">
@@ -104,15 +102,16 @@ dependencies. You can download a single binary, <code>scp</code> it to a far awa
machine of the same type, and expect it to work.</p></div>
<div class="col-sm-4"><p>jq can mangle the data format that you have into the one that you
want with very little effort, and the program to do so is often
-shorter and simpler than you&rsquo;d expect.</p></div>
+shorter and simpler than you'd expect.</p></div>
</div>
<div class="row" style="text-align:center; margin-top: 30px">
- <p>Go read the <a href='/jq/tutorial/'>tutorial</a> for more, or the <a href='/jq/manual/'>manual</a>
-for <em>way</em> more.</p><p>Ask questions on <a href='https://stackoverflow.com/'>stackoverflow</a> using the <a href='https://stackoverflow.com/questions/tagged/jq'>jq
+ <p>Go read the <a href="/jq/tutorial/">tutorial</a> for more, or the <a href="/jq/manual/">manual</a>
+for <em>way</em> more.</p>
+<p>Ask questions on <a href="https://stackoverflow.com/">stackoverflow</a> using the <a href="https://stackoverflow.com/questions/tagged/jq">jq
tag</a>, or on the
-<a href='http://irc.lc/freenode/%23jq/'>#jq</a> channel on
-<a href='https://webchat.freenode.net/'>Freenode</a>.</p>
+<a href="http://irc.lc/freenode/%23jq/">#jq</a> channel on
+<a href="https://webchat.freenode.net/">Freenode</a>.</p>
</div>
<div class="row">
@@ -122,44 +121,41 @@ tag</a>, or on the
<li>
<span class="date">1 November 2018</span>
-
-<p>jq 1.6 released. See installation options on the <a href="/jq/download/">download</a> page, and the <a href="https://github.com/stedolan/jq/releases/tag/jq-1.6">release notes</a> for details.</p>
-
+ <p>jq 1.6 released. See installation options on the <a href="/jq/download/">download</a>
+page, and the <a href="https://github.com/stedolan/jq/releases/tag/jq-1.6">release notes</a>
+for details.</p>
</li>
<li>
<span class="date">15 August 2015</span>
-
-<p>jq 1.5 released, including new datetime, math, and regexp functions, try/catch syntax, array and object destructuring, a streaming parser, and a module system. See installation options on the <a href="/jq/download/">download</a> page, and the <a href="https://github.com/stedolan/jq/releases/tag/jq-1.5">release notes</a> for details.</p>
-
+ <p>jq 1.5 released, including new datetime, math, and regexp functions,
+try/catch syntax, array and object destructuring, a streaming parser,
+and a module system. See installation options on the
+<a href="/jq/download/">download</a> page, and the
+<a href="https://github.com/stedolan/jq/releases/tag/jq-1.5">release notes</a>
+for details.</p>
</li>
<li>
<span class="date">26 July 2015</span>
-
-<p>jq 1.5rc2 is available. Get it on the <a href="https://github.com/stedolan/jq/releases">releases</a> page.</p>
-
+ <p>jq 1.5rc2 is available. Get it on the
+<a href="https://github.com/stedolan/jq/releases">releases</a> page.</p>
</li>
<li>
<span class="date">01 January 2015</span>
-
-<p>jq 1.5rc1 is available. Get it on the <a href="https://github.com/stedolan/jq/releases">releases</a> page.</p>
-
+ <p>jq 1.5rc1 is available. Get it on the
+<a href="https://github.com/stedolan/jq/releases">releases</a> page.</p>
</li>
<li>
<span class="date">09 June 2014</span>
-
-<p>jq 1.4 (finally) released! Get it on the <a href="/jq/download/">download</a> page.</p>
-
+ <p>jq 1.4 (finally) released! Get it on the <a href="/jq/download/">download</a> page.</p>
</li>
<li>
<span class="date">19 May 2013</span>
-
-<p>jq 1.3 released.</p>
-
+ <p>jq 1.3 released.</p>
</li>
</ul>
@@ -169,7 +165,7 @@ tag</a>, or on the
<footer>
<div class="container">
- <p>This website is made with <a href="http://www.tinytree.info">Bonsai</a> and <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
+ <p>This website is made with <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
<p>jq is licensed under the MIT license (code) and the <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a> license (docs).</p>
</div>
</footer>
@@ -177,6 +173,5 @@ tag</a>, or on the
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<script src="https://twitter.github.io/typeahead.js/releases/0.11.1/typeahead.bundle.js"></script>
-
</body>
-</html>
+</html> \ No newline at end of file
diff --git a/js/manual-search.js b/js/manual-search.js
index 8cd2ffa..e5d6ee5 100644
--- a/js/manual-search.js
+++ b/js/manual-search.js
@@ -1 +1,52 @@
-var section_names=function(q){if(!q){return[]}var matches=[];q=q.toLowerCase();$.each(section_map,function(k,v){if(k.toLowerCase().indexOf(q)!=-1){matches.push(k)}});matches.sort(function(a,b){return a.length-b.length});return matches};var section_names_cb=function(q,cb){cb(section_names(q))};var go_to_section=function(){query=$("#searchbox").val();results=section_names(query);if(results.length==0){return}result=results[0];location.hash="#"+section_map[result];if(result!=query){$("#searchbox").val(result)}};$(function(){$("#searchbox").typeahead({hint:false,highlight:true,minLength:1},{name:"contents",source:section_names_cb,limit:6}).on("typeahead:selected",function(e,data){go_to_section()});$("#searchbox").change(go_to_section)});$(function(){$.each($(".manual-example table"),function(index,value){$value=$(value);var j=$value.find("tr:nth-child(2) td:first").text();var q=$value.find(".jqprogram").text().replace(/^jq /,"").replace(/^'(.+)'$/,"$1");var url="https://jqplay.org/jq?q="+encodeURIComponent(q)+"&j="+encodeURIComponent(j);var $last_tr=$value.find("tr:last");$last_tr.after('<tr class="jqplay-btn"><th><a href="'+url+'" class="btn btn-primary btn-sm">Run</a></th><th></th></tr><tr><th></th><th></th></tr>')})}); \ No newline at end of file
+var section_names = function(q) {
+ if (!q) {
+ return [];
+ }
+ var matches = [];
+ q = q.toLowerCase();
+ $.each(section_map, function(k, v) {
+ if (k.toLowerCase().indexOf(q) != -1) {
+ matches.push(k);
+ }
+ });
+ matches.sort(function(a, b) {
+ // shortest to longest
+ return a.length - b.length;
+ });
+ return matches;
+}
+var section_names_cb = function(q, cb) {
+ cb(section_names(q));
+}
+var go_to_section = function() {
+ query = $('#searchbox').val();
+ results = section_names(query);
+ if (results.length == 0) {
+ return;
+ }
+ result = results[0];
+ location.hash = '#' + section_map[result];
+ if (result != query) {
+ $('#searchbox').val(result);
+ }
+}
+$(function(){
+ $('#searchbox').typeahead(
+ {hint: false, highlight: true, minLength: 1},
+ {name: "contents", source: section_names_cb, limit: 6}
+ ).on('typeahead:selected', function(e, data) {
+ go_to_section();
+ });
+ $('#searchbox').change(go_to_section);
+});
+// add "Run" button to execute examples on jqplay.org
+$(function() {
+ $.each($('.manual-example table'), function(index, value) {
+ $value = $(value)
+ var j = $value.find('tr:nth-child(2) td:first').text();
+ var q = $value.find('.jqprogram').text().replace(/^jq /, '').replace(/(\r\n|\n|\r)/gm," ").replace(/^'(.+)'$/, '$1');
+ var url = 'https://jqplay.org/jq?q=' + encodeURIComponent(q) +'&j=' + encodeURIComponent(j)
+ var $last_tr = $value.find('tr:last');
+ $last_tr.after('<tr class="jqplay-btn"><th><a href="' + url + '" class="btn btn-primary btn-sm">Run</a></th><th></th></tr><tr><th></th><th></th></tr>');
+ });
+});
diff --git a/manual/index.html b/manual/index.html
index f1abd39..0986130 100644
--- a/manual/index.html
+++ b/manual/index.html
@@ -18,7 +18,6 @@
<![endif]-->
</head>
-
<body id="manual" data-spy="scroll" data-target="#navcolumn" data-offset="100">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
@@ -56,7 +55,6 @@
</div>
</div>
-
<div class="container">
<div class="row">
<div class="affix" id="navcolumn">
@@ -127,208 +125,239 @@
<div id="manualcontent">
<h1>jq Manual (development version)</h1>
- <p><em>For released versions, see <a href='/jq/manual/v1.6'>jq 1.6</a>,
-<a href='/jq/manual/v1.5'>jq 1.5</a>, <a href='/jq/manual/v1.4'>jq 1.4</a>
-or <a href='/jq/manual/v1.3'>jq 1.3</a>.</em></p>
- <p>A jq program is a &ldquo;filter&rdquo;: it takes an input, and produces an
+ <p><em>For released versions, see <a href="/jq/manual/v1.6">jq 1.6</a>,
+<a href="/jq/manual/v1.5">jq 1.5</a>, <a href="/jq/manual/v1.4">jq 1.4</a>
+or <a href="/jq/manual/v1.3">jq 1.3</a>.</em></p>
+ <p>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.</p><p>Filters can be combined in various ways - you can pipe the output of
+or various other standard tasks.</p>
+<p>Filters can be combined in various ways - you can pipe the output of
one filter into another filter, or collect the output of a filter
-into an array.</p><p>Some filters produce multiple results, for instance there&rsquo;s one that
+into an array.</p>
+<p>Some filters produce multiple results, for instance there's one that
produces all the elements of its input array. Piping that filter
into a second runs the second filter for each element of the
array. Generally, things that would be done with loops and iteration
-in other languages are just done by gluing filters together in jq.</p><p>It&rsquo;s important to remember that every filter has an input and an
-output. Even literals like &ldquo;hello&rdquo; or 42 are filters - they take an
+in other languages are just done by gluing filters together in jq.</p>
+<p>It's important to remember that every filter has an input and an
+output. Even literals like "hello" or 42 are filters - they take an
input but always produce the same literal as output. Operations that
combine two filters, like addition, generally feed the same input to
both and combine the results. So, you can implement an averaging
filter as <code>add / length</code> - feeding the input array both to the <code>add</code>
-filter and the <code>length</code> filter and then performing the division.</p><p>But that&rsquo;s getting ahead of ourselves. :) Let&rsquo;s start with something
+filter and the <code>length</code> filter and then performing the division.</p>
+<p>But that's getting ahead of ourselves. :) Let's start with something
simpler:</p>
<section id="Invokingjq">
<h2>Invoking jq</h2>
-
-<p>jq filters run on a stream of JSON data. The input to jq is parsed as a sequence of whitespace-separated JSON values which are passed through the provided filter one at a time. The output(s) of the filter are written to standard out, again as a sequence of whitespace-separated JSON data.</p>
-
-<p>Note: it is important to mind the shell’s quoting rules. As a general rule it’s best to always quote (with single-quote characters) the jq program, as too many characters with special meaning to jq are also shell meta-characters. For example, <code>jq
-&quot;foo&quot;</code> will fail on most Unix shells because that will be the same as <code>jq foo</code>, which will generally fail because <code>foo is not
-defined</code>. When using the Windows command shell (cmd.exe) it’s best to use double quotes around your jq program when given on the command-line (instead of the <code>-f program-file</code> option), but then double-quotes in the jq program need backslash escaping.</p>
-
-<p>You can affect how jq reads and writes its input and output using some command-line options:</p>
-
+ <p>jq filters run on a stream of JSON data. The input to jq is
+parsed as a sequence of whitespace-separated JSON values which
+are passed through the provided filter one at a time. The
+output(s) of the filter are written to standard out, again as a
+sequence of whitespace-separated JSON data.</p>
+<p>Note: it is important to mind the shell's quoting rules. As a
+general rule it's best to always quote (with single-quote
+characters) the jq program, as too many characters with special
+meaning to jq are also shell meta-characters. For example, <code>jq
+"foo"</code> will fail on most Unix shells because that will be the same
+as <code>jq foo</code>, which will generally fail because <code>foo is not
+defined</code>. When using the Windows command shell (cmd.exe) it's
+best to use double quotes around your jq program when given on the
+command-line (instead of the <code>-f program-file</code> option), but then
+double-quotes in the jq program need backslash escaping.</p>
+<p>You can affect how jq reads and writes its input and output
+using some command-line options:</p>
<ul>
-<li>
-<p><code>--version</code>:</p>
-
+<li><code>--version</code>:</li>
+</ul>
<p>Output the jq version and exit with zero.</p>
-</li>
-
-<li>
-<p><code>--seq</code>:</p>
-
-<p>Use the <code>application/json-seq</code> 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 <code>--seq</code> option.</p>
-</li>
-
-<li>
-<p><code>--stream</code>:</p>
-
-<p>Parse the input in streaming fashion, outputing arrays of path and leaf values (scalars and empty arrays or empty objects). For example, <code>&quot;a&quot;</code> becomes <code>[[],&quot;a&quot;]</code>, and <code>[[],&quot;a&quot;,[&quot;b&quot;]]</code> becomes <code>[[0],[]]</code>, <code>[[1],&quot;a&quot;]</code>, and <code>[[1,0],&quot;b&quot;]</code>.</p>
-
-<p>This is useful for processing very large inputs. Use this in conjunction with filtering and the <code>reduce</code> and <code>foreach</code> syntax to reduce large inputs incrementally.</p>
-</li>
-
-<li>
-<p><code>--slurp</code>/<code>-s</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--raw-input</code>/<code>-R</code>:</p>
-
-<p>Don’t parse the input as JSON. Instead, each line of text is passed to the filter as a string. If combined with <code>--slurp</code>, then the entire input is passed to the filter as a single long string.</p>
-</li>
-
-<li>
-<p><code>--null-input</code>/<code>-n</code>:</p>
-
-<p>Don’t read any input at all! Instead, the filter is run once using <code>null</code> as the input. This is useful when using jq as a simple calculator or to construct JSON data from scratch.</p>
-</li>
-
-<li>
-<p><code>--compact-output</code> / <code>-c</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--tab</code>:</p>
-
+<ul>
+<li><code>--seq</code>:</li>
+</ul>
+<p>Use the <code>application/json-seq</code> 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 <code>--seq</code>
+ option.</p>
+<ul>
+<li><code>--stream</code>:</li>
+</ul>
+<p>Parse the input in streaming fashion, outputting arrays of path
+ and leaf values (scalars and empty arrays or empty objects).
+ For example, <code>"a"</code> becomes <code>[[],"a"]</code>, and <code>[[],"a",["b"]]</code>
+ becomes <code>[[0],[]]</code>, <code>[[1],"a"]</code>, and <code>[[1,0],"b"]</code>.</p>
+<p>This is useful for processing very large inputs. Use this in
+ conjunction with filtering and the <code>reduce</code> and <code>foreach</code> syntax
+ to reduce large inputs incrementally.</p>
+<ul>
+<li><code>--slurp</code>/<code>-s</code>:</li>
+</ul>
+<p>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.</p>
+<ul>
+<li><code>--raw-input</code>/<code>-R</code>:</li>
+</ul>
+<p>Don't parse the input as JSON. Instead, each line of text is
+ passed to the filter as a string. If combined with <code>--slurp</code>,
+ then the entire input is passed to the filter as a single long
+ string.</p>
+<ul>
+<li><code>--null-input</code>/<code>-n</code>:</li>
+</ul>
+<p>Don't read any input at all! Instead, the filter is run once
+ using <code>null</code> as the input. This is useful when using jq as a
+ simple calculator or to construct JSON data from scratch.</p>
+<ul>
+<li><code>--compact-output</code> / <code>-c</code>:</li>
+</ul>
+<p>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.</p>
+<ul>
+<li><code>--tab</code>:</li>
+</ul>
<p>Use a tab for each indentation level instead of two spaces.</p>
-</li>
-
-<li>
-<p><code>--indent n</code>:</p>
-
-<p>Use the given number of spaces (no more than 8) for indentation.</p>
-</li>
-
-<li>
-<p><code>--color-output</code> / <code>-C</code> and <code>--monochrome-output</code> / <code>-M</code>:</p>
-
-<p>By default, jq outputs colored JSON if writing to a terminal. You can force it to produce color even if writing to a pipe or a file using <code>-C</code>, and disable color with <code>-M</code>.</p>
-
-<p>Colors can be configured with the <code>JQ_COLORS</code> environment variable (see below).</p>
-</li>
-
-<li>
-<p><code>--ascii-output</code> / <code>-a</code>:</p>
-
-<p>jq usually outputs non-ASCII Unicode codepoints as UTF-8, even if the input specified them as escape sequences (like “\u03bc”). Using this option, you can force jq to produce pure ASCII output with every non-ASCII character replaced with the equivalent escape sequence.</p>
-</li>
-
-<li>
-<p><code>--unbuffered</code></p>
-
-<p>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).</p>
-</li>
-
-<li>
-<p><code>--sort-keys</code> / <code>-S</code>:</p>
-
+<ul>
+<li><code>--indent n</code>:</li>
+</ul>
+<p>Use the given number of spaces (no more than 7) for indentation.</p>
+<ul>
+<li><code>--color-output</code> / <code>-C</code> and <code>--monochrome-output</code> / <code>-M</code>:</li>
+</ul>
+<p>By default, jq outputs colored JSON if writing to a
+ terminal. You can force it to produce color even if writing to
+ a pipe or a file using <code>-C</code>, and disable color with <code>-M</code>.</p>
+<p>Colors can be configured with the <code>JQ_COLORS</code> environment
+ variable (see below).</p>
+<ul>
+<li><code>--binary</code> / <code>-b</code>:</li>
+</ul>
+<p>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).</p>
+<ul>
+<li><code>--ascii-output</code> / <code>-a</code>:</li>
+</ul>
+<p>jq usually outputs non-ASCII Unicode codepoints as UTF-8, even
+ if the input specified them as escape sequences (like
+ "\u03bc"). Using this option, you can force jq to produce pure
+ ASCII output with every non-ASCII character replaced with the
+ equivalent escape sequence.</p>
+<ul>
+<li><code>--unbuffered</code>:</li>
+</ul>
+<p>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).</p>
+<ul>
+<li><code>--sort-keys</code> / <code>-S</code>:</li>
+</ul>
<p>Output the fields of each object with the keys in sorted order.</p>
-</li>
-
-<li>
-<p><code>--raw-output</code> / <code>-r</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--join-output</code> / <code>-j</code>:</p>
-
-<p>Like <code>-r</code> but jq won’t print a newline after each output.</p>
-</li>
-
-<li>
-<p><code>-f filename</code> / <code>--from-file filename</code>:</p>
-
-<p>Read filter from the file rather than from a command line, like awk’s -f option. You can also use ‘#’ to make comments.</p>
-</li>
-
-<li>
-<p><code>-Ldirectory</code> / <code>-L directory</code>:</p>
-
-<p>Prepend <code>directory</code> to the search list for modules. If this option is used then no builtin search list is used. See the section on modules below.</p>
-</li>
-
-<li>
-<p><code>-e</code> / <code>--exit-status</code>:</p>
-
-<p>Sets the exit status of jq to 0 if the last output values was neither <code>false</code> nor <code>null</code>, 1 if the last output value was either <code>false</code> or <code>null</code>, or 4 if no valid result was ever produced. Normally jq exits with 2 if there was any usage problem or system error, 3 if there was a jq program compile error, or 0 if the jq program ran.</p>
-
-<p>Another way to set the exit status is with the <code>halt_error</code> builtin function.</p>
-</li>
-
-<li>
-<p><code>--arg name value</code>:</p>
-
-<p>This option passes a value to the jq program as a predefined variable. If you run jq with <code>--arg foo bar</code>, then <code>$foo</code> is available in the program and has the value <code>&quot;bar&quot;</code>. Note that <code>value</code> will be treated as a string, so <code>--arg foo 123</code> will bind <code>$foo</code> to <code>&quot;123&quot;</code>.</p>
-
-<p>Named arguments are also available to the jq program as <code>$ARGS.named</code>.</p>
-</li>
-
-<li>
-<p><code>--argjson name JSON-text</code>:</p>
-
-<p>This option passes a JSON-encoded value to the jq program as a predefined variable. If you run jq with <code>--argjson foo 123</code>, then <code>$foo</code> is available in the program and has the value <code>123</code>.</p>
-</li>
-
-<li>
-<p><code>--slurpfile variable-name filename</code>:</p>
-
-<p>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 <code>--slurpfile foo bar</code>, then <code>$foo</code> is available in the program and has an array whose elements correspond to the texts in the file named <code>bar</code>.</p>
-</li>
-
-<li>
-<p><code>--rawfile variable-name filename</code>:</p>
-
-<p>This option reads in the named file and binds its contents to the given global variable. If you run jq with <code>--rawfile foo bar</code>, then <code>$foo</code> is available in the program and has a string whose contents are to the texs in the file named <code>bar</code>.</p>
-</li>
-
-<li>
-<p><code>--argfile variable-name filename</code>:</p>
-
-<p>Do not use. Use <code>--slurpfile</code> instead.</p>
-
-<p>(This option is like <code>--slurpfile</code>, but when the file has just one text, then that is used, else an array of texts is used as in <code>--slurpfile</code>.)</p>
-</li>
-
-<li>
-<p><code>--args</code>:</p>
-
-<p>Remaining arguments are positional string arguments. These are available to the jq program as <code>$ARGS.positional[]</code>.</p>
-</li>
-
-<li>
-<p><code>--jsonargs</code>:</p>
-
-<p>Remaining arguments are positional JSON text arguments. These are available to the jq program as <code>$ARGS.positional[]</code>.</p>
-</li>
-
-<li>
-<p><code>--run-tests [filename]</code>:</p>
-
-<p>Runs the tests in the given file or standard input. This must be the last option given and does not honor all preceding options. The input consists of comment lines, empty lines, and program lines followed by one input line, as many lines of output as are expected (one per output), and a terminating empty line. Compilation failure tests start with a line containing only “%%FAIL”, then a line containing the program to compile, then a line containing an error message to compare to the actual.</p>
-
-<p>Be warned that this option can change backwards-incompatibly.</p>
-</li>
+<ul>
+<li><code>--raw-output</code> / <code>-r</code>:</li>
</ul>
-
+<p>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.</p>
+<ul>
+<li><code>--join-output</code> / <code>-j</code>:</li>
+</ul>
+<p>Like <code>-r</code> but jq won't print a newline after each output.</p>
+<ul>
+<li><code>--nul-output</code> / <code>-0</code>:</li>
+</ul>
+<p>Like <code>-r</code> but jq will print NUL instead of newline after each output.
+ This can be useful when the values being output can contain newlines.</p>
+<ul>
+<li><code>-f filename</code> / <code>--from-file filename</code>:</li>
+</ul>
+<p>Read filter from the file rather than from a command line, like
+ awk's -f option. You can also use '#' to make comments.</p>
+<ul>
+<li><code>-Ldirectory</code> / <code>-L directory</code>:</li>
+</ul>
+<p>Prepend <code>directory</code> to the search list for modules. If this
+ option is used then no builtin search list is used. See the
+ section on modules below.</p>
+<ul>
+<li><code>-e</code> / <code>--exit-status</code>:</li>
+</ul>
+<p>Sets the exit status of jq to 0 if the last output values was
+ neither <code>false</code> nor <code>null</code>, 1 if the last output value was
+ either <code>false</code> or <code>null</code>, or 4 if no valid result was ever
+ produced. Normally jq exits with 2 if there was any usage
+ problem or system error, 3 if there was a jq program compile
+ error, or 0 if the jq program ran.</p>
+<p>Another way to set the exit status is with the <code>halt_error</code>
+ builtin function.</p>
+<ul>
+<li><code>--arg name value</code>:</li>
+</ul>
+<p>This option passes a value to the jq program as a predefined
+ variable. If you run jq with <code>--arg foo bar</code>, then <code>$foo</code> is
+ available in the program and has the value <code>"bar"</code>. Note that
+ <code>value</code> will be treated as a string, so <code>--arg foo 123</code> will
+ bind <code>$foo</code> to <code>"123"</code>.</p>
+<p>Named arguments are also available to the jq program as
+ <code>$ARGS.named</code>.</p>
+<ul>
+<li><code>--argjson name JSON-text</code>:</li>
+</ul>
+<p>This option passes a JSON-encoded value to the jq program as a
+ predefined variable. If you run jq with <code>--argjson foo 123</code>, then
+ <code>$foo</code> is available in the program and has the value <code>123</code>.</p>
+<ul>
+<li><code>--slurpfile variable-name filename</code>:</li>
+</ul>
+<p>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 <code>--slurpfile foo bar</code>, then <code>$foo</code> is available
+ in the program and has an array whose elements correspond to the
+ texts in the file named <code>bar</code>.</p>
+<ul>
+<li><code>--rawfile variable-name filename</code>:</li>
+</ul>
+<p>This option reads in the named file and binds its contents to the given
+ global variable. If you run jq with <code>--rawfile foo bar</code>, then <code>$foo</code> is
+ available in the program and has a string whose contents are to the texs
+ in the file named <code>bar</code>.</p>
+<ul>
+<li><code>--argfile variable-name filename</code>:</li>
+</ul>
+<p>Do not use. Use <code>--slurpfile</code> instead.</p>
+<p>(This option is like <code>--slurpfile</code>, but when the file has just
+ one text, then that is used, else an array of texts is used as
+ in <code>--slurpfile</code>.)</p>
+<ul>
+<li><code>--args</code>:</li>
+</ul>
+<p>Remaining arguments are positional string arguments. These are
+ available to the jq program as <code>$ARGS.positional[]</code>.</p>
+<ul>
+<li><code>--jsonargs</code>:</li>
+</ul>
+<p>Remaining arguments are positional JSON text arguments. These
+ are available to the jq program as <code>$ARGS.positional[]</code>.</p>
+<ul>
+<li><code>--run-tests [filename]</code>:</li>
+</ul>
+<p>Runs the tests in the given file or standard input. This must
+ be the last option given and does not honor all preceding
+ options. The input consists of comment lines, empty lines, and
+ program lines followed by one input line, as many lines of
+ output as are expected (one per output), and a terminating empty
+ line. Compilation failure tests start with a line containing
+ only "%%FAIL", then a line containing the program to compile,
+ then a line containing an error message to compare to the
+ actual.</p>
+<p>Be warned that this option can change backwards-incompatibly.</p>
</section>
@@ -338,16 +367,15 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id="Identity:.">
<h3>
-
-Identity: <code>.</code>
-
+ Identity: <code>.</code>
</h3>
-
-<p>The absolute simplest filter is <code>.</code> . This is a filter that takes its input and produces it unchanged as output. That is, this is the identity operator.</p>
-
-<p>Since jq by default pretty-prints all output, this trivial program can be a useful way of formatting JSON output from, say, <code>curl</code>.</p>
-
+ <p>The absolute simplest filter is <code>.</code> . This is a filter that
+takes its input and produces it unchanged as output. That is,
+this is the identity operator.</p>
+<p>Since jq by default pretty-prints all output, this trivial
+program can be a useful way of formatting JSON output from,
+say, <code>curl</code>.</p>
<div>
@@ -360,14 +388,14 @@ Identity: <code>.</code>
<table>
<tr><th></th><td class="jqprogram">jq '.'</td></tr>
- <tr><th>Input</th><td>&quot;Hello, world!&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;Hello, world!&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;Hello, world!&quot;</td>
+ <td>&#34;Hello, world!&#34;</td>
</tr>
</table>
@@ -379,22 +407,21 @@ Identity: <code>.</code>
<section id="ObjectIdentifier-Index:.foo,.foo.bar">
<h3>
-
-Object Identifier-Index: <code>.foo</code>, <code>.foo.bar</code>
-
+ Object Identifier-Index: <code>.foo</code>, <code>.foo.bar</code>
</h3>
-
-<p>The simplest <em>useful</em> filter is <code>.foo</code>. When given a JSON object (aka dictionary or hash) as input, it produces the value at the key “foo”, or null if there’s none present.</p>
-
+ <p>The simplest <em>useful</em> filter is <code>.foo</code>. When given a
+JSON object (aka dictionary or hash) as input, it produces
+the value at the key "foo", or null if there's none present.</p>
<p>A filter of the form <code>.foo.bar</code> is equivalent to <code>.foo|.bar</code>.</p>
-
-<p>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>
-
-<p>If the key contains special characters, you need to surround it with double quotes like this: <code>.&quot;foo$&quot;</code>, or else <code>.[&quot;foo$&quot;]</code>.</p>
-
-<p>For example <code>.[&quot;foo::bar&quot;]</code> and <code>.[&quot;foo.bar&quot;]</code> work while <code>.foo::bar</code> does not, and <code>.foo.bar</code> means <code>.[&quot;foo&quot;].[&quot;bar&quot;]</code>.</p>
-
+<p>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>
+<p>If the key contains special characters or starts with a digit,
+you need to surround it with double quotes like this:
+<code>."foo$"</code>, or else <code>.["foo$"]</code>.</p>
+<p>For example <code>.["foo::bar"]</code> and <code>.["foo.bar"]</code> work while
+<code>.foo::bar</code> does not, and <code>.foo.bar</code> means <code>.["foo"].["bar"]</code>.</p>
<div>
@@ -407,7 +434,7 @@ Object Identifier-Index: <code>.foo</code>, <code>.foo.bar</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;less interesting data&quot;}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;less interesting data&#34;}</td></tr>
<tr>
@@ -421,7 +448,7 @@ Object Identifier-Index: <code>.foo</code>, <code>.foo.bar</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo'</td></tr>
- <tr><th>Input</th><td>{&quot;notfoo&quot;: true, &quot;alsonotfoo&quot;: false}</td></tr>
+ <tr><th>Input</th><td>{&#34;notfoo&#34;: true, &#34;alsonotfoo&#34;: false}</td></tr>
<tr>
@@ -434,8 +461,8 @@ Object Identifier-Index: <code>.foo</code>, <code>.foo.bar</code>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[&quot;foo&quot;]'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42}</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[&#34;foo&#34;]'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42}</td></tr>
<tr>
@@ -454,14 +481,11 @@ Object Identifier-Index: <code>.foo</code>, <code>.foo.bar</code>
<section id="OptionalObjectIdentifier-Index:.foo?">
<h3>
-
-Optional Object Identifier-Index: <code>.foo?</code>
-
+ Optional Object Identifier-Index: <code>.foo?</code>
</h3>
-
-<p>Just like <code>.foo</code>, but does not output even an error when <code>.</code> is not an array or an object.</p>
-
+ <p>Just like <code>.foo</code>, but does not output even an error when <code>.</code>
+is not an array or an object.</p>
<div>
@@ -474,7 +498,7 @@ Optional Object Identifier-Index: <code>.foo?</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo?'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;less interesting data&quot;}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;less interesting data&#34;}</td></tr>
<tr>
@@ -488,7 +512,7 @@ Optional Object Identifier-Index: <code>.foo?</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo?'</td></tr>
- <tr><th>Input</th><td>{&quot;notfoo&quot;: true, &quot;alsonotfoo&quot;: false}</td></tr>
+ <tr><th>Input</th><td>{&#34;notfoo&#34;: true, &#34;alsonotfoo&#34;: false}</td></tr>
<tr>
@@ -501,8 +525,8 @@ Optional Object Identifier-Index: <code>.foo?</code>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[&quot;foo&quot;]?'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42}</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[&#34;foo&#34;]?'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42}</td></tr>
<tr>
@@ -533,32 +557,28 @@ Optional Object Identifier-Index: <code>.foo?</code>
</section>
- <section id="GenericObjectIndex:.[<string>]">
+ <section id="GenericObjectIndex:.[&lt;string&gt;]">
<h3>
-
-Generic Object Index: <code>.[&lt;string&gt;]</code>
-
+ Generic Object Index: <code>.[&lt;string&gt;]</code>
</h3>
-
-<p>You can also look up fields of an object using syntax like <code>.[&quot;foo&quot;]</code> (.foo above is a shorthand version of this, but only for identifier-like strings).</p>
-
+ <p>You can also look up fields of an object using syntax like
+<code>.["foo"]</code> (.foo above is a shorthand version of this, but
+only for identifier-like strings).</p>
</section>
<section id="ArrayIndex:.[2]">
<h3>
-
-Array Index: <code>.[2]</code>
-
+ Array Index: <code>.[2]</code>
</h3>
-
-<p>When the index value is an integer, <code>.[&lt;value&gt;]</code> can index arrays. Arrays are zero-based, so <code>.[2]</code> returns the third element.</p>
-
-<p>Negative indices are allowed, with -1 referring to the last element, -2 referring to the next to last element, and so on.</p>
-
+ <p>When the index value is an integer, <code>.[&lt;value&gt;]</code> can index
+arrays. Arrays are zero-based, so <code>.[2]</code> returns the third
+element.</p>
+<p>Negative indices are allowed, with -1 referring to the last
+element, -2 referring to the next to last element, and so on.</p>
<div>
@@ -571,21 +591,21 @@ Array Index: <code>.[2]</code>
<table>
<tr><th></th><td class="jqprogram">jq '.[0]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}</td>
+ <td>{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[2]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
@@ -618,14 +638,16 @@ Array Index: <code>.[2]</code>
<section id="Array/StringSlice:.[10:15]">
<h3>
-
-Array/String Slice: <code>.[10:15]</code>
-
+ Array/String Slice: <code>.[10:15]</code>
</h3>
-
-<p>The <code>.[10:15]</code> syntax can be used to return a subarray of an array or substring of a string. The array returned by <code>.[10:15]</code> will be of length 5, containing the elements from index 10 (inclusive) to index 15 (exclusive). Either index may be negative (in which case it counts backwards from the end of the array), or omitted (in which case it refers to the start or end of the array).</p>
-
+ <p>The <code>.[10:15]</code> syntax can be used to return a subarray of an
+array or substring of a string. The array returned by
+<code>.[10:15]</code> will be of length 5, containing the elements from
+index 10 (inclusive) to index 15 (exclusive). Either index may
+be negative (in which case it counts backwards from the end of
+the array), or omitted (in which case it refers to the start
+or end of the array).</p>
<div>
@@ -638,56 +660,56 @@ Array/String Slice: <code>.[10:15]</code>
<table>
<tr><th></th><td class="jqprogram">jq '.[2:4]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;c&quot;, &quot;d&quot;]</td>
+ <td>[&#34;c&#34;, &#34;d&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[2:4]'</td></tr>
- <tr><th>Input</th><td>&quot;abcdefghi&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;abcdefghi&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;cd&quot;</td>
+ <td>&#34;cd&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[:3]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</td>
+ <td>[&#34;a&#34;, &#34;b&#34;, &#34;c&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[-2:]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;d&quot;, &quot;e&quot;]</td>
+ <td>[&#34;d&#34;, &#34;e&#34;]</td>
</tr>
</table>
@@ -699,16 +721,16 @@ Array/String Slice: <code>.[10:15]</code>
<section id="Array/ObjectValueIterator:.[]">
<h3>
-
-Array/Object Value Iterator: <code>.[]</code>
-
+ Array/Object Value Iterator: <code>.[]</code>
</h3>
-
-<p>If you use the <code>.[index]</code> syntax, but omit the index entirely, it will return <em>all</em> of the elements of an array. Running <code>.[]</code> with the input <code>[1,2,3]</code> will produce the numbers as three separate results, rather than as a single array.</p>
-
-<p>You can also use this on an object, and it will return all the values of the object.</p>
-
+ <p>If you use the <code>.[index]</code> syntax, but omit the index
+entirely, it will return <em>all</em> of the elements of an
+array. Running <code>.[]</code> with the input <code>[1,2,3]</code> will produce the
+numbers as three separate results, rather than as a single
+array.</p>
+<p>You can also use this on an object, and it will return all
+the values of the object.</p>
<div>
@@ -721,21 +743,21 @@ Array/Object Value Iterator: <code>.[]</code>
<table>
<tr><th></th><td class="jqprogram">jq '.[]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}</td>
+ <td>{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}</td>
+ <td>{&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}</td>
</tr>
</table>
@@ -754,7 +776,7 @@ Array/Object Value Iterator: <code>.[]</code>
<table>
<tr><th></th><td class="jqprogram">jq '.[]'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 1}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 1}</td></tr>
<tr>
@@ -780,29 +802,27 @@ Array/Object Value Iterator: <code>.[]</code>
<section id=".[]?">
<h3>
-
-<code>.[]?</code>
-
+ <code>.[]?</code>
</h3>
-
-<p>Like <code>.[]</code>, but no errors will be output if . is not an array or object.</p>
-
+ <p>Like <code>.[]</code>, but no errors will be output if . is not an array
+or object.</p>
</section>
<section id="Comma:,">
<h3>
-
-Comma: <code>,</code>
-
+ Comma: <code>,</code>
</h3>
-
-<p>If two filters are separated by a comma, then the same input will be fed into both and the two filters’ output value streams will be concatenated in order: first, all of the outputs produced by the left expression, and then all of the outputs produced by the right. For instance, filter <code>.foo,
-.bar</code>, produces both the “foo” fields and “bar” fields as separate outputs.</p>
-
+ <p>If two filters are separated by a comma, then the
+same input will be fed into both and the two filters' output
+value streams will be concatenated in order: first, all of the
+outputs produced by the left expression, and then all of the
+outputs produced by the right. For instance, filter <code>.foo,
+.bar</code>, produces both the "foo" fields and "bar" fields as
+separate outputs.</p>
<div>
@@ -815,7 +835,7 @@ Comma: <code>,</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo, .bar'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;something else&quot;, &quot;baz&quot;: true}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;something else&#34;, &#34;baz&#34;: true}</td></tr>
<tr>
@@ -829,56 +849,56 @@ Comma: <code>,</code>
<th></th>
- <td>&quot;something else&quot;</td>
+ <td>&#34;something else&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.user, .projects[]'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;projects&quot;: [&quot;jq&quot;, &quot;wikiflow&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;projects&#34;: [&#34;jq&#34;, &#34;wikiflow&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>&quot;stedolan&quot;</td>
+ <td>&#34;stedolan&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;jq&quot;</td>
+ <td>&#34;jq&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;wikiflow&quot;</td>
+ <td>&#34;wikiflow&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[4,2]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;e&quot;</td>
+ <td>&#34;e&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;c&quot;</td>
+ <td>&#34;c&#34;</td>
</tr>
</table>
@@ -890,20 +910,22 @@ Comma: <code>,</code>
<section id="Pipe:|">
<h3>
-
-Pipe: <code>|</code>
-
+ Pipe: <code>|</code>
</h3>
-
-<p>The | operator combines two filters by feeding the output(s) of the one on the left into the input of the one on the right. It’s pretty much the same as the Unix shell’s pipe, if you’re used to that.</p>
-
-<p>If the one on the left produces multiple results, the one on the right will be run for each of those results. So, the expression <code>.[] | .foo</code> retrieves the “foo” field of each element of the input array.</p>
-
+ <p>The | operator combines two filters by feeding the output(s) of
+the one on the left into the input of the one on the right. It's
+pretty much the same as the Unix shell's pipe, if you're used to
+that.</p>
+<p>If the one on the left produces multiple results, the one on
+the right will be run for each of those results. So, the
+expression <code>.[] | .foo</code> retrieves the "foo" field of each
+element of the input array.</p>
<p>Note that <code>.a.b.c</code> is the same as <code>.a | .b | .c</code>.</p>
-
-<p>Note too that <code>.</code> is the input value at the particular stage in a “pipeline”, specifically: where the <code>.</code> expression appears. Thus <code>.a | . | .b</code> is the same as <code>.a.b</code>, as the <code>.</code> in the middle refers to whatever value <code>.a</code> produced.</p>
-
+<p>Note too that <code>.</code> is the input value at the particular stage
+in a "pipeline", specifically: where the <code>.</code> expression appears.
+Thus <code>.a | . | .b</code> is the same as <code>.a.b</code>, as the <code>.</code> in the
+middle refers to whatever value <code>.a</code> produced.</p>
<div>
@@ -916,21 +938,21 @@ Pipe: <code>|</code>
<table>
<tr><th></th><td class="jqprogram">jq '.[] | .name'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;JSON&quot;</td>
+ <td>&#34;JSON&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;XML&quot;</td>
+ <td>&#34;XML&#34;</td>
</tr>
</table>
@@ -942,14 +964,11 @@ Pipe: <code>|</code>
<section id="Parenthesis">
<h3>
-
-Parenthesis
-
+ Parenthesis
</h3>
-
-<p>Parenthesis work as a grouping operator just as in any typical programming language.</p>
-
+ <p>Parenthesis work as a grouping operator just as in any typical
+programming language.</p>
<div>
@@ -983,26 +1002,35 @@ Parenthesis
<section id="TypesandValues">
<h2>Types and Values</h2>
-
-<p>jq supports the same set of datatypes as JSON - numbers, strings, booleans, arrays, objects (which in JSON-speak are hashes with only string keys), and “null”.</p>
-
-<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 - <code>42</code> is a valid jq expression that takes an input, ignores it, and returns 42 instead.</p>
-
+ <p>jq supports the same set of datatypes as JSON - numbers,
+strings, booleans, arrays, objects (which in JSON-speak are
+hashes with only string keys), and "null".</p>
+<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 - <code>42</code> is a valid jq
+expression that takes an input, ignores it, and returns 42
+instead.</p>
<section id="Arrayconstruction:[]">
<h3>
-
-Array construction: <code>[]</code>
-
+ Array construction: <code>[]</code>
</h3>
-
-<p>As in JSON, <code>[]</code> is used to construct arrays, as in <code>[1,2,3]</code>. 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 <code>[.foo, .bar, .baz]</code>) or to “collect” all the results of a filter into an array (as in <code>[.items[].name]</code>)</p>
-
-<p>Once you understand the “,” operator, you can look at jq’s array syntax in a different light: the expression <code>[1,2,3]</code> is not using a built-in syntax for comma-separated arrays, but is instead applying the <code>[]</code> operator (collect results) to the expression 1,2,3 (which produces three different results).</p>
-
-<p>If you have a filter <code>X</code> that produces four results, then the expression <code>[X]</code> will produce a single result, an array of four elements.</p>
-
+ <p>As in JSON, <code>[]</code> is used to construct arrays, as in
+<code>[1,2,3]</code>. 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 <code>[.foo, .bar, .baz]</code>) or to "collect" all the
+results of a filter into an array (as in <code>[.items[].name]</code>)</p>
+<p>Once you understand the "," operator, you can look at jq's array
+syntax in a different light: the expression <code>[1,2,3]</code> is not using a
+built-in syntax for comma-separated arrays, but is instead applying
+the <code>[]</code> operator (collect results) to the expression 1,2,3 (which
+produces three different results).</p>
+<p>If you have a filter <code>X</code> that produces four results,
+then the expression <code>[X]</code> will produce a single result, an
+array of four elements.</p>
<div>
@@ -1015,14 +1043,14 @@ Array construction: <code>[]</code>
<table>
<tr><th></th><td class="jqprogram">jq '[.user, .projects[]]'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;projects&quot;: [&quot;jq&quot;, &quot;wikiflow&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;projects&#34;: [&#34;jq&#34;, &#34;wikiflow&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;stedolan&quot;, &quot;jq&quot;, &quot;wikiflow&quot;]</td>
+ <td>[&#34;stedolan&#34;, &#34;jq&#34;, &#34;wikiflow&#34;]</td>
</tr>
</table>
@@ -1048,47 +1076,58 @@ Array construction: <code>[]</code>
<section id="ObjectConstruction:{}">
<h3>
-
-Object Construction: <code>{}</code>
-
+ Object Construction: <code>{}</code>
</h3>
-
-<p>Like JSON, <code>{}</code> is for constructing objects (aka dictionaries or hashes), as in: <code>{&quot;a&quot;: 42, &quot;b&quot;: 17}</code>.</p>
-
-<p>If the keys are “identifier-like”, then the quotes can be left off, as in <code>{a:42, b:17}</code>. Keys generated by expressions need to be parenthesized, e.g., <code>{(&quot;a&quot;+&quot;b&quot;):59}</code>.</p>
-
-<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).</p>
-
-<pre><code>{foo: .bar}</code></pre>
-
-<p>will produce the JSON object <code>{&quot;foo&quot;: 42}</code> if given the JSON object <code>{&quot;bar&quot;:42, &quot;baz&quot;:43}</code> as its input. You can use this to select particular fields of an object: if the input is an object with “user”, “title”, “id”, and “content” fields and you just want “user” and “title”, you can write</p>
-
-<pre><code>{user: .user, title: .title}</code></pre>
-
-<p>Because that is so common, there’s a shortcut syntax for it: <code>{user, title}</code>.</p>
-
-<p>If one of the expressions produces multiple results, multiple dictionaries will be produced. If the input’s</p>
-
-<pre><code>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</code></pre>
-
+ <p>Like JSON, <code>{}</code> is for constructing objects (aka
+dictionaries or hashes), as in: <code>{"a": 42, "b": 17}</code>.</p>
+<p>If the keys are "identifier-like", then the quotes can be left
+off, as in <code>{a:42, b:17}</code>. 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.,
+<code>{("a"+"b"):59}</code>.</p>
+<p>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).</p>
+<pre><code>{foo: .bar}
+</code></pre>
+<p>will produce the JSON object <code>{"foo": 42}</code> if given the JSON
+object <code>{"bar":42, "baz":43}</code> as its input. You can use this
+to select particular fields of an object: if the input is an
+object with "user", "title", "id", and "content" fields and
+you just want "user" and "title", you can write</p>
+<pre><code>{user: .user, title: .title}
+</code></pre>
+<p>Because that is so common, there's a shortcut syntax for it:
+<code>{user, title}</code>.</p>
+<p>If one of the expressions produces multiple results,
+multiple dictionaries will be produced. If the input's</p>
+<pre><code>{"user":"stedolan","titles":["JQ Primer", "More JQ"]}
+</code></pre>
<p>then the expression</p>
-
-<pre><code>{user, title: .titles[]}</code></pre>
-
+<pre><code>{user, title: .titles[]}
+</code></pre>
<p>will produce two outputs:</p>
-
-<pre><code>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;JQ Primer&quot;}
-{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;More JQ&quot;}</code></pre>
-
-<p>Putting parentheses around the key means it will be evaluated as an expression. With the same input as above,</p>
-
-<pre><code>{(.user): .titles}</code></pre>
-
+<pre><code>{"user":"stedolan", "title": "JQ Primer"}
+{"user":"stedolan", "title": "More JQ"}
+</code></pre>
+<p>Putting parentheses around the key means it will be evaluated as an
+expression. With the same input as above,</p>
+<pre><code>{(.user): .titles}
+</code></pre>
<p>produces</p>
-
-<pre><code>{&quot;stedolan&quot;: [&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</code></pre>
-
+<pre><code>{"stedolan": ["JQ Primer", "More JQ"]}
+</code></pre>
+<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,</p>
+<pre><code>"f o o" as $foo | "b a r" as $bar | {$foo, $bar:$foo}
+</code></pre>
+<p>produces</p>
+<pre><code>{"f o o":"f o o","b a r":"f o o"}
+</code></pre>
<div>
@@ -1101,35 +1140,35 @@ Object Construction: <code>{}</code>
<table>
<tr><th></th><td class="jqprogram">jq '{user, title: .titles[]}'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;,&#34;titles&#34;:[&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;JQ Primer&quot;}</td>
+ <td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;title&#34;: &#34;JQ Primer&#34;}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;More JQ&quot;}</td>
+ <td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;title&#34;: &#34;More JQ&#34;}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '{(.user): .titles}'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;,&#34;titles&#34;:[&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;stedolan&quot;: [&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td>
+ <td>{&#34;stedolan&#34;: [&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td>
</tr>
</table>
@@ -1141,16 +1180,17 @@ Object Construction: <code>{}</code>
<section id="RecursiveDescent:..">
<h3>
-
-Recursive Descent: <code>..</code>
-
+ Recursive Descent: <code>..</code>
</h3>
-
-<p>Recursively descends <code>.</code>, producing every value. This is the same as the zero-argument <code>recurse</code> builtin (see below). This is intended to resemble the XPath <code>//</code> operator. Note that <code>..a</code> does not work; use <code>..|.a</code> instead. In the example below we use <code>..|.a?</code> to find all the values of object keys “a” in any object found “below” <code>.</code>.</p>
-
-<p>This is particularly useful in conjunction with <code>path(EXP)</code> (also see below) and the <code>?</code> operator.</p>
-
+ <p>Recursively descends <code>.</code>, producing every value. This is the
+same as the zero-argument <code>recurse</code> builtin (see below). This
+is intended to resemble the XPath <code>//</code> operator. Note that
+<code>..a</code> does not work; use <code>..|.a</code> instead. In the example
+below we use <code>..|.a?</code> to find all the values of object keys
+"a" in any object found "below" <code>.</code>.</p>
+<p>This is particularly useful in conjunction with <code>path(EXP)</code>
+(also see below) and the <code>?</code> operator.</p>
<div>
@@ -1163,7 +1203,7 @@ Recursive Descent: <code>..</code>
<table>
<tr><th></th><td class="jqprogram">jq '..|.a?'</td></tr>
- <tr><th>Input</th><td>[[{&quot;a&quot;:1}]]</td></tr>
+ <tr><th>Input</th><td>[[{&#34;a&#34;:1}]]</td></tr>
<tr>
@@ -1184,40 +1224,40 @@ Recursive Descent: <code>..</code>
<section id="Builtinoperatorsandfunctions">
<h2>Builtin operators and functions</h2>
-
-<p>Some jq operator (for instance, <code>+</code>) 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>
-
+ <p>Some jq operator (for instance, <code>+</code>) 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>
<section id="Addition:+">
<h3>
-
-Addition: <code>+</code>
-
+ Addition: <code>+</code>
</h3>
-
-<p>The operator <code>+</code> takes two filters, applies them both to the same input, and adds the results together. What “adding” means depends on the types involved:</p>
-
+ <p>The operator <code>+</code> takes two filters, applies them both
+to the same input, and adds the results together. What
+"adding" means depends on the types involved:</p>
<ul>
<li>
<p><strong>Numbers</strong> are added by normal arithmetic.</p>
</li>
-
<li>
<p><strong>Arrays</strong> are added by being concatenated into a larger array.</p>
</li>
-
<li>
<p><strong>Strings</strong> are added by being joined into a larger string.</p>
</li>
-
<li>
-<p><strong>Objects</strong> are added by merging, that is, inserting all the key-value pairs from both objects into a single combined object. If both objects contain a value for the same key, the object on the right of the <code>+</code> wins. (For recursive merge use the <code>*</code> operator.)</p>
+<p><strong>Objects</strong> are added by merging, that is, inserting all
+ the key-value pairs from both objects into a single
+ combined object. If both objects contain a value for the
+ same key, the object on the right of the <code>+</code> wins. (For
+ recursive merge use the <code>*</code> operator.)</p>
</li>
</ul>
-
-<p><code>null</code> can be added to any value, and returns the other value unchanged.</p>
-
+<p><code>null</code> can be added to any value, and returns the other
+value unchanged.</p>
<div>
@@ -1230,7 +1270,7 @@ Addition: <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + 1'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 7}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 7}</td></tr>
<tr>
@@ -1244,7 +1284,7 @@ Addition: <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + .b'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: [1,2], &quot;b&quot;: [3,4]}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: [1,2], &#34;b&#34;: [3,4]}</td></tr>
<tr>
@@ -1258,7 +1298,7 @@ Addition: <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + null'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1}</td></tr>
<tr>
@@ -1293,7 +1333,7 @@ Addition: <code>+</code>
<th>Output</th>
- <td>{&quot;a&quot;: 42, &quot;b&quot;: 2, &quot;c&quot;: 3}</td>
+ <td>{&#34;a&#34;: 42, &#34;b&#34;: 2, &#34;c&#34;: 3}</td>
</tr>
</table>
@@ -1305,14 +1345,12 @@ Addition: <code>+</code>
<section id="Subtraction:-">
<h3>
-
-Subtraction: <code>-</code>
-
+ Subtraction: <code>-</code>
</h3>
-
-<p>As well as normal arithmetic subtraction on numbers, the <code>-</code> operator can be used on arrays to remove all occurrences of the second array’s elements from the first array.</p>
-
+ <p>As well as normal arithmetic subtraction on numbers, the <code>-</code>
+operator can be used on arrays to remove all occurrences of
+the second array's elements from the first array.</p>
<div>
@@ -1325,7 +1363,7 @@ Subtraction: <code>-</code>
<table>
<tr><th></th><td class="jqprogram">jq '4 - .a'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:3}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:3}</td></tr>
<tr>
@@ -1338,15 +1376,15 @@ Subtraction: <code>-</code>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '. - [&quot;xml&quot;, &quot;yaml&quot;]'</td></tr>
- <tr><th>Input</th><td>[&quot;xml&quot;, &quot;yaml&quot;, &quot;json&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '. - [&#34;xml&#34;, &#34;yaml&#34;]'</td></tr>
+ <tr><th>Input</th><td>[&#34;xml&#34;, &#34;yaml&#34;, &#34;json&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;json&quot;]</td>
+ <td>[&#34;json&#34;]</td>
</tr>
</table>
@@ -1358,20 +1396,19 @@ Subtraction: <code>-</code>
<section id="Multiplication,division,modulo:*,/,and%">
<h3>
-
-Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</code>
-
+ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</code>
</h3>
-
-<p>These infix operators behave as expected when given two numbers. Division by zero raises an error. <code>x % y</code> computes x modulo y.</p>
-
-<p>Multiplying a string by a number produces the concatenation of that string that many times. <code>&quot;x&quot; * 0</code> produces <strong>null</strong>.</p>
-
-<p>Dividing a string by another splits the first using the second as separators.</p>
-
-<p>Multiplying two objects will merge them recursively: this works like addition but if both objects contain a value for the same key, and the values are objects, the two are merged with the same strategy.</p>
-
+ <p>These infix operators behave as expected when given two numbers.
+Division by zero raises an error. <code>x % y</code> computes x modulo y.</p>
+<p>Multiplying a string by a number produces the concatenation of
+that string that many times. <code>"x" * 0</code> produces <strong>null</strong>.</p>
+<p>Dividing a string by another splits the first using the second
+as separators.</p>
+<p>Multiplying two objects will merge them recursively: this works
+like addition but if both objects contain a value for the
+same key, and the values are objects, the two are merged with
+the same strategy.</p>
<div>
@@ -1397,21 +1434,21 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '. / &quot;, &quot;'</td></tr>
- <tr><th>Input</th><td>&quot;a, b,c,d, e&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq '. / &#34;, &#34;'</td></tr>
+ <tr><th>Input</th><td>&#34;a, b,c,d, e&#34;</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;a&quot;,&quot;b,c,d&quot;,&quot;e&quot;]</td>
+ <td>[&#34;a&#34;,&#34;b,c,d&#34;,&#34;e&#34;]</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '{&quot;k&quot;: {&quot;a&quot;: 1, &quot;b&quot;: 2}} * {&quot;k&quot;: {&quot;a&quot;: 0,&quot;c&quot;: 3}}'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '{&#34;k&#34;: {&#34;a&#34;: 1, &#34;b&#34;: 2}} * {&#34;k&#34;: {&#34;a&#34;: 0,&#34;c&#34;: 3}}'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -1419,7 +1456,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<th>Output</th>
- <td>{&quot;k&quot;: {&quot;a&quot;: 0, &quot;b&quot;: 2, &quot;c&quot;: 3}}</td>
+ <td>{&#34;k&#34;: {&#34;a&#34;: 0, &#34;b&#34;: 2, &#34;c&#34;: 3}}</td>
</tr>
</table>
@@ -1452,33 +1489,28 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="length">
<h3>
-
-<code>length</code>
-
+ <code>length</code>
</h3>
-
-<p>The builtin function <code>length</code> gets the length of various different types of value:</p>
-
+ <p>The builtin function <code>length</code> gets the length of various
+different types of value:</p>
<ul>
<li>
-<p>The length of a <strong>string</strong> is the number of Unicode codepoints it contains (which will be the same as its JSON-encoded length in bytes if it’s pure ASCII).</p>
+<p>The length of a <strong>string</strong> is the number of Unicode
+ codepoints it contains (which will be the same as its
+ JSON-encoded length in bytes if it's pure ASCII).</p>
</li>
-
<li>
<p>The length of an <strong>array</strong> is the number of elements.</p>
</li>
-
<li>
<p>The length of an <strong>object</strong> is the number of key-value pairs.</p>
</li>
-
<li>
<p>The length of <strong>null</strong> is zero.</p>
</li>
</ul>
-
<div>
@@ -1490,7 +1522,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<table>
<tr><th></th><td class="jqprogram">jq '.[] | length'</td></tr>
- <tr><th>Input</th><td>[[1,2], &quot;string&quot;, {&quot;a&quot;:2}, null]</td></tr>
+ <tr><th>Input</th><td>[[1,2], &#34;string&#34;, {&#34;a&#34;:2}, null]</td></tr>
<tr>
@@ -1530,14 +1562,11 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="utf8bytelength">
<h3>
-
-<code>utf8bytelength</code>
-
+ <code>utf8bytelength</code>
</h3>
-
-<p>The builtin function <code>utf8bytelength</code> outputs the number of bytes used to encode a string in UTF-8.</p>
-
+ <p>The builtin function <code>utf8bytelength</code> outputs the number of
+bytes used to encode a string in UTF-8.</p>
<div>
@@ -1550,7 +1579,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<table>
<tr><th></th><td class="jqprogram">jq 'utf8bytelength'</td></tr>
- <tr><th>Input</th><td>&quot;\u03bc&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;\u03bc&#34;</td></tr>
<tr>
@@ -1569,20 +1598,21 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="keys,keys_unsorted">
<h3>
-
-<code>keys</code>, <code>keys_unsorted</code>
-
+ <code>keys</code>, <code>keys_unsorted</code>
</h3>
-
-<p>The builtin function <code>keys</code>, when given an object, returns its keys in an array.</p>
-
-<p>The keys are sorted “alphabetically”, by unicode codepoint order. This is not an order that makes particular sense in any particular language, but you can count on it being the same for any two objects with the same set of keys, regardless of locale settings.</p>
-
-<p>When <code>keys</code> is given an array, it returns the valid indices for that array: the integers from 0 to length-1.</p>
-
-<p>The <code>keys_unsorted</code> function is just like <code>keys</code>, but if the input is an object then the keys will not be sorted, instead the keys will roughly be in insertion order.</p>
-
+ <p>The builtin function <code>keys</code>, when given an object, returns
+its keys in an array.</p>
+<p>The keys are sorted "alphabetically", by unicode codepoint
+order. This is not an order that makes particular sense in
+any particular language, but you can count on it being the
+same for any two objects with the same set of keys,
+regardless of locale settings.</p>
+<p>When <code>keys</code> is given an array, it returns the valid indices
+for that array: the integers from 0 to length-1.</p>
+<p>The <code>keys_unsorted</code> function is just like <code>keys</code>, but if
+the input is an object then the keys will not be sorted,
+instead the keys will roughly be in insertion order.</p>
<div>
@@ -1595,14 +1625,14 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<table>
<tr><th></th><td class="jqprogram">jq 'keys'</td></tr>
- <tr><th>Input</th><td>{&quot;abc&quot;: 1, &quot;abcd&quot;: 2, &quot;Foo&quot;: 3}</td></tr>
+ <tr><th>Input</th><td>{&#34;abc&#34;: 1, &#34;abcd&#34;: 2, &#34;Foo&#34;: 3}</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;Foo&quot;, &quot;abc&quot;, &quot;abcd&quot;]</td>
+ <td>[&#34;Foo&#34;, &#34;abc&#34;, &#34;abcd&#34;]</td>
</tr>
</table>
@@ -1628,16 +1658,15 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="has(key)">
<h3>
-
-<code>has(key)</code>
-
+ <code>has(key)</code>
</h3>
-
-<p>The builtin function <code>has</code> returns whether the input object has the given key, or the input array has an element at the given index.</p>
-
-<p><code>has($key)</code> has the same effect as checking whether <code>$key</code> is a member of the array returned by <code>keys</code>, although <code>has</code> will be faster.</p>
-
+ <p>The builtin function <code>has</code> returns whether the input object
+has the given key, or the input array has an element at the
+given index.</p>
+<p><code>has($key)</code> has the same effect as checking whether <code>$key</code>
+is a member of the array returned by <code>keys</code>, although <code>has</code>
+will be faster.</p>
<div>
@@ -1649,8 +1678,8 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<div id="example19" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'map(has(&quot;foo&quot;))'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;: 42}, {}]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'map(has(&#34;foo&#34;))'</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;: 42}, {}]</td></tr>
<tr>
@@ -1664,7 +1693,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<table>
<tr><th></th><td class="jqprogram">jq 'map(has(2))'</td></tr>
- <tr><th>Input</th><td>[[0,1], [&quot;a&quot;,&quot;b&quot;,&quot;c&quot;]]</td></tr>
+ <tr><th>Input</th><td>[[0,1], [&#34;a&#34;,&#34;b&#34;,&#34;c&#34;]]</td></tr>
<tr>
@@ -1683,14 +1712,13 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="in">
<h3>
-
-<code>in</code>
-
+ <code>in</code>
</h3>
-
-<p>The builtin function <code>in</code> returns whether or not the input key is in the given object, or the input index corresponds to an element in the given array. It is, essentially, an inversed version of <code>has</code>.</p>
-
+ <p>The builtin function <code>in</code> returns whether or not the input key is in the
+given object, or the input index corresponds to an element
+in the given array. It is, essentially, an inversed version
+of <code>has</code>.</p>
<div>
@@ -1702,8 +1730,8 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<div id="example20" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '.[] | in({&quot;foo&quot;: 42})'</td></tr>
- <tr><th>Input</th><td>[&quot;foo&quot;, &quot;bar&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[] | in({&#34;foo&#34;: 42})'</td></tr>
+ <tr><th>Input</th><td>[&#34;foo&#34;, &#34;bar&#34;]</td></tr>
<tr>
@@ -1743,18 +1771,16 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="map(x),map_values(x)">
<h3>
-
-<code>map(x)</code>, <code>map_values(x)</code>
-
+ <code>map(x)</code>, <code>map_values(x)</code>
</h3>
-
-<p>For any filter <code>x</code>, <code>map(x)</code> will run that filter for each element of the input array, and return the outputs in a new array. <code>map(.+1)</code> will increment each element of an array of numbers.</p>
-
-<p>Similarly, <code>map_values(x)</code> will run that filter for each element, but it will return an object when an object is passed.</p>
-
-<p><code>map(x)</code> is equivalent to <code>[.[] | x]</code>. In fact, this is how it’s defined. Similarly, <code>map_values(x)</code> is defined as <code>.[] |= x</code>.</p>
-
+ <p>For any filter <code>x</code>, <code>map(x)</code> will run that filter for each
+element of the input array, and return the outputs in a new
+array. <code>map(.+1)</code> will increment each element of an array of numbers.</p>
+<p>Similarly, <code>map_values(x)</code> will run that filter for each element,
+but it will return an object when an object is passed.</p>
+<p><code>map(x)</code> is equivalent to <code>[.[] | x]</code>. In fact, this is how
+it's defined. Similarly, <code>map_values(x)</code> is defined as <code>.[] |= x</code>.</p>
<div>
@@ -1781,14 +1807,14 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<table>
<tr><th></th><td class="jqprogram">jq 'map_values(.+1)'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: 3}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 2, &#34;c&#34;: 3}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;: 2, &quot;b&quot;: 3, &quot;c&quot;: 4}</td>
+ <td>{&#34;a&#34;: 2, &#34;b&#34;: 3, &#34;c&#34;: 4}</td>
</tr>
</table>
@@ -1800,22 +1826,25 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="path(path_expression)">
<h3>
-
-<code>path(path_expression)</code>
-
+ <code>path(path_expression)</code>
</h3>
-
-<p>Outputs array representations of the given path expression in <code>.</code>. The outputs are arrays of strings (object keys) and/or numbers (array indices).</p>
-
-<p>Path expressions are jq expressions like <code>.a</code>, but also <code>.[]</code>. There are two types of path expressions: ones that can match exactly, and ones that cannot. For example, <code>.a.b.c</code> is an exact match path expression, while <code>.a[].b</code> is not.</p>
-
-<p><code>path(exact_path_expression)</code> will produce the array representation of the path expression even if it does not exist in <code>.</code>, if <code>.</code> is <code>null</code> or an array or an object.</p>
-
-<p><code>path(pattern)</code> will produce array representations of the paths matching <code>pattern</code> if the paths exist in <code>.</code>.</p>
-
-<p>Note that the path expressions are not different from normal expressions. The expression <code>path(..|select(type==&quot;boolean&quot;))</code> outputs all the paths to boolean values in <code>.</code>, and only those paths.</p>
-
+ <p>Outputs array representations of the given path expression
+in <code>.</code>. The outputs are arrays of strings (object keys)
+and/or numbers (array indices).</p>
+<p>Path expressions are jq expressions like <code>.a</code>, but also <code>.[]</code>.
+There are two types of path expressions: ones that can match
+exactly, and ones that cannot. For example, <code>.a.b.c</code> is an
+exact match path expression, while <code>.a[].b</code> is not.</p>
+<p><code>path(exact_path_expression)</code> will produce the array
+representation of the path expression even if it does not
+exist in <code>.</code>, if <code>.</code> is <code>null</code> or an array or an object.</p>
+<p><code>path(pattern)</code> will produce array representations of the
+paths matching <code>pattern</code> if the paths exist in <code>.</code>.</p>
+<p>Note that the path expressions are not different from normal
+expressions. The expression
+<code>path(..|select(type=="boolean"))</code> outputs all the paths to
+boolean values in <code>.</code>, and only those paths.</p>
<div>
@@ -1835,21 +1864,21 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<th>Output</th>
- <td>[&quot;a&quot;,0,&quot;b&quot;]</td>
+ <td>[&#34;a&#34;,0,&#34;b&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[path(..)]'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:[{&quot;b&quot;:1}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:[{&#34;b&#34;:1}]}</td></tr>
<tr>
<th>Output</th>
- <td>[[],[&quot;a&quot;],[&quot;a&quot;,0],[&quot;a&quot;,0,&quot;b&quot;]]</td>
+ <td>[[],[&#34;a&#34;],[&#34;a&#34;,0],[&#34;a&#34;,0,&#34;b&#34;]]</td>
</tr>
</table>
@@ -1861,14 +1890,11 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="del(path_expression)">
<h3>
-
-<code>del(path_expression)</code>
-
+ <code>del(path_expression)</code>
</h3>
-
-<p>The builtin function <code>del</code> removes a key and its corresponding value from an object.</p>
-
+ <p>The builtin function <code>del</code> removes a key and its corresponding
+value from an object.</p>
<div>
@@ -1881,28 +1907,28 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<table>
<tr><th></th><td class="jqprogram">jq 'del(.foo)'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: 9001, &quot;baz&quot;: 42}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: 9001, &#34;baz&#34;: 42}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;bar&quot;: 9001, &quot;baz&quot;: 42}</td>
+ <td>{&#34;bar&#34;: 9001, &#34;baz&#34;: 42}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'del(.[1, 2])'</td></tr>
- <tr><th>Input</th><td>[&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;foo&#34;, &#34;bar&#34;, &#34;baz&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;foo&quot;]</td>
+ <td>[&#34;foo&#34;]</td>
</tr>
</table>
@@ -1914,14 +1940,11 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="getpath(PATHS)">
<h3>
-
-<code>getpath(PATHS)</code>
-
+ <code>getpath(PATHS)</code>
</h3>
-
-<p>The builtin function <code>getpath</code> outputs the values in <code>.</code> found at each path in <code>PATHS</code>.</p>
-
+ <p>The builtin function <code>getpath</code> outputs the values in <code>.</code> found
+at each path in <code>PATHS</code>.</p>
<div>
@@ -1933,7 +1956,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<div id="example24" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'getpath([&quot;a&quot;,&quot;b&quot;])'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'getpath([&#34;a&#34;,&#34;b&#34;])'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -1947,8 +1970,8 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '[getpath([&quot;a&quot;,&quot;b&quot;], [&quot;a&quot;,&quot;c&quot;])]'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:{&quot;b&quot;:0, &quot;c&quot;:1}}</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[getpath([&#34;a&#34;,&#34;b&#34;], [&#34;a&#34;,&#34;c&#34;])]'</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:{&#34;b&#34;:0, &#34;c&#34;:1}}</td></tr>
<tr>
@@ -1967,14 +1990,10 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="setpath(PATHS;VALUE)">
<h3>
-
-<code>setpath(PATHS; VALUE)</code>
-
+ <code>setpath(PATHS; VALUE)</code>
</h3>
-
-<p>The builtin function <code>setpath</code> sets the <code>PATHS</code> in <code>.</code> to <code>VALUE</code>.</p>
-
+ <p>The builtin function <code>setpath</code> sets the <code>PATHS</code> in <code>.</code> to <code>VALUE</code>.</p>
<div>
@@ -1986,7 +2005,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<div id="example25" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'setpath([&quot;a&quot;,&quot;b&quot;]; 1)'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'setpath([&#34;a&#34;,&#34;b&#34;]; 1)'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -1994,27 +2013,27 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<th>Output</th>
- <td>{&quot;a&quot;: {&quot;b&quot;: 1}}</td>
+ <td>{&#34;a&#34;: {&#34;b&#34;: 1}}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'setpath([&quot;a&quot;,&quot;b&quot;]; 1)'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:{&quot;b&quot;:0}}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'setpath([&#34;a&#34;,&#34;b&#34;]; 1)'</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:{&#34;b&#34;:0}}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;: {&quot;b&quot;: 1}}</td>
+ <td>{&#34;a&#34;: {&#34;b&#34;: 1}}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'setpath([0,&quot;a&quot;]; 1)'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'setpath([0,&#34;a&#34;]; 1)'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -2022,7 +2041,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<th>Output</th>
- <td>[{&quot;a&quot;:1}]</td>
+ <td>[{&#34;a&#34;:1}]</td>
</tr>
</table>
@@ -2034,14 +2053,12 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="delpaths(PATHS)">
<h3>
-
-<code>delpaths(PATHS)</code>
-
+ <code>delpaths(PATHS)</code>
</h3>
-
-<p>The builtin function <code>delpaths</code> sets the <code>PATHS</code> in <code>.</code>. <code>PATHS</code> must be an array of paths, where each path is an array of strings and numbers.</p>
-
+ <p>The builtin function <code>delpaths</code> sets the <code>PATHS</code> in <code>.</code>.
+<code>PATHS</code> must be an array of paths, where each path is an array
+of strings and numbers.</p>
<div>
@@ -2053,15 +2070,15 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<div id="example26" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'delpaths([[&quot;a&quot;,&quot;b&quot;]])'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:{&quot;b&quot;:1},&quot;x&quot;:{&quot;y&quot;:2}}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'delpaths([[&#34;a&#34;,&#34;b&#34;]])'</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:{&#34;b&#34;:1},&#34;x&#34;:{&#34;y&#34;:2}}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;:{},&quot;x&quot;:{&quot;y&quot;:2}}</td>
+ <td>{&#34;a&#34;:{},&#34;x&#34;:{&#34;y&#34;:2}}</td>
</tr>
</table>
@@ -2073,17 +2090,18 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="to_entries,from_entries,with_entries">
<h3>
-
-<code>to_entries</code>, <code>from_entries</code>, <code>with_entries</code>
-
+ <code>to_entries</code>, <code>from_entries</code>, <code>with_entries</code>
</h3>
-
-<p>These functions convert between an object and an array of key-value pairs. If <code>to_entries</code> is passed an object, then for each <code>k: v</code> entry in the input, the output array includes <code>{&quot;key&quot;: k, &quot;value&quot;: v}</code>.</p>
-
-<p><code>from_entries</code> does the opposite conversion, and <code>with_entries(foo)</code> is a shorthand for <code>to_entries |
-map(foo) | from_entries</code>, useful for doing some operation to all keys and values of an object. <code>from_entries</code> accepts key, Key, name, Name, value and Value as keys.</p>
-
+ <p>These functions convert between an object and an array of
+key-value pairs. If <code>to_entries</code> is passed an object, then
+for each <code>k: v</code> entry in the input, the output array
+includes <code>{"key": k, "value": v}</code>.</p>
+<p><code>from_entries</code> does the opposite conversion, and
+<code>with_entries(foo)</code> is a shorthand for <code>to_entries |
+map(foo) | from_entries</code>, useful for doing some operation to
+all keys and values of an object. <code>from_entries</code> accepts key, Key,
+name, Name, value and Value as keys.</p>
<div>
@@ -2096,42 +2114,42 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'to_entries'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;key&quot;:&quot;a&quot;, &quot;value&quot;:1}, {&quot;key&quot;:&quot;b&quot;, &quot;value&quot;:2}]</td>
+ <td>[{&#34;key&#34;:&#34;a&#34;, &#34;value&#34;:1}, {&#34;key&#34;:&#34;b&#34;, &#34;value&#34;:2}]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'from_entries'</td></tr>
- <tr><th>Input</th><td>[{&quot;key&quot;:&quot;a&quot;, &quot;value&quot;:1}, {&quot;key&quot;:&quot;b&quot;, &quot;value&quot;:2}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;key&#34;:&#34;a&#34;, &#34;value&#34;:1}, {&#34;key&#34;:&#34;b&#34;, &#34;value&#34;:2}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td>
+ <td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'with_entries(.key |= &quot;KEY_&quot; + .)'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'with_entries(.key |= &#34;KEY_&#34; + .)'</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;KEY_a&quot;: 1, &quot;KEY_b&quot;: 2}</td>
+ <td>{&#34;KEY_a&#34;: 1, &#34;KEY_b&#34;: 2}</td>
</tr>
</table>
@@ -2143,16 +2161,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="select(boolean_expression)">
<h3>
-
-<code>select(boolean_expression)</code>
-
+ <code>select(boolean_expression)</code>
</h3>
-
-<p>The function <code>select(foo)</code> produces its input unchanged if <code>foo</code> returns true for that input, and produces no output otherwise.</p>
-
-<p>It’s useful for filtering lists: <code>[1,2,3] | map(select(. &gt;= 2))</code> will give you <code>[2,3]</code>.</p>
-
+ <p>The function <code>select(foo)</code> produces its input unchanged if
+<code>foo</code> returns true for that input, and produces no output
+otherwise.</p>
+<p>It's useful for filtering lists: <code>[1,2,3] | map(select(. &gt;= 2))</code>
+will give you <code>[2,3]</code>.</p>
<div>
@@ -2178,15 +2194,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[] | select(.id == &quot;second&quot;)'</td></tr>
- <tr><th>Input</th><td>[{&quot;id&quot;: &quot;first&quot;, &quot;val&quot;: 1}, {&quot;id&quot;: &quot;second&quot;, &quot;val&quot;: 2}]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[] | select(.id == &#34;second&#34;)'</td></tr>
+ <tr><th>Input</th><td>[{&#34;id&#34;: &#34;first&#34;, &#34;val&#34;: 1}, {&#34;id&#34;: &#34;second&#34;, &#34;val&#34;: 2}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;id&quot;: &quot;second&quot;, &quot;val&quot;: 2}</td>
+ <td>{&#34;id&#34;: &#34;second&#34;, &#34;val&#34;: 2}</td>
</tr>
</table>
@@ -2198,14 +2214,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="arrays,objects,iterables,booleans,numbers,normals,finites,strings,nulls,values,scalars">
<h3>
-
-<code>arrays</code>, <code>objects</code>, <code>iterables</code>, <code>booleans</code>, <code>numbers</code>, <code>normals</code>, <code>finites</code>, <code>strings</code>, <code>nulls</code>, <code>values</code>, <code>scalars</code>
-
+ <code>arrays</code>, <code>objects</code>, <code>iterables</code>, <code>booleans</code>, <code>numbers</code>, <code>normals</code>, <code>finites</code>, <code>strings</code>, <code>nulls</code>, <code>values</code>, <code>scalars</code>
</h3>
-
-<p>These built-ins select only inputs that are arrays, objects, iterables (arrays or objects), booleans, numbers, normal numbers, finite numbers, strings, null, non-null values, and non-iterables, respectively.</p>
-
+ <p>These built-ins select only inputs that are arrays, objects,
+iterables (arrays or objects), booleans, numbers, normal
+numbers, finite numbers, strings, null, non-null values, and
+non-iterables, respectively.</p>
<div>
@@ -2218,7 +2233,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[]|numbers'</td></tr>
- <tr><th>Input</th><td>[[],{},1,&quot;foo&quot;,null,true,false]</td></tr>
+ <tr><th>Input</th><td>[[],{},1,&#34;foo&#34;,null,true,false]</td></tr>
<tr>
@@ -2237,16 +2252,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="empty">
<h3>
-
-<code>empty</code>
-
+ <code>empty</code>
</h3>
-
-<p><code>empty</code> returns no results. None at all. Not even <code>null</code>.</p>
-
-<p>It’s useful on occasion. You’ll know if you need it :)</p>
-
+ <p><code>empty</code> returns no results. None at all. Not even <code>null</code>.</p>
+<p>It's useful on occasion. You'll know if you need it :)</p>
<div>
@@ -2299,60 +2309,50 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="error(message)">
<h3>
-
-<code>error(message)</code>
-
+ <code>error(message)</code>
</h3>
-
-<p>Produces an error, just like <code>.a</code> applied to values other than null and objects would, but with the given message as the error’s value. Errors can be caught with try/catch; see below.</p>
-
+ <p>Produces an error, just like <code>.a</code> applied to values other than
+null and objects would, but with the given message as the
+error's value. Errors can be caught with try/catch; see below.</p>
</section>
<section id="halt">
<h3>
-
-<code>halt</code>
-
+ <code>halt</code>
</h3>
-
-<p>Stops the jq program with no further outputs. jq will exit with exit status <code>0</code>.</p>
-
+ <p>Stops the jq program with no further outputs. jq will exit
+with exit status <code>0</code>.</p>
</section>
<section id="halt_error,halt_error(exit_code)">
<h3>
-
-<code>halt_error</code>, <code>halt_error(exit_code)</code>
-
+ <code>halt_error</code>, <code>halt_error(exit_code)</code>
</h3>
-
-<p>Stops the jq program with no further outputs. The input will be printed on <code>stderr</code> as raw output (i.e., strings will not have double quotes) with no decoration, not even a newline.</p>
-
-<p>The given <code>exit_code</code> (defaulting to <code>5</code>) will be jq’s exit status.</p>
-
-<p>For example, <code>&quot;Error: somthing went wrong\n&quot;|halt_error(1)</code>.</p>
-
+ <p>Stops the jq program with no further outputs. The input will
+be printed on <code>stderr</code> as raw output (i.e., strings will not
+have double quotes) with no decoration, not even a newline.</p>
+<p>The given <code>exit_code</code> (defaulting to <code>5</code>) will be jq's exit
+status.</p>
+<p>For example, <code>"Error: somthing went wrong\n"|halt_error(1)</code>.</p>
</section>
<section id="$__loc__">
<h3>
-
-<code>$__loc__</code>
-
+ <code>$__loc__</code>
</h3>
-
-<p>Produces an object with a “file” key and a “line” key, with the filename and line number where <code>$__loc__</code> occurs, as values.</p>
-
+ <p>Produces an object with a "file" key and a "line" key, with
+the filename and line number where <code>$__loc__</code> occurs, as
+values.</p>
<div>
@@ -2364,7 +2364,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example31" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'try error(&quot;\($__loc__)&quot;) catch .'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'try error(&#34;\($__loc__)&#34;) catch .'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -2372,7 +2372,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;{\&quot;file\&quot;:\&quot;&lt;top-level&gt;\&quot;,\&quot;line\&quot;:1}&quot;</td>
+ <td>&#34;{\&#34;file\&#34;:\&#34;&lt;top-level&gt;\&#34;,\&#34;line\&#34;:1}&#34;</td>
</tr>
</table>
@@ -2384,18 +2384,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="paths,paths(node_filter),leaf_paths">
<h3>
-
-<code>paths</code>, <code>paths(node_filter)</code>, <code>leaf_paths</code>
-
+ <code>paths</code>, <code>paths(node_filter)</code>, <code>leaf_paths</code>
</h3>
-
-<p><code>paths</code> outputs the paths to all the elements in its input (except it does not output the empty list, representing . itself).</p>
-
-<p><code>paths(f)</code> outputs the paths to any values for which <code>f</code> is true. That is, <code>paths(numbers)</code> outputs the paths to all numeric values.</p>
-
-<p><code>leaf_paths</code> is an alias of <code>paths(scalars)</code>; <code>leaf_paths</code> is <em>deprecated</em> and will be removed in the next major release.</p>
-
+ <p><code>paths</code> outputs the paths to all the elements in its input
+(except it does not output the empty list, representing .
+itself).</p>
+<p><code>paths(f)</code> outputs the paths to any values for which <code>f</code> is true.
+That is, <code>paths(numbers)</code> outputs the paths to all numeric
+values.</p>
+<p><code>leaf_paths</code> is an alias of <code>paths(scalars)</code>; <code>leaf_paths</code> is
+<em>deprecated</em> and will be removed in the next major release.</p>
<div>
@@ -2408,28 +2407,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '[paths]'</td></tr>
- <tr><th>Input</th><td>[1,[[],{&quot;a&quot;:2}]]</td></tr>
+ <tr><th>Input</th><td>[1,[[],{&#34;a&#34;:2}]]</td></tr>
<tr>
<th>Output</th>
- <td>[[0],[1],[1,0],[1,1],[1,1,&quot;a&quot;]]</td>
+ <td>[[0],[1],[1,0],[1,1],[1,1,&#34;a&#34;]]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[paths(scalars)]'</td></tr>
- <tr><th>Input</th><td>[1,[[],{&quot;a&quot;:2}]]</td></tr>
+ <tr><th>Input</th><td>[1,[[],{&#34;a&#34;:2}]]</td></tr>
<tr>
<th>Output</th>
- <td>[[0],[1,1,&quot;a&quot;]]</td>
+ <td>[[0],[1,1,&#34;a&#34;]]</td>
</tr>
</table>
@@ -2441,17 +2440,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="add">
<h3>
-
-<code>add</code>
-
+ <code>add</code>
</h3>
-
-<p>The filter <code>add</code> takes as input an array, and produces as output the elements of the array added together. This might mean summed, concatenated or merged depending on the types of the elements of the input array - the rules are the same as those for the <code>+</code> operator (described above).</p>
-
+ <p>The filter <code>add</code> takes as input an array, and produces as
+output the elements of the array added together. This might
+mean summed, concatenated or merged depending on the types
+of the elements of the input array - the rules are the same
+as those for the <code>+</code> operator (described above).</p>
<p>If the input is an empty array, <code>add</code> returns <code>null</code>.</p>
-
<div>
@@ -2463,14 +2461,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'add'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;abc&quot;</td>
+ <td>&#34;abc&#34;</td>
</tr>
</table>
@@ -2510,20 +2508,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="any,any(condition),any(generator;condition)">
<h3>
-
-<code>any</code>, <code>any(condition)</code>, <code>any(generator; condition)</code>
-
+ <code>any</code>, <code>any(condition)</code>, <code>any(generator; condition)</code>
</h3>
-
-<p>The filter <code>any</code> takes as input an array of boolean values, and produces <code>true</code> as output if any of the elements of the array are <code>true</code>.</p>
-
+ <p>The filter <code>any</code> takes as input an array of boolean values,
+and produces <code>true</code> as output if any of the elements of
+the array are <code>true</code>.</p>
<p>If the input is an empty array, <code>any</code> returns <code>false</code>.</p>
-
-<p>The <code>any(condition)</code> form applies the given condition to the elements of the input array.</p>
-
-<p>The <code>any(generator; condition)</code> form applies the given condition to all the outputs of the given generator.</p>
-
+<p>The <code>any(condition)</code> form applies the given condition to the
+elements of the input array.</p>
+<p>The <code>any(generator; condition)</code> form applies the given
+condition to all the outputs of the given generator.</p>
<div>
@@ -2583,21 +2578,18 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="all,all(condition),all(generator;condition)">
<h3>
-
-<code>all</code>, <code>all(condition)</code>, <code>all(generator; condition)</code>
-
+ <code>all</code>, <code>all(condition)</code>, <code>all(generator; condition)</code>
</h3>
-
-<p>The filter <code>all</code> takes as input an array of boolean values, and produces <code>true</code> as output if all of the elements of the array are <code>true</code>.</p>
-
-<p>The <code>all(condition)</code> form applies the given condition to the elements of the input array.</p>
-
-<p>The <code>all(generator; condition)</code> form applies the given condition to all the outputs of the given generator.</p>
-
+ <p>The filter <code>all</code> takes as input an array of boolean values,
+and produces <code>true</code> as output if all of the elements of
+the array are <code>true</code>.</p>
+<p>The <code>all(condition)</code> form applies the given condition to the
+elements of the input array.</p>
+<p>The <code>all(generator; condition)</code> form applies the given
+condition to all the outputs of the given generator.</p>
<p>If the input is an empty array, <code>all</code> returns <code>true</code>.</p>
-
<div>
@@ -2656,16 +2648,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="flatten,flatten(depth)">
<h3>
-
-<code>flatten</code>, <code>flatten(depth)</code>
-
+ <code>flatten</code>, <code>flatten(depth)</code>
</h3>
-
-<p>The filter <code>flatten</code> takes as input an array of nested arrays, and produces a flat array in which all arrays inside the original array have been recursively replaced by their values. You can pass an argument to it to specify how many levels of nesting to flatten.</p>
-
-<p><code>flatten(2)</code> is like <code>flatten</code>, but going only up to two levels deep.</p>
-
+ <p>The filter <code>flatten</code> takes as input an array of nested arrays,
+and produces a flat array in which all arrays inside the original
+array have been recursively replaced by their values. You can pass
+an argument to it to specify how many levels of nesting to flatten.</p>
+<p><code>flatten(2)</code> is like <code>flatten</code>, but going only up to two
+levels deep.</p>
<div>
@@ -2720,14 +2711,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'flatten'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;: &quot;bar&quot;}, [{&quot;foo&quot;: &quot;baz&quot;}]]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;: &#34;bar&#34;}, [{&#34;foo&#34;: &#34;baz&#34;}]]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;foo&quot;: &quot;bar&quot;}, {&quot;foo&quot;: &quot;baz&quot;}]</td>
+ <td>[{&#34;foo&#34;: &#34;bar&#34;}, {&#34;foo&#34;: &#34;baz&#34;}]</td>
</tr>
</table>
@@ -2739,20 +2730,19 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="range(upto),range(from;upto)range(from;upto;by)">
<h3>
-
-<code>range(upto)</code>, <code>range(from;upto)</code> <code>range(from;upto;by)</code>
-
+ <code>range(upto)</code>, <code>range(from;upto)</code> <code>range(from;upto;by)</code>
</h3>
-
-<p>The <code>range</code> function produces a range of numbers. <code>range(4;10)</code> produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers are produced as separate outputs. Use <code>[range(4;10)]</code> to get a range as an array.</p>
-
-<p>The one argument form generates numbers from 0 to the given number, with an increment of 1.</p>
-
-<p>The two argument form generates numbers from <code>from</code> to <code>upto</code> with an increment of 1.</p>
-
-<p>The three argument form generates numbers <code>from</code> to <code>upto</code> with an increment of <code>by</code>.</p>
-
+ <p>The <code>range</code> function produces a range of numbers. <code>range(4;10)</code>
+produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers
+are produced as separate outputs. Use <code>[range(4;10)]</code> to get a range as
+an array.</p>
+<p>The one argument form generates numbers from 0 to the given
+number, with an increment of 1.</p>
+<p>The two argument form generates numbers from <code>from</code> to <code>upto</code>
+with an increment of 1.</p>
+<p>The three argument form generates numbers <code>from</code> to <code>upto</code>
+with an increment of <code>by</code>.</p>
<div>
@@ -2861,14 +2851,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="floor">
<h3>
-
-<code>floor</code>
-
+ <code>floor</code>
</h3>
-
-<p>The <code>floor</code> function returns the floor of its numeric input.</p>
-
+ <p>The <code>floor</code> function returns the floor of its numeric input.</p>
<div>
@@ -2900,14 +2886,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="sqrt">
<h3>
-
-<code>sqrt</code>
-
+ <code>sqrt</code>
</h3>
-
-<p>The <code>sqrt</code> function returns the square root of its numeric input.</p>
-
+ <p>The <code>sqrt</code> function returns the square root of its numeric input.</p>
<div>
@@ -2939,14 +2921,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="tonumber">
<h3>
-
-<code>tonumber</code>
-
+ <code>tonumber</code>
</h3>
-
-<p>The <code>tonumber</code> function parses its input as a number. It will convert correctly-formatted strings to their numeric equivalent, leave numbers alone, and give an error on all other input.</p>
-
+ <p>The <code>tonumber</code> function parses its input as a number. It
+will convert correctly-formatted strings to their numeric
+equivalent, leave numbers alone, and give an error on all other input.</p>
<div>
@@ -2959,7 +2939,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[] | tonumber'</td></tr>
- <tr><th>Input</th><td>[1, &quot;1&quot;]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;1&#34;]</td></tr>
<tr>
@@ -2985,14 +2965,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="tostring">
<h3>
-
-<code>tostring</code>
-
+ <code>tostring</code>
</h3>
-
-<p>The <code>tostring</code> function prints its input as a string. Strings are left unchanged, and all other values are JSON-encoded.</p>
-
+ <p>The <code>tostring</code> function prints its input as a
+string. Strings are left unchanged, and all other values are
+JSON-encoded.</p>
<div>
@@ -3005,28 +2983,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[] | tostring'</td></tr>
- <tr><th>Input</th><td>[1, &quot;1&quot;, [1]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;1&#34;, [1]]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;1&quot;</td>
+ <td>&#34;1&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;1&quot;</td>
+ <td>&#34;1&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;[1]&quot;</td>
+ <td>&#34;[1]&#34;</td>
</tr>
</table>
@@ -3038,14 +3016,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="type">
<h3>
-
-<code>type</code>
-
+ <code>type</code>
</h3>
-
-<p>The <code>type</code> function returns the type of its argument as a string, which is one of null, boolean, number, string, array or object.</p>
-
+ <p>The <code>type</code> function returns the type of its argument as a
+string, which is one of null, boolean, number, string, array
+or object.</p>
<div>
@@ -3058,14 +3034,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'map(type)'</td></tr>
- <tr><th>Input</th><td>[0, false, [], {}, null, &quot;hello&quot;]</td></tr>
+ <tr><th>Input</th><td>[0, false, [], {}, null, &#34;hello&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;number&quot;, &quot;boolean&quot;, &quot;array&quot;, &quot;object&quot;, &quot;null&quot;, &quot;string&quot;]</td>
+ <td>[&#34;number&#34;, &#34;boolean&#34;, &#34;array&#34;, &#34;object&#34;, &#34;null&#34;, &#34;string&#34;]</td>
</tr>
</table>
@@ -3077,18 +3053,19 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="infinite,nan,isinfinite,isnan,isfinite,isnormal">
<h3>
-
-<code>infinite</code>, <code>nan</code>, <code>isinfinite</code>, <code>isnan</code>, <code>isfinite</code>, <code>isnormal</code>
-
+ <code>infinite</code>, <code>nan</code>, <code>isinfinite</code>, <code>isnan</code>, <code>isfinite</code>, <code>isnormal</code>
</h3>
-
-<p>Some arithmetic operations can yield infinities and “not a number” (NaN) values. The <code>isinfinite</code> builtin returns <code>true</code> if its input is infinite. The <code>isnan</code> builtin returns <code>true</code> if its input is a NaN. The <code>infinite</code> builtin returns a positive infinite value. The <code>nan</code> builtin returns a NaN. The <code>isnormal</code> builtin returns true if its input is a normal number.</p>
-
+ <p>Some arithmetic operations can yield infinities and "not a
+number" (NaN) values. The <code>isinfinite</code> builtin returns <code>true</code>
+if its input is infinite. The <code>isnan</code> builtin returns <code>true</code>
+if its input is a NaN. The <code>infinite</code> builtin returns a
+positive infinite value. The <code>nan</code> builtin returns a NaN.
+The <code>isnormal</code> builtin returns true if its input is a normal
+number.</p>
<p>Note that division by zero raises an error.</p>
-
-<p>Currently most arithmetic operations operating on infinities, NaNs, and sub-normals do not raise errors.</p>
-
+<p>Currently most arithmetic operations operating on infinities,
+NaNs, and sub-normals do not raise errors.</p>
<div>
@@ -3129,14 +3106,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;number&quot;</td>
+ <td>&#34;number&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;number&quot;</td>
+ <td>&#34;number&#34;</td>
</tr>
</table>
@@ -3148,36 +3125,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="sort,sort_by(path_expression)">
<h3>
-
-<code>sort, sort_by(path_expression)</code>
-
+ <code>sort, sort_by(path_expression)</code>
</h3>
-
-<p>The <code>sort</code> functions sorts its input, which must be an array. Values are sorted in the following order:</p>
-
+ <p>The <code>sort</code> functions sorts its input, which must be an
+array. Values are sorted in the following order:</p>
<ul>
<li><code>null</code></li>
-
<li><code>false</code></li>
-
<li><code>true</code></li>
-
<li>numbers</li>
-
<li>strings, in alphabetical order (by unicode codepoint value)</li>
-
<li>arrays, in lexical order</li>
-
<li>objects</li>
</ul>
-
-<p>The ordering for objects is a little complex: first they’re compared by comparing their sets of keys (as arrays in sorted order), and if their keys are equal then the values are compared key by key.</p>
-
-<p><code>sort</code> may be used to sort by a particular field of an object, or by applying any jq filter.</p>
-
-<p><code>sort_by(foo)</code> compares two elements by comparing the result of <code>foo</code> on each element.</p>
-
+<p>The ordering for objects is a little complex: first they're
+compared by comparing their sets of keys (as arrays in
+sorted order), and if their keys are equal then the values
+are compared key by key.</p>
+<p><code>sort</code> may be used to sort by a particular field of an
+object, or by applying any jq filter.</p>
+<p><code>sort_by(foo)</code> compares two elements by comparing the result of
+<code>foo</code> on each element.</p>
<div>
@@ -3204,14 +3173,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'sort_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:4, &quot;bar&quot;:10}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:2, &quot;bar&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:4, &#34;bar&#34;:10}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:2, &#34;bar&#34;:1}]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;foo&quot;:2, &quot;bar&quot;:1}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:4, &quot;bar&quot;:10}]</td>
+ <td>[{&#34;foo&#34;:2, &#34;bar&#34;:1}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:4, &#34;bar&#34;:10}]</td>
</tr>
</table>
@@ -3223,16 +3192,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="group_by(path_expression)">
<h3>
-
-<code>group_by(path_expression)</code>
-
+ <code>group_by(path_expression)</code>
</h3>
-
-<p><code>group_by(.foo)</code> takes as input an array, groups the elements having the same <code>.foo</code> field into separate arrays, and produces all of these arrays as elements of a larger array, sorted by the value of the <code>.foo</code> field.</p>
-
-<p>Any jq expression, not just a field access, may be used in place of <code>.foo</code>. The sorting order is the same as described in the <code>sort</code> function above.</p>
-
+ <p><code>group_by(.foo)</code> takes as input an array, groups the
+elements having the same <code>.foo</code> field into separate arrays,
+and produces all of these arrays as elements of a larger
+array, sorted by the value of the <code>.foo</code> field.</p>
+<p>Any jq expression, not just a field access, may be used in
+place of <code>.foo</code>. The sorting order is the same as described
+in the <code>sort</code> function above.</p>
<div>
@@ -3245,14 +3214,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'group_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:1, &quot;bar&quot;:10}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:1, &quot;bar&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:1, &#34;bar&#34;:10}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:1, &#34;bar&#34;:1}]</td></tr>
<tr>
<th>Output</th>
- <td>[[{&quot;foo&quot;:1, &quot;bar&quot;:10}, {&quot;foo&quot;:1, &quot;bar&quot;:1}], [{&quot;foo&quot;:3, &quot;bar&quot;:100}]]</td>
+ <td>[[{&#34;foo&#34;:1, &#34;bar&#34;:10}, {&#34;foo&#34;:1, &#34;bar&#34;:1}], [{&#34;foo&#34;:3, &#34;bar&#34;:100}]]</td>
</tr>
</table>
@@ -3264,16 +3233,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="min,max,min_by(path_exp),max_by(path_exp)">
<h3>
-
-<code>min</code>, <code>max</code>, <code>min_by(path_exp)</code>, <code>max_by(path_exp)</code>
-
+ <code>min</code>, <code>max</code>, <code>min_by(path_exp)</code>, <code>max_by(path_exp)</code>
</h3>
-
-<p>Find the minimum or maximum element of the input array.</p>
-
-<p>The <code>min_by(path_exp)</code> and <code>max_by(path_exp)</code> functions allow you to specify a particular field or property to examine, e.g. <code>min_by(.foo)</code> finds the object with the smallest <code>foo</code> field.</p>
-
+ <p>Find the minimum or maximum element of the input array.</p>
+<p>The <code>min_by(path_exp)</code> and <code>max_by(path_exp)</code> functions allow
+you to specify a particular field or property to examine, e.g.
+<code>min_by(.foo)</code> finds the object with the smallest <code>foo</code> field.</p>
<div>
@@ -3300,14 +3266,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'max_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:1, &quot;bar&quot;:14}, {&quot;foo&quot;:2, &quot;bar&quot;:3}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:1, &#34;bar&#34;:14}, {&#34;foo&#34;:2, &#34;bar&#34;:3}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;:2, &quot;bar&quot;:3}</td>
+ <td>{&#34;foo&#34;:2, &#34;bar&#34;:3}</td>
</tr>
</table>
@@ -3319,16 +3285,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="unique,unique_by(path_exp)">
<h3>
-
-<code>unique</code>, <code>unique_by(path_exp)</code>
-
+ <code>unique</code>, <code>unique_by(path_exp)</code>
</h3>
-
-<p>The <code>unique</code> function takes as input an array and produces an array of the same elements, in sorted order, with duplicates removed.</p>
-
-<p>The <code>unique_by(path_exp)</code> function will keep only one element for each value obtained by applying the argument. Think of it as making an array by taking one element out of every group produced by <code>group</code>.</p>
-
+ <p>The <code>unique</code> function takes as input an array and produces
+an array of the same elements, in sorted order, with
+duplicates removed.</p>
+<p>The <code>unique_by(path_exp)</code> function will keep only one element
+for each value obtained by applying the argument. Think of it
+as making an array by taking one element out of every group
+produced by <code>group</code>.</p>
<div>
@@ -3355,28 +3321,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'unique_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;: 1, &quot;bar&quot;: 2}, {&quot;foo&quot;: 1, &quot;bar&quot;: 3}, {&quot;foo&quot;: 4, &quot;bar&quot;: 5}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;: 1, &#34;bar&#34;: 2}, {&#34;foo&#34;: 1, &#34;bar&#34;: 3}, {&#34;foo&#34;: 4, &#34;bar&#34;: 5}]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;foo&quot;: 1, &quot;bar&quot;: 2}, {&quot;foo&quot;: 4, &quot;bar&quot;: 5}]</td>
+ <td>[{&#34;foo&#34;: 1, &#34;bar&#34;: 2}, {&#34;foo&#34;: 4, &#34;bar&#34;: 5}]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'unique_by(length)'</td></tr>
- <tr><th>Input</th><td>[&quot;chunky&quot;, &quot;bacon&quot;, &quot;kitten&quot;, &quot;cicada&quot;, &quot;asparagus&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;chunky&#34;, &#34;bacon&#34;, &#34;kitten&#34;, &#34;cicada&#34;, &#34;asparagus&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;bacon&quot;, &quot;chunky&quot;, &quot;asparagus&quot;]</td>
+ <td>[&#34;bacon&#34;, &#34;chunky&#34;, &#34;asparagus&#34;]</td>
</tr>
</table>
@@ -3388,14 +3354,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="reverse">
<h3>
-
-<code>reverse</code>
-
+ <code>reverse</code>
</h3>
-
-<p>This function reverses an array.</p>
-
+ <p>This function reverses an array.</p>
<div>
@@ -3427,14 +3389,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="contains(element)">
<h3>
-
-<code>contains(element)</code>
-
+ <code>contains(element)</code>
</h3>
-
-<p>The filter <code>contains(b)</code> will produce true if b is completely contained within the input. A string B is contained in a string A if B is a substring of A. An array B is contained in an array A if all elements in B are contained in any element in A. An object B is contained in object A if all of the values in B are contained in the value in A with the same key. All other types are assumed to be contained in each other if they are equal.</p>
-
+ <p>The filter <code>contains(b)</code> will produce true if b is
+completely contained within the input. A string B is
+contained in a string A if B is a substring of A. An array B
+is contained in an array A if all elements in B are
+contained in any element in A. An object B is contained in
+object A if all of the values in B are contained in the
+value in A with the same key. All other types are assumed to
+be contained in each other if they are equal.</p>
<div>
@@ -3446,8 +3411,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example49" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'contains(&quot;bar&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foobar&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains(&#34;bar&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foobar&#34;</td></tr>
<tr>
@@ -3460,8 +3425,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'contains([&quot;baz&quot;, &quot;bar&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains([&#34;baz&#34;, &#34;bar&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;]</td></tr>
<tr>
@@ -3474,8 +3439,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'contains([&quot;bazzzzz&quot;, &quot;bar&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains([&#34;bazzzzz&#34;, &#34;bar&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;]</td></tr>
<tr>
@@ -3489,7 +3454,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'contains({foo: 12, bar: [{barp: 12}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]}</td></tr>
<tr>
@@ -3503,7 +3468,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'contains({foo: 12, bar: [{barp: 15}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]}</td></tr>
<tr>
@@ -3522,14 +3487,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="indices(s)">
<h3>
-
-<code>indices(s)</code>
-
+ <code>indices(s)</code>
</h3>
-
-<p>Outputs an array containing the indices in <code>.</code> where <code>s</code> occurs. The input may be an array, in which case if <code>s</code> is an array then the indices output will be those where all elements in <code>.</code> match those of <code>s</code>.</p>
-
+ <p>Outputs an array containing the indices in <code>.</code> where <code>s</code>
+occurs. The input may be an array, in which case if <code>s</code> is an
+array then the indices output will be those where all elements
+in <code>.</code> match those of <code>s</code>.</p>
<div>
@@ -3541,8 +3505,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example50" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'indices(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a,b, cd, efg, hijk&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'indices(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a,b, cd, efg, hijk&#34;</td></tr>
<tr>
@@ -3589,14 +3553,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="index(s),rindex(s)">
<h3>
-
-<code>index(s)</code>, <code>rindex(s)</code>
-
+ <code>index(s)</code>, <code>rindex(s)</code>
</h3>
-
-<p>Outputs the index of the first (<code>index</code>) or last (<code>rindex</code>) occurrence of <code>s</code> in the input.</p>
-
+ <p>Outputs the index of the first (<code>index</code>) or last (<code>rindex</code>)
+occurrence of <code>s</code> in the input.</p>
<div>
@@ -3608,8 +3569,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example51" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'index(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a,b, cd, efg, hijk&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'index(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a,b, cd, efg, hijk&#34;</td></tr>
<tr>
@@ -3622,8 +3583,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'rindex(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a,b, cd, efg, hijk&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'rindex(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a,b, cd, efg, hijk&#34;</td></tr>
<tr>
@@ -3642,14 +3603,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="inside">
<h3>
-
-<code>inside</code>
-
+ <code>inside</code>
</h3>
-
-<p>The filter <code>inside(b)</code> will produce true if the input is completely contained within b. It is, essentially, an inversed version of <code>contains</code>.</p>
-
+ <p>The filter <code>inside(b)</code> will produce true if the input is
+completely contained within b. It is, essentially, an
+inversed version of <code>contains</code>.</p>
<div>
@@ -3661,8 +3620,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example52" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'inside(&quot;foobar&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;bar&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside(&#34;foobar&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;bar&#34;</td></tr>
<tr>
@@ -3675,8 +3634,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'inside([&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;baz&quot;, &quot;bar&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside([&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;baz&#34;, &#34;bar&#34;]</td></tr>
<tr>
@@ -3689,8 +3648,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'inside([&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;bazzzzz&quot;, &quot;bar&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside([&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;bazzzzz&#34;, &#34;bar&#34;]</td></tr>
<tr>
@@ -3703,8 +3662,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'inside({&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;: [{&quot;barp&quot;: 12}]}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside({&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]})'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;: [{&#34;barp&#34;: 12}]}</td></tr>
<tr>
@@ -3717,8 +3676,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'inside({&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;: [{&quot;barp&quot;: 15}]}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside({&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]})'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;: [{&#34;barp&#34;: 15}]}</td></tr>
<tr>
@@ -3737,14 +3696,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="startswith(str)">
<h3>
-
-<code>startswith(str)</code>
-
+ <code>startswith(str)</code>
</h3>
-
-<p>Outputs <code>true</code> if . starts with the given string argument.</p>
-
+ <p>Outputs <code>true</code> if . starts with the given string argument.</p>
<div>
@@ -3756,8 +3711,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example53" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|startswith(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;fo&quot;, &quot;foo&quot;, &quot;barfoo&quot;, &quot;foobar&quot;, &quot;barfoob&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|startswith(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;fo&#34;, &#34;foo&#34;, &#34;barfoo&#34;, &#34;foobar&#34;, &#34;barfoob&#34;]</td></tr>
<tr>
@@ -3776,14 +3731,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="endswith(str)">
<h3>
-
-<code>endswith(str)</code>
-
+ <code>endswith(str)</code>
</h3>
-
-<p>Outputs <code>true</code> if . ends with the given string argument.</p>
-
+ <p>Outputs <code>true</code> if . ends with the given string argument.</p>
<div>
@@ -3795,8 +3746,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example54" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|endswith(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;barfoo&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|endswith(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;barfoo&#34;]</td></tr>
<tr>
@@ -3815,14 +3766,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="combinations,combinations(n)">
<h3>
-
-<code>combinations</code>, <code>combinations(n)</code>
-
+ <code>combinations</code>, <code>combinations(n)</code>
</h3>
-
-<p>Outputs all combinations of the elements of the arrays in the input array. If given an argument <code>n</code>, it outputs all combinations of <code>n</code> repetitions of the input array.</p>
-
+ <p>Outputs all combinations of the elements of the arrays in the
+input array. If given an argument <code>n</code>, it outputs all combinations
+of <code>n</code> repetitions of the input array.</p>
<div>
@@ -3910,14 +3859,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="ltrimstr(str)">
<h3>
-
-<code>ltrimstr(str)</code>
-
+ <code>ltrimstr(str)</code>
</h3>
-
-<p>Outputs its input with the given prefix string removed, if it starts with it.</p>
-
+ <p>Outputs its input with the given prefix string removed, if it
+starts with it.</p>
<div>
@@ -3929,15 +3875,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example56" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|ltrimstr(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;fo&quot;, &quot;foo&quot;, &quot;barfoo&quot;, &quot;foobar&quot;, &quot;afoo&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|ltrimstr(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;fo&#34;, &#34;foo&#34;, &#34;barfoo&#34;, &#34;foobar&#34;, &#34;afoo&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;fo&quot;,&quot;&quot;,&quot;barfoo&quot;,&quot;bar&quot;,&quot;afoo&quot;]</td>
+ <td>[&#34;fo&#34;,&#34;&#34;,&#34;barfoo&#34;,&#34;bar&#34;,&#34;afoo&#34;]</td>
</tr>
</table>
@@ -3949,14 +3895,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="rtrimstr(str)">
<h3>
-
-<code>rtrimstr(str)</code>
-
+ <code>rtrimstr(str)</code>
</h3>
-
-<p>Outputs its input with the given suffix string removed, if it ends with it.</p>
-
+ <p>Outputs its input with the given suffix string removed, if it
+ends with it.</p>
<div>
@@ -3968,15 +3911,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example57" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|rtrimstr(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;fo&quot;, &quot;foo&quot;, &quot;barfoo&quot;, &quot;foobar&quot;, &quot;foob&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|rtrimstr(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;fo&#34;, &#34;foo&#34;, &#34;barfoo&#34;, &#34;foobar&#34;, &#34;foob&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;fo&quot;,&quot;&quot;,&quot;bar&quot;,&quot;foobar&quot;,&quot;foob&quot;]</td>
+ <td>[&#34;fo&#34;,&#34;&#34;,&#34;bar&#34;,&#34;foobar&#34;,&#34;foob&#34;]</td>
</tr>
</table>
@@ -3988,14 +3931,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="explode">
<h3>
-
-<code>explode</code>
-
+ <code>explode</code>
</h3>
-
-<p>Converts an input string into an array of the string’s codepoint numbers.</p>
-
+ <p>Converts an input string into an array of the string's
+codepoint numbers.</p>
<div>
@@ -4008,7 +3948,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'explode'</td></tr>
- <tr><th>Input</th><td>&quot;foobar&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;foobar&#34;</td></tr>
<tr>
@@ -4027,14 +3967,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="implode">
<h3>
-
-<code>implode</code>
-
+ <code>implode</code>
</h3>
-
-<p>The inverse of explode.</p>
-
+ <p>The inverse of explode.</p>
<div>
@@ -4054,7 +3990,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;ABC&quot;</td>
+ <td>&#34;ABC&#34;</td>
</tr>
</table>
@@ -4066,14 +4002,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="split(str)">
<h3>
-
-<code>split(str)</code>
-
+ <code>split(str)</code>
</h3>
-
-<p>Splits an input string on the separator argument.</p>
-
+ <p>Splits an input string on the separator argument.</p>
<div>
@@ -4085,15 +4017,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example60" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'split(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a, b,c,d, e, &quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'split(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a, b,c,d, e, &#34;</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;a&quot;,&quot;b,c,d&quot;,&quot;e&quot;,&quot;&quot;]</td>
+ <td>[&#34;a&#34;,&#34;b,c,d&#34;,&#34;e&#34;,&#34;&#34;]</td>
</tr>
</table>
@@ -4105,16 +4037,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="join(str)">
<h3>
-
-<code>join(str)</code>
-
+ <code>join(str)</code>
</h3>
-
-<p>Joins the array of elements given as input, using the argument as separator. It is the inverse of <code>split</code>: that is, running <code>split(&quot;foo&quot;) | join(&quot;foo&quot;)</code> over any input string returns said input string.</p>
-
-<p>Numbers and booleans in the input are converted to strings. Null values are treated as empty strings. Arrays and objects in the input are not supported.</p>
-
+ <p>Joins the array of elements given as input, using the
+argument as separator. It is the inverse of <code>split</code>: that is,
+running <code>split("foo") | join("foo")</code> over any input string
+returns said input string.</p>
+<p>Numbers and booleans in the input are converted to strings.
+Null values are treated as empty strings. Arrays and objects
+in the input are not supported.</p>
<div>
@@ -4126,29 +4058,29 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example61" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'join(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b,c,d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'join(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b,c,d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;a, b,c,d, e&quot;</td>
+ <td>&#34;a, b,c,d, e&#34;</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'join(&quot; &quot;)'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,1,2.3,true,null,false]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'join(&#34; &#34;)'</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,1,2.3,true,null,false]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;a 1 2.3 true false&quot;</td>
+ <td>&#34;a 1 2.3 true false&#34;</td>
</tr>
</table>
@@ -4160,30 +4092,26 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="ascii_downcase,ascii_upcase">
<h3>
-
-<code>ascii_downcase</code>, <code>ascii_upcase</code>
-
+ <code>ascii_downcase</code>, <code>ascii_upcase</code>
</h3>
-
-<p>Emit a copy of the input string with its alphabetic characters (a-z and A-Z) converted to the specified case.</p>
-
+ <p>Emit a copy of the input string with its alphabetic characters (a-z and A-Z)
+converted to the specified case.</p>
</section>
<section id="while(cond;update)">
<h3>
-
-<code>while(cond; update)</code>
-
+ <code>while(cond; update)</code>
</h3>
-
-<p>The <code>while(cond; update)</code> function allows you to repeatedly apply an update to <code>.</code> until <code>cond</code> is false.</p>
-
-<p>Note that <code>while(cond; update)</code> is internally defined as a recursive jq function. Recursive calls within <code>while</code> will not consume additional memory if <code>update</code> produces at most one output for each input. See advanced topics below.</p>
-
+ <p>The <code>while(cond; update)</code> function allows you to repeatedly
+apply an update to <code>.</code> until <code>cond</code> is false.</p>
+<p>Note that <code>while(cond; update)</code> is internally defined as a
+recursive jq function. Recursive calls within <code>while</code> will
+not consume additional memory if <code>update</code> produces at most one
+output for each input. See advanced topics below.</p>
<div>
@@ -4215,16 +4143,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="until(cond;next)">
<h3>
-
-<code>until(cond; next)</code>
-
+ <code>until(cond; next)</code>
</h3>
-
-<p>The <code>until(cond; next)</code> function allows you to repeatedly apply the expression <code>next</code>, initially to <code>.</code> then to its own output, until <code>cond</code> is true. For example, this can be used to implement a factorial function (see below).</p>
-
-<p>Note that <code>until(cond; next)</code> is internally defined as a recursive jq function. Recursive calls within <code>until()</code> will not consume additional memory if <code>next</code> produces at most one output for each input. See advanced topics below.</p>
-
+ <p>The <code>until(cond; next)</code> function allows you to repeatedly
+apply the expression <code>next</code>, initially to <code>.</code> then to its own
+output, until <code>cond</code> is true. For example, this can be used
+to implement a factorial function (see below).</p>
+<p>Note that <code>until(cond; next)</code> is internally defined as a
+recursive jq function. Recursive calls within <code>until()</code> will
+not consume additional memory if <code>next</code> produces at most one
+output for each input. See advanced topics below.</p>
<div>
@@ -4256,36 +4185,41 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="recurse(f),recurse,recurse(f;condition),recurse_down">
<h3>
-
-<code>recurse(f)</code>, <code>recurse</code>, <code>recurse(f; condition)</code>, <code>recurse_down</code>
-
+ <code>recurse(f)</code>, <code>recurse</code>, <code>recurse(f; condition)</code>, <code>recurse_down</code>
</h3>
-
-<p>The <code>recurse(f)</code> function allows you to search through a recursive structure, and extract interesting data from all levels. Suppose your input represents a filesystem:</p>
-
-<pre><code>{&quot;name&quot;: &quot;/&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/bin&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/bin/ls&quot;, &quot;children&quot;: []},
- {&quot;name&quot;: &quot;/bin/sh&quot;, &quot;children&quot;: []}]},
- {&quot;name&quot;: &quot;/home&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/home/stephen&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/home/stephen/jq&quot;, &quot;children&quot;: []}]}]}]}</code></pre>
-
-<p>Now suppose you want to extract all of the filenames present. You need to retrieve <code>.name</code>, <code>.children[].name</code>, <code>.children[].children[].name</code>, and so on. You can do this with:</p>
-
-<pre><code>recurse(.children[]) | .name</code></pre>
-
-<p>When called without an argument, <code>recurse</code> is equivalent to <code>recurse(.[]?)</code>.</p>
-
-<p><code>recurse(f)</code> is identical to <code>recurse(f; . != null)</code> and can be used without concerns about recursion depth.</p>
-
-<p><code>recurse(f; condition)</code> is a generator which begins by emitting . and then emits in turn .|f, .|f|f, .|f|f|f, … so long as the computed value satisfies the condition. For example, to generate all the integers, at least in principle, one could write <code>recurse(.+1; true)</code>.</p>
-
-<p>For legacy reasons, <code>recurse_down</code> exists as an alias to calling <code>recurse</code> without arguments. This alias is considered <em>deprecated</em> and will be removed in the next major release.</p>
-
-<p>The recursive calls in <code>recurse</code> will not consume additional memory whenever <code>f</code> produces at most a single output for each input.</p>
-
+ <p>The <code>recurse(f)</code> function allows you to search through a
+recursive structure, and extract interesting data from all
+levels. Suppose your input represents a filesystem:</p>
+<pre><code>{"name": "/", "children": [
+ {"name": "/bin", "children": [
+ {"name": "/bin/ls", "children": []},
+ {"name": "/bin/sh", "children": []}]},
+ {"name": "/home", "children": [
+ {"name": "/home/stephen", "children": [
+ {"name": "/home/stephen/jq", "children": []}]}]}]}
+</code></pre>
+<p>Now suppose you want to extract all of the filenames
+present. You need to retrieve <code>.name</code>, <code>.children[].name</code>,
+<code>.children[].children[].name</code>, and so on. You can do this
+with:</p>
+<pre><code>recurse(.children[]) | .name
+</code></pre>
+<p>When called without an argument, <code>recurse</code> is equivalent to
+<code>recurse(.[]?)</code>.</p>
+<p><code>recurse(f)</code> is identical to <code>recurse(f; . != null)</code> and can be
+used without concerns about recursion depth.</p>
+<p><code>recurse(f; condition)</code> is a generator which begins by
+emitting . and then emits in turn .|f, .|f|f, .|f|f|f, ... so long
+as the computed value satisfies the condition. For example,
+to generate all the integers, at least in principle, one
+could write <code>recurse(.+1; true)</code>.</p>
+<p>For legacy reasons, <code>recurse_down</code> exists as an alias to
+calling <code>recurse</code> without arguments. This alias is considered
+<em>deprecated</em> and will be removed in the next major release.</p>
+<p>The recursive calls in <code>recurse</code> will not consume additional
+memory whenever <code>f</code> produces at most a single output for each
+input.</p>
<div>
@@ -4298,49 +4232,49 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'recurse(.foo[])'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;:[{&quot;foo&quot;: []}, {&quot;foo&quot;:[{&quot;foo&quot;:[]}]}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;:[{&#34;foo&#34;: []}, {&#34;foo&#34;:[{&#34;foo&#34;:[]}]}]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;:[{&quot;foo&quot;:[]},{&quot;foo&quot;:[{&quot;foo&quot;:[]}]}]}</td>
+ <td>{&#34;foo&#34;:[{&#34;foo&#34;:[]},{&#34;foo&#34;:[{&#34;foo&#34;:[]}]}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[]}</td>
+ <td>{&#34;foo&#34;:[]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[{&quot;foo&quot;:[]}]}</td>
+ <td>{&#34;foo&#34;:[{&#34;foo&#34;:[]}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[]}</td>
+ <td>{&#34;foo&#34;:[]}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'recurse'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:0,&quot;b&quot;:[1]}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:0,&#34;b&#34;:[1]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;:0,&quot;b&quot;:[1]}</td>
+ <td>{&#34;a&#34;:0,&#34;b&#34;:[1]}</td>
</tr>
<tr>
@@ -4401,14 +4335,20 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="walk(f)">
<h3>
-
-<code>walk(f)</code>
-
+ <code>walk(f)</code>
</h3>
-
-<p>The <code>walk(f)</code> function applies f recursively to every component of the input entity. When an array is encountered, f is first applied to its elements and then to the array itself; when an object is encountered, f is first applied to all the values and then to the object. In practice, f will usually test the type of its input, as illustrated in the following examples. The first example highlights the usefulness of processing the elements of an array of arrays before processing the array itself. The second example shows how all the keys of all the objects within the input can be considered for alteration.</p>
-
+ <p>The <code>walk(f)</code> function applies f recursively to every
+component of the input entity. When an array is
+encountered, f is first applied to its elements and then to
+the array itself; when an object is encountered, f is first
+applied to all the values and then to the object. In
+practice, f will usually test the type of its input, as
+illustrated in the following examples. The first example
+highlights the usefulness of processing the elements of an
+array of arrays before processing the array itself. The second
+example shows how all the keys of all the objects within the
+input can be considered for alteration.</p>
<div>
@@ -4420,7 +4360,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example65" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'walk(if type == &quot;array&quot; then sort else . end)'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'walk(if type == &#34;array&#34; then sort else . end)'</td></tr>
<tr><th>Input</th><td>[[4, 1, 7], [8, 5, 2], [3, 6, 9]]</td></tr>
@@ -4434,15 +4374,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'walk( if type == &quot;object&quot; then with_entries( .key |= sub( &quot;^_+&quot;; &quot;&quot;) ) else . end )'</td></tr>
- <tr><th>Input</th><td>[ { &quot;_a&quot;: { &quot;__b&quot;: 2 } } ]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'walk( if type == &#34;object&#34; then with_entries( .key |= sub( &#34;^_+&#34;; &#34;&#34;) ) else . end )'</td></tr>
+ <tr><th>Input</th><td>[ { &#34;_a&#34;: { &#34;__b&#34;: 2 } } ]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;a&quot;:{&quot;b&quot;:2}}]</td>
+ <td>[{&#34;a&#34;:{&#34;b&#34;:2}}]</td>
</tr>
</table>
@@ -4454,18 +4394,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="$ENV,env">
<h3>
-
-<code>$ENV</code>, <code>env</code>
-
+ <code>$ENV</code>, <code>env</code>
</h3>
-
-<p><code>$ENV</code> is an object representing the environment variables as set when the jq program started.</p>
-
-<p><code>env</code> outputs an object representing jq’s current environment.</p>
-
-<p>At the moment there is no builtin for setting environment variables.</p>
-
+ <p><code>$ENV</code> is an object representing the environment variables as
+set when the jq program started.</p>
+<p><code>env</code> outputs an object representing jq's current environment.</p>
+<p>At the moment there is no builtin for setting environment
+variables.</p>
<div>
@@ -4485,7 +4421,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;less&quot;</td>
+ <td>&#34;less&#34;</td>
</tr>
</table>
@@ -4499,7 +4435,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;less&quot;</td>
+ <td>&#34;less&#34;</td>
</tr>
</table>
@@ -4511,14 +4447,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="transpose">
<h3>
-
-<code>transpose</code>
-
+ <code>transpose</code>
</h3>
-
-<p>Transpose a possibly jagged matrix (an array of arrays). Rows are padded with nulls so the result is always rectangular.</p>
-
+ <p>Transpose a possibly jagged matrix (an array of arrays).
+Rows are padded with nulls so the result is always rectangular.</p>
<div>
@@ -4550,14 +4483,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="bsearch(x)">
<h3>
-
-<code>bsearch(x)</code>
-
+ <code>bsearch(x)</code>
</h3>
-
-<p>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.</p>
-
+ <p>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.</p>
<div>
@@ -4617,14 +4553,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="Stringinterpolation-\(foo)">
<h3>
-
-String interpolation - <code>\(foo)</code>
-
+ String interpolation - <code>\(foo)</code>
</h3>
-
-<p>Inside a string, you can put an expression inside parens after a backslash. Whatever the expression returns will be interpolated into the string.</p>
-
+ <p>Inside a string, you can put an expression inside parens
+after a backslash. Whatever the expression returns will be
+interpolated into the string.</p>
<div>
@@ -4636,7 +4570,7 @@ String interpolation - <code>\(foo)</code>
<div id="example69" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '&quot;The input was \(.), which is one less than \(.+1)&quot;'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '&#34;The input was \(.), which is one less than \(.+1)&#34;'</td></tr>
<tr><th>Input</th><td>42</td></tr>
@@ -4644,7 +4578,7 @@ String interpolation - <code>\(foo)</code>
<th>Output</th>
- <td>&quot;The input was 42, which is one less than 43&quot;</td>
+ <td>&#34;The input was 42, which is one less than 43&#34;</td>
</tr>
</table>
@@ -4656,14 +4590,13 @@ String interpolation - <code>\(foo)</code>
<section id="Convertto/fromJSON">
<h3>
-
-Convert to/from JSON
-
+ Convert to/from JSON
</h3>
-
-<p>The <code>tojson</code> and <code>fromjson</code> 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.</p>
-
+ <p>The <code>tojson</code> and <code>fromjson</code> 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.</p>
<div>
@@ -4676,42 +4609,42 @@ Convert to/from JSON
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|tostring]'</td></tr>
- <tr><th>Input</th><td>[1, &quot;foo&quot;, [&quot;foo&quot;]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;foo&#34;, [&#34;foo&#34;]]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;1&quot;,&quot;foo&quot;,&quot;[\&quot;foo\&quot;]&quot;]</td>
+ <td>[&#34;1&#34;,&#34;foo&#34;,&#34;[\&#34;foo\&#34;]&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|tojson]'</td></tr>
- <tr><th>Input</th><td>[1, &quot;foo&quot;, [&quot;foo&quot;]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;foo&#34;, [&#34;foo&#34;]]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;1&quot;,&quot;\&quot;foo\&quot;&quot;,&quot;[\&quot;foo\&quot;]&quot;]</td>
+ <td>[&#34;1&#34;,&#34;\&#34;foo\&#34;&#34;,&#34;[\&#34;foo\&#34;]&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|tojson|fromjson]'</td></tr>
- <tr><th>Input</th><td>[1, &quot;foo&quot;, [&quot;foo&quot;]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;foo&#34;, [&#34;foo&#34;]]</td></tr>
<tr>
<th>Output</th>
- <td>[1,&quot;foo&quot;,[&quot;foo&quot;]]</td>
+ <td>[1,&#34;foo&#34;,[&#34;foo&#34;]]</td>
</tr>
</table>
@@ -4723,80 +4656,76 @@ Convert to/from JSON
<section id="Formatstringsandescaping">
<h3>
-
-Format strings and escaping
-
+ Format strings and escaping
</h3>
-
-<p>The <code>@foo</code> syntax is used to format and escape strings, which is useful for building URLs, documents in a language like HTML or XML, and so forth. <code>@foo</code> can be used as a filter on its own, the possible escapings are:</p>
-
+ <p>The <code>@foo</code> syntax is used to format and escape strings,
+which is useful for building URLs, documents in a language
+like HTML or XML, and so forth. <code>@foo</code> can be used as a
+filter on its own, the possible escapings are:</p>
<ul>
-<li>
-<p><code>@text</code>:</p>
-
+<li><code>@text</code>:</li>
+</ul>
<p>Calls <code>tostring</code>, see that function for details.</p>
-</li>
-
-<li>
-<p><code>@json</code>:</p>
-
+<ul>
+<li><code>@json</code>:</li>
+</ul>
<p>Serializes the input as JSON.</p>
-</li>
-
-<li>
-<p><code>@html</code>:</p>
-
-<p>Applies HTML/XML escaping, by mapping the characters <code>&lt;&gt;&amp;'&quot;</code> to their entity equivalents <code>&amp;lt;</code>, <code>&amp;gt;</code>, <code>&amp;amp;</code>, <code>&amp;apos;</code>, <code>&amp;quot;</code>.</p>
-</li>
-
-<li>
-<p><code>@uri</code>:</p>
-
-<p>Applies percent-encoding, by mapping all reserved URI characters to a <code>%XX</code> sequence.</p>
-</li>
-
-<li>
-<p><code>@csv</code>:</p>
-
-<p>The input must be an array, and it is rendered as CSV with double quotes for strings, and quotes escaped by repetition.</p>
-</li>
-
-<li>
-<p><code>@tsv</code>:</p>
-
-<p>The input must be an array, and it is rendered as TSV (tab-separated values). Each input array will be printed as a single line. Fields are separated by a single tab (ascii <code>0x09</code>). Input characters line-feed (ascii <code>0x0a</code>), carriage-return (ascii <code>0x0d</code>), tab (ascii <code>0x09</code>) and backslash (ascii <code>0x5c</code>) will be output as escape sequences <code>\n</code>, <code>\r</code>, <code>\t</code>, <code>\\</code> respectively.</p>
-</li>
-
-<li>
-<p><code>@sh</code>:</p>
-
-<p>The input is escaped suitable for use in a command-line for a POSIX shell. If the input is an array, the output will be a series of space-separated strings.</p>
-</li>
-
-<li>
-<p><code>@base64</code>:</p>
-
+<ul>
+<li><code>@html</code>:</li>
+</ul>
+<p>Applies HTML/XML escaping, by mapping the characters
+ <code>&lt;&gt;&amp;'"</code> to their entity equivalents <code>&amp;lt;</code>, <code>&amp;gt;</code>,
+ <code>&amp;amp;</code>, <code>&amp;apos;</code>, <code>&amp;quot;</code>.</p>
+<ul>
+<li><code>@uri</code>:</li>
+</ul>
+<p>Applies percent-encoding, by mapping all reserved URI
+ characters to a <code>%XX</code> sequence.</p>
+<ul>
+<li><code>@csv</code>:</li>
+</ul>
+<p>The input must be an array, and it is rendered as CSV
+ with double quotes for strings, and quotes escaped by
+ repetition.</p>
+<ul>
+<li><code>@tsv</code>:</li>
+</ul>
+<p>The input must be an array, and it is rendered as TSV
+ (tab-separated values). Each input array will be printed as
+ a single line. Fields are separated by a single
+ tab (ascii <code>0x09</code>). Input characters line-feed (ascii <code>0x0a</code>),
+ carriage-return (ascii <code>0x0d</code>), tab (ascii <code>0x09</code>) and
+ backslash (ascii <code>0x5c</code>) will be output as escape sequences
+ <code>\n</code>, <code>\r</code>, <code>\t</code>, <code>\\</code> respectively.</p>
+<ul>
+<li><code>@sh</code>:</li>
+</ul>
+<p>The input is escaped suitable for use in a command-line
+ for a POSIX shell. If the input is an array, the output
+ will be a series of space-separated strings.</p>
+<ul>
+<li><code>@base64</code>:</li>
+</ul>
<p>The input is converted to base64 as specified by RFC 4648.</p>
-</li>
-
-<li>
-<p><code>@base64d</code>:</p>
-
-<p>The inverse of <code>@base64</code>, input is decoded as specified by RFC 4648. Note: If the decoded string is not UTF-8, the results are undefined.</p>
-</li>
+<ul>
+<li><code>@base64d</code>:</li>
</ul>
-
-<p>This syntax can be combined with string interpolation in a useful way. You can follow a <code>@foo</code> token with a string literal. The contents of the string literal will <em>not</em> be escaped. However, all interpolations made inside that string literal will be escaped. For instance,</p>
-
-<pre><code>@uri &quot;https://www.google.com/search?q=\(.search)&quot;</code></pre>
-
-<p>will produce the following output for the input <code>{&quot;search&quot;:&quot;what is jq?&quot;}</code>:</p>
-
-<pre><code>&quot;https://www.google.com/search?q=what%20is%20jq%3F&quot;</code></pre>
-
-<p>Note that the slashes, question mark, etc. in the URL are not escaped, as they were part of the string literal.</p>
-
+<p>The inverse of <code>@base64</code>, input is decoded as specified by RFC 4648.
+ Note\: If the decoded string is not UTF-8, the results are undefined.</p>
+<p>This syntax can be combined with string interpolation in a
+useful way. You can follow a <code>@foo</code> token with a string
+literal. The contents of the string literal will <em>not</em> be
+escaped. However, all interpolations made inside that string
+literal will be escaped. For instance,</p>
+<pre><code>@uri "https://www.google.com/search?q=\(.search)"
+</code></pre>
+<p>will produce the following output for the input
+<code>{"search":"what is jq?"}</code>:</p>
+<pre><code>"https://www.google.com/search?q=what%20is%20jq%3F"
+</code></pre>
+<p>Note that the slashes, question mark, etc. in the URL are
+not escaped, as they were part of the string literal.</p>
<div>
@@ -4809,56 +4738,56 @@ Format strings and escaping
<table>
<tr><th></th><td class="jqprogram">jq '@html'</td></tr>
- <tr><th>Input</th><td>&quot;This works if x &lt; y&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;This works if x &lt; y&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;This works if x &amp;lt; y&quot;</td>
+ <td>&#34;This works if x &amp;lt; y&#34;</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '@sh &quot;echo \(.)&quot;'</td></tr>
- <tr><th>Input</th><td>&quot;O'Hara's Ale&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq '@sh &#34;echo \(.)&#34;'</td></tr>
+ <tr><th>Input</th><td>&#34;O&#39;Hara&#39;s Ale&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;echo 'O'\\''Hara'\\''s Ale'&quot;</td>
+ <td>&#34;echo &#39;O&#39;\\&#39;&#39;Hara&#39;\\&#39;&#39;s Ale&#39;&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '@base64'</td></tr>
- <tr><th>Input</th><td>&quot;This is a message&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;This is a message&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;VGhpcyBpcyBhIG1lc3NhZ2U=&quot;</td>
+ <td>&#34;VGhpcyBpcyBhIG1lc3NhZ2U=&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '@base64d'</td></tr>
- <tr><th>Input</th><td>&quot;VGhpcyBpcyBhIG1lc3NhZ2U=&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;VGhpcyBpcyBhIG1lc3NhZ2U=&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;This is a message&quot;</td>
+ <td>&#34;This is a message&#34;</td>
</tr>
</table>
@@ -4870,38 +4799,55 @@ Format strings and escaping
<section id="Dates">
<h3>
-
-Dates
-
+ Dates
</h3>
-
-<p>jq provides some basic date handling functionality, with some high-level and low-level builtins. In all cases these builtins deal exclusively with time in UTC.</p>
-
-<p>The <code>fromdateiso8601</code> builtin parses datetimes in the ISO 8601 format to a number of seconds since the Unix epoch (1970-01-01T00:00:00Z). The <code>todateiso8601</code> builtin does the inverse.</p>
-
-<p>The <code>fromdate</code> builtin parses datetime strings. Currently <code>fromdate</code> only supports ISO 8601 datetime strings, but in the future it will attempt to parse datetime strings in more formats.</p>
-
+ <p>jq provides some basic date handling functionality, with some
+high-level and low-level builtins. In all cases these
+builtins deal exclusively with time in UTC.</p>
+<p>The <code>fromdateiso8601</code> builtin parses datetimes in the ISO 8601
+format to a number of seconds since the Unix epoch
+(1970-01-01T00:00:00Z). The <code>todateiso8601</code> builtin does the
+inverse.</p>
+<p>The <code>fromdate</code> builtin parses datetime strings. Currently
+<code>fromdate</code> only supports ISO 8601 datetime strings, but in the
+future it will attempt to parse datetime strings in more
+formats.</p>
<p>The <code>todate</code> builtin is an alias for <code>todateiso8601</code>.</p>
-
-<p>The <code>now</code> builtin outputs the current time, in seconds since the Unix epoch.</p>
-
-<p>Low-level jq interfaces to the C-library time functions are also provided: <code>strptime</code>, <code>strftime</code>, <code>strflocaltime</code>, <code>mktime</code>, <code>gmtime</code>, and <code>localtime</code>. Refer to your host operating system’s documentation for the format strings used by <code>strptime</code> and <code>strftime</code>. Note: these are not necessarily stable interfaces in jq, particularly as to their localization functionality.</p>
-
-<p>The <code>gmtime</code> builtin consumes a number of seconds since the Unix epoch and outputs a “broken down time” representation of Greenwhich Meridian time as an array of numbers representing (in this order): the year, the month (zero-based), the day of the month (one-based), the hour of the day, the minute of the hour, the second of the minute, the day of the week, and the day of the year – all one-based unless otherwise stated. The day of the week number may be wrong on some systems for dates before March 1st 1900, or after December 31 2099.</p>
-
-<p>The <code>localtime</code> builtin works like the <code>gmtime</code> builtin, but using the local timezone setting.</p>
-
-<p>The <code>mktime</code> builtin consumes “broken down time” representations of time output by <code>gmtime</code> and <code>strptime</code>.</p>
-
-<p>The <code>strptime(fmt)</code> builtin parses input strings matching the <code>fmt</code> argument. The output is in the “broken down time” representation consumed by <code>gmtime</code> and output by <code>mktime</code>.</p>
-
-<p>The <code>strftime(fmt)</code> builtin formats a time (GMT) with the given format. The <code>strflocaltime</code> does the same, but using the local timezone setting.</p>
-
-<p>The format strings for <code>strptime</code> and <code>strftime</code> are described in typical C library documentation. The format string for ISO 8601 datetime is <code>&quot;%Y-%m-%dT%H:%M:%SZ&quot;</code>.</p>
-
-<p>jq may not support some or all of this date functionality on some systems. In particular, the <code>%u</code> and <code>%j</code> specifiers for <code>strptime(fmt)</code> are not supported on macOS.</p>
-
+<p>The <code>now</code> builtin outputs the current time, in seconds since
+the Unix epoch.</p>
+<p>Low-level jq interfaces to the C-library time functions are
+also provided: <code>strptime</code>, <code>strftime</code>, <code>strflocaltime</code>,
+<code>mktime</code>, <code>gmtime</code>, and <code>localtime</code>. Refer to your host
+operating system's documentation for the format strings used
+by <code>strptime</code> and <code>strftime</code>. Note: these are not necessarily
+stable interfaces in jq, particularly as to their localization
+functionality.</p>
+<p>The <code>gmtime</code> builtin consumes a number of seconds since the
+Unix epoch and outputs a "broken down time" representation of
+Greenwhich Meridian time as an array of numbers representing
+(in this order): the year, the month (zero-based), the day of
+the month (one-based), the hour of the day, the minute of the
+hour, the second of the minute, the day of the week, and the
+day of the year -- all one-based unless otherwise stated. The
+day of the week number may be wrong on some systems for dates
+before March 1st 1900, or after December 31 2099.</p>
+<p>The <code>localtime</code> builtin works like the <code>gmtime</code> builtin, but
+using the local timezone setting.</p>
+<p>The <code>mktime</code> builtin consumes "broken down time"
+representations of time output by <code>gmtime</code> and <code>strptime</code>.</p>
+<p>The <code>strptime(fmt)</code> builtin parses input strings matching the
+<code>fmt</code> argument. The output is in the "broken down time"
+representation consumed by <code>gmtime</code> and output by <code>mktime</code>.</p>
+<p>The <code>strftime(fmt)</code> builtin formats a time (GMT) with the
+given format. The <code>strflocaltime</code> does the same, but using
+the local timezone setting.</p>
+<p>The format strings for <code>strptime</code> and <code>strftime</code> are described
+in typical C library documentation. The format string for ISO
+8601 datetime is <code>"%Y-%m-%dT%H:%M:%SZ"</code>.</p>
+<p>jq may not support some or all of this date functionality on
+some systems. In particular, the <code>%u</code> and <code>%j</code> specifiers for
+<code>strptime(fmt)</code> are not supported on macOS.</p>
<div>
@@ -4914,7 +4860,7 @@ Dates
<table>
<tr><th></th><td class="jqprogram">jq 'fromdate'</td></tr>
- <tr><th>Input</th><td>&quot;2015-03-05T23:51:47Z&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;2015-03-05T23:51:47Z&#34;</td></tr>
<tr>
@@ -4927,8 +4873,8 @@ Dates
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'strptime(&quot;%Y-%m-%dT%H:%M:%SZ&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;2015-03-05T23:51:47Z&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'strptime(&#34;%Y-%m-%dT%H:%M:%SZ&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;2015-03-05T23:51:47Z&#34;</td></tr>
<tr>
@@ -4941,8 +4887,8 @@ Dates
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'strptime(&quot;%Y-%m-%dT%H:%M:%SZ&quot;)|mktime'</td></tr>
- <tr><th>Input</th><td>&quot;2015-03-05T23:51:47Z&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'strptime(&#34;%Y-%m-%dT%H:%M:%SZ&#34;)|mktime'</td></tr>
+ <tr><th>Input</th><td>&#34;2015-03-05T23:51:47Z&#34;</td></tr>
<tr>
@@ -4961,66 +4907,58 @@ Dates
<section id="SQL-StyleOperators">
<h3>
-
-SQL-Style Operators
-
+ SQL-Style Operators
</h3>
-
-<p>jq provides a few SQL-style operators.</p>
-
+ <p>jq provides a few SQL-style operators.</p>
<ul>
-<li>
-<p>INDEX(stream; index_expression):</p>
-
-<p>This builtin produces an object whose keys are computed by the given index expression applied to each value from the given stream.</p>
-</li>
-
-<li>
-<p>JOIN($idx; stream; idx_expr; join_expr):</p>
-
-<p>This builtin joins the values from the given stream to the given index. The index’s keys are computed by applying the given index expression to each value from the given stream. An array of the value in the stream and the corresponding value from the index is fed to the given join expression to produce each result.</p>
-</li>
-
-<li>
-<p>JOIN($idx; stream; idx_expr):</p>
-
+<li>INDEX(stream; index_expression):</li>
+</ul>
+<p>This builtin produces an object whose keys are computed by
+ the given index expression applied to each value from the
+ given stream.</p>
+<ul>
+<li>JOIN($idx; stream; idx_expr; join_expr):</li>
+</ul>
+<p>This builtin joins the values from the given stream to the
+ given index. The index's keys are computed by applying the
+ given index expression to each value from the given stream.
+ An array of the value in the stream and the corresponding
+ value from the index is fed to the given join expression to
+ produce each result.</p>
+<ul>
+<li>JOIN($idx; stream; idx_expr):</li>
+</ul>
<p>Same as <code>JOIN($idx; stream; idx_expr; .)</code>.</p>
-</li>
-
-<li>
-<p>JOIN($idx; idx_expr):</p>
-
-<p>This builtin joins the input <code>.</code> to the given index, applying the given index expression to <code>.</code> to compute the index key. The join operation is as described above.</p>
-</li>
-
-<li>
-<p>IN(s):</p>
-
-<p>This builtin outputs <code>true</code> if <code>.</code> appears in the given stream, otherwise it outputs <code>false</code>.</p>
-</li>
-
-<li>
-<p>IN(source; s):</p>
-
-<p>This builtin outputs <code>true</code> if any value in the source stream appears in the second stream, otherwise it outputs <code>false</code>.</p>
-</li>
+<ul>
+<li>JOIN($idx; idx_expr):</li>
</ul>
-
+<p>This builtin joins the input <code>.</code> to the given index, applying
+ the given index expression to <code>.</code> to compute the index key.
+ The join operation is as described above.</p>
+<ul>
+<li>IN(s):</li>
+</ul>
+<p>This builtin outputs <code>true</code> if <code>.</code> appears in the given
+ stream, otherwise it outputs <code>false</code>.</p>
+<ul>
+<li>IN(source; s):</li>
+</ul>
+<p>This builtin outputs <code>true</code> if any value in the source stream
+ appears in the second stream, otherwise it outputs <code>false</code>.</p>
</section>
<section id="builtins">
<h3>
-
-<code>builtins</code>
-
+ <code>builtins</code>
</h3>
-
-<p>Returns a list of all builtin functions in the format <code>name/arity</code>. Since functions with the same name but different arities are considered separate functions, <code>all/0</code>, <code>all/1</code>, and <code>all/2</code> would all be present in the list.</p>
-
+ <p>Returns a list of all builtin functions in the format <code>name/arity</code>.
+Since functions with the same name but different arities are considered
+separate functions, <code>all/0</code>, <code>all/1</code>, and <code>all/2</code> would all be present
+in the list.</p>
</section>
@@ -5033,16 +4971,16 @@ SQL-Style Operators
<section id="==,!=">
<h3>
-
-<code>==</code>, <code>!=</code>
-
+ <code>==</code>, <code>!=</code>
</h3>
-
-<p>The expression ‘a == b’ will produce ‘true’ if the result of a and b are equal (that is, if they represent equivalent JSON documents) and ‘false’ otherwise. In particular, strings are never considered equal to numbers. If you’re coming from Javascript, jq’s == is like Javascript’s === - considering values equal only when they have the same type as well as the same value.</p>
-
-<p>!= is “not equal”, and ‘a != b’ returns the opposite value of ‘a == b’</p>
-
+ <p>The expression 'a == b' will produce 'true' if the result of a and b
+are equal (that is, if they represent equivalent JSON documents) and
+'false' otherwise. In particular, strings are never considered equal
+to numbers. If you're coming from Javascript, jq's == is like
+Javascript's === - considering values equal only when they have the
+same type as well as the same value.</p>
+<p>!= is "not equal", and 'a != b' returns the opposite value of 'a == b'</p>
<div>
@@ -5055,7 +4993,7 @@ SQL-Style Operators
<table>
<tr><th></th><td class="jqprogram">jq '.[] == 1'</td></tr>
- <tr><th>Input</th><td>[1, 1.0, &quot;1&quot;, &quot;banana&quot;]</td></tr>
+ <tr><th>Input</th><td>[1, 1.0, &#34;1&#34;, &#34;banana&#34;]</td></tr>
<tr>
@@ -5095,22 +5033,26 @@ SQL-Style Operators
<section id="if-then-else">
<h3>
-
-if-then-else
-
+ if-then-else
</h3>
-
-<p><code>if A then B else C end</code> will act the same as <code>B</code> if <code>A</code> produces a value other than false or null, but act the same as <code>C</code> otherwise.</p>
-
-<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 <code>if .name then A else B end</code>, you’ll need something more like <code>if (.name | length) &gt; 0 then A else
-B end</code> instead.</p>
-
-<p>If the condition <code>A</code> produces multiple results, then <code>B</code> is evaluated once for each result that is not false or null, and <code>C</code> is evaluated once for each false or null.</p>
-
+ <p><code>if A then B else C end</code> will act the same as <code>B</code> if <code>A</code>
+produces a value other than false or null, but act the same
+as <code>C</code> otherwise.</p>
+<p><code>if A then B end</code> is the same as <code>if A then B else . end</code>.
+That is, the <code>else</code> branch is optional, and if absent is the
+same as <code>.</code>.</p>
+<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 <code>if .name then A else B end</code>, you'll
+need something more like <code>if .name then A else B end</code> instead.</p>
+<p>If the condition <code>A</code> produces multiple results, then <code>B</code> is evaluated
+once for each result that is not false or null, and <code>C</code> is evaluated
+once for each false or null.</p>
<p>More cases can be added to an if using <code>elif A then B</code> syntax.</p>
-
<div>
@@ -5121,13 +5063,7 @@ B end</code> instead.</p>
<div id="example74" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'if . == 0 then
- &quot;zero&quot;
-elif . == 1 then
- &quot;one&quot;
-else
- &quot;many&quot;
-end'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'if . == 0 then &#34;zero&#34; elif . == 1 then &#34;one&#34; else &#34;many&#34; end'</td></tr>
<tr><th>Input</th><td>2</td></tr>
@@ -5135,7 +5071,7 @@ end'</td></tr>
<th>Output</th>
- <td>&quot;many&quot;</td>
+ <td>&#34;many&#34;</td>
</tr>
</table>
@@ -5145,19 +5081,17 @@ end'</td></tr>
</section>
- <section id=">,>=,<=,<">
+ <section id="&gt;,&gt;=,&lt;=,&lt;">
<h3>
-
-<code>&gt;, &gt;=, &lt;=, &lt;</code>
-
+ <code>&gt;, &gt;=, &lt;=, &lt;</code>
</h3>
-
-<p>The comparison operators <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;=</code>, <code>&lt;</code> 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).</p>
-
+ <p>The comparison operators <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;=</code>, <code>&lt;</code> 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).</p>
<p>The ordering is the same as that described for <code>sort</code>, above.</p>
-
<div>
@@ -5188,21 +5122,24 @@ end'</td></tr>
<section id="and/or/not">
<h3>
-
-and/or/not
-
+ and/or/not
</h3>
-
-<p>jq supports the normal Boolean operators and/or/not. They have the same standard of truth as if expressions - false and null are considered “false values”, and anything else is a “true value”.</p>
-
-<p>If an operand of one of these operators produces multiple results, the operator itself will produce a result for each input.</p>
-
-<p><code>not</code> is in fact a builtin function rather than an operator, so it is called as a filter to which things can be piped rather than with special syntax, as in <code>.foo and .bar |
+ <p>jq supports the normal Boolean operators and/or/not. They have the
+same standard of truth as if expressions - false and null are
+considered "false values", and anything else is a "true value".</p>
+<p>If an operand of one of these operators produces multiple
+results, the operator itself will produce a result for each input.</p>
+<p><code>not</code> is in fact a builtin function rather than an operator,
+so it is called as a filter to which things can be piped
+rather than with special syntax, as in <code>.foo and .bar |
not</code>.</p>
-
-<p>These three only produce the values “true” and “false”, and so are only useful for genuine Boolean operations, rather than the common Perl/Python/Ruby idiom of “value_that_may_be_null or default”. If you want to use this form of “or”, picking between two values rather than evaluating a condition, see the “//” operator below.</p>
-
+<p>These three only produce the values "true" and "false", and
+so are only useful for genuine Boolean operations, rather
+than the common Perl/Python/Ruby idiom of
+"value_that_may_be_null or default". If you want to use this
+form of "or", picking between two values rather than
+evaluating a condition, see the "//" operator below.</p>
<div>
@@ -5214,7 +5151,7 @@ not</code>.</p>
<div id="example76" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '42 and &quot;a string&quot;'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '42 and &#34;a string&#34;'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -5304,16 +5241,17 @@ not</code>.</p>
<section id="Alternativeoperator://">
<h3>
-
-Alternative operator: <code>//</code>
-
+ Alternative operator: <code>//</code>
</h3>
-
-<p>A filter of the form <code>a // b</code> produces the same results as <code>a</code>, if <code>a</code> produces results other than <code>false</code> and <code>null</code>. Otherwise, <code>a // b</code> produces the same results as <code>b</code>.</p>
-
-<p>This is useful for providing defaults: <code>.foo // 1</code> will evaluate to <code>1</code> if there’s no <code>.foo</code> element in the input. It’s similar to how <code>or</code> is sometimes used in Python (jq’s <code>or</code> operator is reserved for strictly Boolean operations).</p>
-
+ <p>A filter of the form <code>a // b</code> produces the same
+results as <code>a</code>, if <code>a</code> produces results other than <code>false</code>
+and <code>null</code>. Otherwise, <code>a // b</code> produces the same results as <code>b</code>.</p>
+<p>This is useful for providing defaults: <code>.foo // 1</code> will
+evaluate to <code>1</code> if there's no <code>.foo</code> element in the
+input. It's similar to how <code>or</code> is sometimes used in Python
+(jq's <code>or</code> operator is reserved for strictly Boolean
+operations).</p>
<div>
@@ -5326,7 +5264,7 @@ Alternative operator: <code>//</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo // 42'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 19}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 19}</td></tr>
<tr>
@@ -5359,17 +5297,16 @@ Alternative operator: <code>//</code>
<section id="try-catch">
<h3>
-
-try-catch
-
+ try-catch
</h3>
-
-<p>Errors can be caught by using <code>try EXP catch EXP</code>. The first expression is executed, and if it fails then the second is executed with the error message. The output of the handler, if any, is output as if it had been the output of the expression to try.</p>
-
+ <p>Errors can be caught by using <code>try EXP catch EXP</code>. The first
+expression is executed, and if it fails then the second is
+executed with the error message. The output of the handler,
+if any, is output as if it had been the output of the
+expression to try.</p>
<p>The <code>try EXP</code> form uses <code>empty</code> as the exception handler.</p>
-
<div>
@@ -5380,7 +5317,7 @@ try-catch
<div id="example78" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'try .a catch &quot;. is not an object&quot;'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'try .a catch &#34;. is not an object&#34;'</td></tr>
<tr><th>Input</th><td>true</td></tr>
@@ -5388,14 +5325,14 @@ try-catch
<th>Output</th>
- <td>&quot;. is not an object&quot;</td>
+ <td>&#34;. is not an object&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|try .a]'</td></tr>
- <tr><th>Input</th><td>[{}, true, {&quot;a&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{}, true, {&#34;a&#34;:1}]</td></tr>
<tr>
@@ -5408,7 +5345,7 @@ try-catch
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'try error(&quot;some exception&quot;) catch .'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'try error(&#34;some exception&#34;) catch .'</td></tr>
<tr><th>Input</th><td>true</td></tr>
@@ -5416,7 +5353,7 @@ try-catch
<th>Output</th>
- <td>&quot;some exception&quot;</td>
+ <td>&#34;some exception&#34;</td>
</tr>
</table>
@@ -5428,53 +5365,42 @@ try-catch
<section id="Breakingoutofcontrolstructures">
<h3>
-
-Breaking out of control structures
-
+ Breaking out of control structures
</h3>
-
-<p>A convenient use of try/catch is to break out of control structures like <code>reduce</code>, <code>foreach</code>, <code>while</code>, and so on.</p>
-
+ <p>A convenient use of try/catch is to break out of control
+structures like <code>reduce</code>, <code>foreach</code>, <code>while</code>, and so on.</p>
<p>For example:</p>
-
-<pre><code># Repeat an expression until it raises &quot;break&quot; as an
+<pre><code># Repeat an expression until it raises "break" as an
# error, then stop repeating without re-raising the error.
-# But if the error caught is not &quot;break&quot; then re-raise it.
-try repeat(exp) catch .==&quot;break&quot; then empty else error;</code></pre>
-
-<p>jq has a syntax for named lexical labels to “break” or “go (back) to”:</p>
-
-<pre><code>label $out | ... break $out ...</code></pre>
-
-<p>The <code>break $label_name</code> expression will cause the program to to act as though the nearest (to the left) <code>label $label_name</code> produced <code>empty</code>.</p>
-
-<p>The relationship between the <code>break</code> and corresponding <code>label</code> is lexical: the label has to be “visible” from the break.</p>
-
+# But if the error caught is not "break" then re-raise it.
+try repeat(exp) catch .=="break" then empty else error;
+</code></pre>
+<p>jq has a syntax for named lexical labels to "break" or "go (back) to":</p>
+<pre><code>label $out | ... break $out ...
+</code></pre>
+<p>The <code>break $label_name</code> expression will cause the program to
+to act as though the nearest (to the left) <code>label $label_name</code>
+produced <code>empty</code>.</p>
+<p>The relationship between the <code>break</code> and corresponding <code>label</code>
+is lexical: the label has to be "visible" from the break.</p>
<p>To break out of a <code>reduce</code>, for example:</p>
-
-<pre><code>label $out | reduce .[] as $item (null; if .==false then break $out else ... end)</code></pre>
-
+<pre><code>label $out | reduce .[] as $item (null; if .==false then break $out else ... end)
+</code></pre>
<p>The following jq program produces a syntax error:</p>
-
-<pre><code>break $out</code></pre>
-
+<pre><code>break $out
+</code></pre>
<p>because no label <code>$out</code> is visible.</p>
-
</section>
<section id="ErrorSuppression/OptionalOperator:?">
<h3>
-
-Error Suppression / Optional Operator: <code>?</code>
-
+ Error Suppression / Optional Operator: <code>?</code>
</h3>
-
-<p>The <code>?</code> operator, used as <code>EXP?</code>, is shorthand for <code>try EXP</code>.</p>
-
+ <p>The <code>?</code> operator, used as <code>EXP?</code>, is shorthand for <code>try EXP</code>.</p>
<div>
@@ -5487,7 +5413,7 @@ Error Suppression / Optional Operator: <code>?</code>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|(.a)?]'</td></tr>
- <tr><th>Input</th><td>[{}, true, {&quot;a&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{}, true, {&#34;a&#34;:1}]</td></tr>
<tr>
@@ -5508,71 +5434,50 @@ Error Suppression / Optional Operator: <code>?</code>
<section id="RegularexpressionsPCRE">
<h2>Regular expressions (PCRE)</h2>
-
-<p>jq uses the Oniguruma regular expression library, as do php, ruby, TextMate, Sublime Text, etc, so the description here will focus on jq specifics.</p>
-
-<p>The jq regex filters are defined so that they can be used using one of these patterns:</p>
-
+ <p>jq uses the Oniguruma regular expression library, as do php,
+ruby, TextMate, Sublime Text, etc, so the description here
+will focus on jq specifics.</p>
+<p>The jq regex filters are defined so that they can be used using
+one of these patterns:</p>
<pre><code>STRING | FILTER( REGEX )
STRING | FILTER( REGEX; FLAGS )
STRING | FILTER( [REGEX] )
-STRING | FILTER( [REGEX, FLAGS] )</code></pre>
-
+STRING | FILTER( [REGEX, FLAGS] )
+</code></pre>
<p>where:</p>
-
<ul>
<li>STRING, REGEX and FLAGS are jq strings and subject to jq string interpolation;</li>
-
<li>REGEX, after string interpolation, should be a valid PCRE regex;</li>
-
<li>FILTER is one of <code>test</code>, <code>match</code>, or <code>capture</code>, as described below.</li>
</ul>
-
<p>FLAGS is a string consisting of one of more of the supported flags:</p>
-
<ul>
<li><code>g</code> - Global search (find all matches, not just the first)</li>
-
<li><code>i</code> - Case insensitive search</li>
-
-<li><code>m</code> - Multi line mode (‘.’ will match newlines)</li>
-
+<li><code>m</code> - Multi line mode ('.' will match newlines)</li>
<li><code>n</code> - Ignore empty matches</li>
-
<li><code>p</code> - Both s and m modes are enabled</li>
-
-<li><code>s</code> - Single line mode (‘^’ -&gt; ‘\A’, ‘$’ -&gt; ‘\Z’)</li>
-
+<li><code>s</code> - Single line mode ('^' -&gt; '\A', '$' -&gt; '\Z')</li>
<li><code>l</code> - Find longest possible matches</li>
-
<li><code>x</code> - Extended regex format (ignore whitespace and comments)</li>
</ul>
-
<p>To match whitespace in an x pattern use an escape such as \s, e.g.</p>
-
<ul>
-<li>test( “a\sb”, “x” ).</li>
+<li>test( "a\sb", "x" ).</li>
</ul>
-
<p>Note that certain flags may also be specified within REGEX, e.g.</p>
-
<ul>
-<li>jq -n ‘(“test”, “TEst”, “teST”, “TEST”) | test( “(?i)te(?-i)st” )’</li>
+<li>jq -n '("test", "TEst", "teST", "TEST") | test( "(?i)te(?-i)st" )'</li>
</ul>
-
<p>evaluates to: true, true, false, false.</p>
-
<section id="test(val),test(regex;flags)">
<h3>
-
-<code>test(val)</code>, <code>test(regex; flags)</code>
-
+ <code>test(val)</code>, <code>test(regex; flags)</code>
</h3>
-
-<p>Like <code>match</code>, but does not return match objects, only <code>true</code> or <code>false</code> for whether or not the regex matches the input.</p>
-
+ <p>Like <code>match</code>, but does not return match objects, only <code>true</code> or <code>false</code>
+for whether or not the regex matches the input.</p>
<div>
@@ -5584,8 +5489,8 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<div id="example80" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'test(&quot;foo&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foo&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'test(&#34;foo&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foo&#34;</td></tr>
<tr>
@@ -5598,8 +5503,8 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[] | test(&quot;a b c # spaces are ignored&quot;; &quot;ix&quot;)'</td></tr>
- <tr><th>Input</th><td>[&quot;xabcd&quot;, &quot;ABC&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[] | test(&#34;a b c # spaces are ignored&#34;; &#34;ix&#34;)'</td></tr>
+ <tr><th>Input</th><td>[&#34;xabcd&#34;, &#34;ABC&#34;]</td></tr>
<tr>
@@ -5625,39 +5530,26 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<section id="match(val),match(regex;flags)">
<h3>
-
-<code>match(val)</code>, <code>match(regex; flags)</code>
-
+ <code>match(val)</code>, <code>match(regex; flags)</code>
</h3>
-
-<p><strong>match</strong> outputs an object for each match it finds. Matches have the following fields:</p>
-
+ <p><strong>match</strong> outputs an object for each match it finds. Matches have
+the following fields:</p>
<ul>
<li><code>offset</code> - offset in UTF-8 codepoints from the beginning of the input</li>
-
<li><code>length</code> - length in UTF-8 codepoints of the match</li>
-
<li><code>string</code> - the string that it matched</li>
-
<li><code>captures</code> - an array of objects representing capturing groups.</li>
</ul>
-
<p>Capturing group objects have the following fields:</p>
-
<ul>
<li><code>offset</code> - offset in UTF-8 codepoints from the beginning of the input</li>
-
<li><code>length</code> - length in UTF-8 codepoints of this capturing group</li>
-
<li><code>string</code> - the string that was captured</li>
-
<li><code>name</code> - the name of the capturing group (or <code>null</code> if it was unnamed)</li>
</ul>
-
<p>Capturing groups that did not match anything return an offset of -1</p>
-
<div>
@@ -5668,85 +5560,85 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<div id="example81" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'match(&quot;(abc)+&quot;; &quot;g&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;abc abc&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'match(&#34;(abc)+&#34;; &#34;g&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;abc abc&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;offset&quot;: 0, &quot;length&quot;: 3, &quot;string&quot;: &quot;abc&quot;, &quot;captures&quot;: [{&quot;offset&quot;: 0, &quot;length&quot;: 3, &quot;string&quot;: &quot;abc&quot;, &quot;name&quot;: null}]}</td>
+ <td>{&#34;offset&#34;: 0, &#34;length&#34;: 3, &#34;string&#34;: &#34;abc&#34;, &#34;captures&#34;: [{&#34;offset&#34;: 0, &#34;length&#34;: 3, &#34;string&#34;: &#34;abc&#34;, &#34;name&#34;: null}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;offset&quot;: 4, &quot;length&quot;: 3, &quot;string&quot;: &quot;abc&quot;, &quot;captures&quot;: [{&quot;offset&quot;: 4, &quot;length&quot;: 3, &quot;string&quot;: &quot;abc&quot;, &quot;name&quot;: null}]}</td>
+ <td>{&#34;offset&#34;: 4, &#34;length&#34;: 3, &#34;string&#34;: &#34;abc&#34;, &#34;captures&#34;: [{&#34;offset&#34;: 4, &#34;length&#34;: 3, &#34;string&#34;: &#34;abc&#34;, &#34;name&#34;: null}]}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'match(&quot;foo&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foo bar foo&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'match(&#34;foo&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foo bar foo&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;offset&quot;: 0, &quot;length&quot;: 3, &quot;string&quot;: &quot;foo&quot;, &quot;captures&quot;: []}</td>
+ <td>{&#34;offset&#34;: 0, &#34;length&#34;: 3, &#34;string&#34;: &#34;foo&#34;, &#34;captures&#34;: []}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'match([&quot;foo&quot;, &quot;ig&quot;])'</td></tr>
- <tr><th>Input</th><td>&quot;foo bar FOO&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'match([&#34;foo&#34;, &#34;ig&#34;])'</td></tr>
+ <tr><th>Input</th><td>&#34;foo bar FOO&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;offset&quot;: 0, &quot;length&quot;: 3, &quot;string&quot;: &quot;foo&quot;, &quot;captures&quot;: []}</td>
+ <td>{&#34;offset&#34;: 0, &#34;length&#34;: 3, &#34;string&#34;: &#34;foo&#34;, &#34;captures&#34;: []}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;offset&quot;: 8, &quot;length&quot;: 3, &quot;string&quot;: &quot;FOO&quot;, &quot;captures&quot;: []}</td>
+ <td>{&#34;offset&#34;: 8, &#34;length&#34;: 3, &#34;string&#34;: &#34;FOO&#34;, &#34;captures&#34;: []}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'match(&quot;foo (?&lt;bar123&gt;bar)? foo&quot;; &quot;ig&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foo bar foo foo foo&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'match(&#34;foo (?&lt;bar123&gt;bar)? foo&#34;; &#34;ig&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foo bar foo foo foo&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;offset&quot;: 0, &quot;length&quot;: 11, &quot;string&quot;: &quot;foo bar foo&quot;, &quot;captures&quot;: [{&quot;offset&quot;: 4, &quot;length&quot;: 3, &quot;string&quot;: &quot;bar&quot;, &quot;name&quot;: &quot;bar123&quot;}]}</td>
+ <td>{&#34;offset&#34;: 0, &#34;length&#34;: 11, &#34;string&#34;: &#34;foo bar foo&#34;, &#34;captures&#34;: [{&#34;offset&#34;: 4, &#34;length&#34;: 3, &#34;string&#34;: &#34;bar&#34;, &#34;name&#34;: &#34;bar123&#34;}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;offset&quot;: 12, &quot;length&quot;: 8, &quot;string&quot;: &quot;foo foo&quot;, &quot;captures&quot;: [{&quot;offset&quot;: -1, &quot;length&quot;: 0, &quot;string&quot;: null, &quot;name&quot;: &quot;bar123&quot;}]}</td>
+ <td>{&#34;offset&#34;: 12, &#34;length&#34;: 8, &#34;string&#34;: &#34;foo foo&#34;, &#34;captures&#34;: [{&#34;offset&#34;: -1, &#34;length&#34;: 0, &#34;string&#34;: null, &#34;name&#34;: &#34;bar123&#34;}]}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '[ match(&quot;.&quot;; &quot;g&quot;)] | length'</td></tr>
- <tr><th>Input</th><td>&quot;abc&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[ match(&#34;.&#34;; &#34;g&#34;)] | length'</td></tr>
+ <tr><th>Input</th><td>&#34;abc&#34;</td></tr>
<tr>
@@ -5765,14 +5657,12 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<section id="capture(val),capture(regex;flags)">
<h3>
-
-<code>capture(val)</code>, <code>capture(regex; flags)</code>
-
+ <code>capture(val)</code>, <code>capture(regex; flags)</code>
</h3>
-
-<p>Collects the named captures in a JSON object, with the name of each capture as the key, and the matched string as the corresponding value.</p>
-
+ <p>Collects the named captures in a JSON object, with the name
+of each capture as the key, and the matched string as the
+corresponding value.</p>
<div>
@@ -5784,15 +5674,15 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<div id="example82" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'capture(&quot;(?&lt;a&gt;[a-z]+)-(?&lt;n&gt;[0-9]+)&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;xyzzy-14&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'capture(&#34;(?&lt;a&gt;[a-z]+)-(?&lt;n&gt;[0-9]+)&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;xyzzy-14&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{ &quot;a&quot;: &quot;xyzzy&quot;, &quot;n&quot;: &quot;14&quot; }</td>
+ <td>{ &#34;a&#34;: &#34;xyzzy&#34;, &#34;n&#34;: &#34;14&#34; }</td>
</tr>
</table>
@@ -5804,70 +5694,61 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<section id="scan(regex),scan(regex;flags)">
<h3>
-
-<code>scan(regex)</code>, <code>scan(regex; flags)</code>
-
+ <code>scan(regex)</code>, <code>scan(regex; flags)</code>
</h3>
-
-<p>Emit a stream of the non-overlapping substrings of the input that match the regex in accordance with the flags, if any have been specified. If there is no match, the stream is empty. To capture all the matches for each input string, use the idiom <code>[ expr ]</code>, e.g. <code>[ scan(regex) ]</code>.</p>
-
+ <p>Emit a stream of the non-overlapping substrings of the input
+that match the regex in accordance with the flags, if any
+have been specified. If there is no match, the stream is empty.
+To capture all the matches for each input string, use the idiom
+<code>[ expr ]</code>, e.g. <code>[ scan(regex) ]</code>.</p>
</section>
<section id="split(regex;flags)">
<h3>
-
-<code>split(regex; flags)</code>
-
+ <code>split(regex; flags)</code>
</h3>
-
-<p>For backwards compatibility, <code>split</code> splits on a string, not a regex.</p>
-
+ <p>For backwards compatibility, <code>split</code> splits on a string, not a regex.</p>
</section>
<section id="splits(regex),splits(regex;flags)">
<h3>
-
-<code>splits(regex)</code>, <code>splits(regex; flags)</code>
-
+ <code>splits(regex)</code>, <code>splits(regex; flags)</code>
</h3>
-
-<p>These provide the same results as their <code>split</code> counterparts, but as a stream instead of an array.</p>
-
+ <p>These provide the same results as their <code>split</code> counterparts,
+but as a stream instead of an array.</p>
</section>
<section id="sub(regex;tostring)sub(regex;string;flags)">
<h3>
-
-<code>sub(regex; tostring)</code> <code>sub(regex; string; flags)</code>
-
+ <code>sub(regex; tostring)</code> <code>sub(regex; string; flags)</code>
</h3>
-
-<p>Emit the string obtained by replacing the first match of regex in the input string with <code>tostring</code>, after interpolation. <code>tostring</code> 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 <code>capture</code>) to <code>tostring</code>, so a reference to a captured variable named “x” would take the form: “(.x)”.</p>
-
+ <p>Emit the string obtained by replacing the first match of regex in the
+input string with <code>tostring</code>, after interpolation. <code>tostring</code> 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 <code>capture</code>) to <code>tostring</code>, so a reference to a captured
+variable named "x" would take the form: "(.x)".</p>
</section>
<section id="gsub(regex;string),gsub(regex;string;flags)">
<h3>
-
-<code>gsub(regex; string)</code>, <code>gsub(regex; string; flags)</code>
-
+ <code>gsub(regex; string)</code>, <code>gsub(regex; string; flags)</code>
</h3>
-
-<p><code>gsub</code> is like <code>sub</code> but all the non-overlapping occurrences of the regex are replaced by the string, after interpolation.</p>
-
+ <p><code>gsub</code> is like <code>sub</code> but all the non-overlapping occurrences of the regex are
+replaced by the string, after interpolation.</p>
</section>
@@ -5876,79 +5757,100 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<section id="Advancedfeatures">
<h2>Advanced features</h2>
-
-<p>Variables are an absolute necessity in most programming languages, but they’re relegated to an “advanced feature” in jq.</p>
-
-<p>In most languages, variables are the only means of passing around data. If you calculate a value, and you want to use it more than once, you’ll need to store it in a variable. To pass a value to another part of the program, you’ll need that part of the program to define a variable (as a function parameter, object member, or whatever) in which to place the data.</p>
-
-<p>It is also possible to define functions in jq, although this is is a feature whose biggest use is defining jq’s standard library (many jq functions such as <code>map</code> and <code>find</code> are in fact written in jq).</p>
-
-<p>jq has reduction operators, which are very powerful but a bit tricky. Again, these are mostly used internally, to define some useful bits of jq’s standard library.</p>
-
-<p>It may not be obvious at first, but jq is all about generators (yes, as often found in other languages). Some utilities are provided to help deal with generators.</p>
-
-<p>Some minimal I/O support (besides reading JSON from standard input, and writing JSON to standard output) is available.</p>
-
+ <p>Variables are an absolute necessity in most programming languages, but
+they're relegated to an "advanced feature" in jq.</p>
+<p>In most languages, variables are the only means of passing around
+data. If you calculate a value, and you want to use it more than once,
+you'll need to store it in a variable. To pass a value to another part
+of the program, you'll need that part of the program to define a
+variable (as a function parameter, object member, or whatever) in
+which to place the data.</p>
+<p>It is also possible to define functions in jq, although this is
+is a feature whose biggest use is defining jq's standard library
+(many jq functions such as <code>map</code> and <code>find</code> are in fact written
+in jq).</p>
+<p>jq has reduction operators, which are very powerful but a bit
+tricky. Again, these are mostly used internally, to define some
+useful bits of jq's standard library.</p>
+<p>It may not be obvious at first, but jq is all about generators
+(yes, as often found in other languages). Some utilities are
+provided to help deal with generators.</p>
+<p>Some minimal I/O support (besides reading JSON from standard
+input, and writing JSON to standard output) is available.</p>
<p>Finally, there is a module/library system.</p>
-
<section id="Variable/SymbolicBindingOperator:...as$identifier|...">
<h3>
-
-Variable / Symbolic Binding Operator: <code>... as $identifier | ...</code>
-
+ Variable / Symbolic Binding Operator: <code>... as $identifier | ...</code>
</h3>
-
-<p>In jq, all filters have an input and an output, so manual plumbing is not necessary to pass a value from one part of a program to the next. Many expressions, for instance <code>a + b</code>, pass their input to two distinct subexpressions (here <code>a</code> and <code>b</code> are both passed the same input), so variables aren’t usually necessary in order to use a value twice.</p>
-
-<p>For instance, calculating the average value of an array of numbers requires a few variables in most languages - at least one to hold the array, perhaps one for each element or for a loop counter. In jq, it’s simply <code>add / length</code> - the <code>add</code> expression is given the array and produces its sum, and the <code>length</code> expression is given the array and produces its length.</p>
-
-<p>So, there’s generally a cleaner way to solve most problems in jq than defining variables. Still, sometimes they do make things easier, so jq lets you define variables using <code>expression as $variable</code>. All variable names start with <code>$</code>. Here’s a slightly uglier version of the array-averaging example:</p>
-
-<pre><code>length as $array_length | add / $array_length</code></pre>
-
-<p>We’ll need a more complicated problem to find a situation where using variables actually makes our lives easier.</p>
-
-<p>Suppose we have an array of blog posts, with “author” and “title” fields, and another object which is used to map author usernames to real names. Our input looks like:</p>
-
-<pre><code>{&quot;posts&quot;: [{&quot;title&quot;: &quot;Frist psot&quot;, &quot;author&quot;: &quot;anon&quot;},
- {&quot;title&quot;: &quot;A well-written article&quot;, &quot;author&quot;: &quot;person1&quot;}],
- &quot;realnames&quot;: {&quot;anon&quot;: &quot;Anonymous Coward&quot;,
- &quot;person1&quot;: &quot;Person McPherson&quot;}}</code></pre>
-
-<p>We want to produce the posts with the author field containing a real name, as in:</p>
-
-<pre><code>{&quot;title&quot;: &quot;Frist psot&quot;, &quot;author&quot;: &quot;Anonymous Coward&quot;}
-{&quot;title&quot;: &quot;A well-written article&quot;, &quot;author&quot;: &quot;Person McPherson&quot;}</code></pre>
-
-<p>We use a variable, $names, to store the realnames object, so that we can refer to it later when looking up author usernames:</p>
-
-<pre><code>.realnames as $names | .posts[] | {title, author: $names[.author]}</code></pre>
-
-<p>The expression <code>exp as $x | ...</code> means: for each value of expression <code>exp</code>, run the rest of the pipeline with the entire original input, and with <code>$x</code> set to that value. Thus <code>as</code> functions as something of a foreach loop.</p>
-
-<p>Just as <code>{foo}</code> is a handy way of writing <code>{foo: .foo}</code>, so <code>{$foo}</code> is a handy way of writing <code>{foo:$foo}</code>.</p>
-
-<p>Multiple variables may be declared using a single <code>as</code> expression by providing a pattern that matches the structure of the input (this is known as “destructuring”):</p>
-
-<pre><code>. as {realnames: $names, posts: [$first, $second]} | ...</code></pre>
-
+ <p>In jq, all filters have an input and an output, so manual
+plumbing is not necessary to pass a value from one part of a program
+to the next. Many expressions, for instance <code>a + b</code>, pass their input
+to two distinct subexpressions (here <code>a</code> and <code>b</code> are both passed the
+same input), so variables aren't usually necessary in order to use a
+value twice.</p>
+<p>For instance, calculating the average value of an array of numbers
+requires a few variables in most languages - at least one to hold the
+array, perhaps one for each element or for a loop counter. In jq, it's
+simply <code>add / length</code> - the <code>add</code> expression is given the array and
+produces its sum, and the <code>length</code> expression is given the array and
+produces its length.</p>
+<p>So, there's generally a cleaner way to solve most problems in jq than
+defining variables. Still, sometimes they do make things easier, so jq
+lets you define variables using <code>expression as $variable</code>. All
+variable names start with <code>$</code>. Here's a slightly uglier version of the
+array-averaging example:</p>
+<pre><code>length as $array_length | add / $array_length
+</code></pre>
+<p>We'll need a more complicated problem to find a situation where using
+variables actually makes our lives easier.</p>
+<p>Suppose we have an array of blog posts, with "author" and "title"
+fields, and another object which is used to map author usernames to
+real names. Our input looks like:</p>
+<pre><code>{"posts": [{"title": "Frist psot", "author": "anon"},
+ {"title": "A well-written article", "author": "person1"}],
+ "realnames": {"anon": "Anonymous Coward",
+ "person1": "Person McPherson"}}
+</code></pre>
+<p>We want to produce the posts with the author field containing a real
+name, as in:</p>
+<pre><code>{"title": "Frist psot", "author": "Anonymous Coward"}
+{"title": "A well-written article", "author": "Person McPherson"}
+</code></pre>
+<p>We use a variable, $names, to store the realnames object, so that we
+can refer to it later when looking up author usernames:</p>
+<pre><code>.realnames as $names | .posts[] | {title, author: $names[.author]}
+</code></pre>
+<p>The expression <code>exp as $x | ...</code> means: for each value of expression
+<code>exp</code>, run the rest of the pipeline with the entire original input, and
+with <code>$x</code> set to that value. Thus <code>as</code> functions as something of a
+foreach loop.</p>
+<p>Just as <code>{foo}</code> is a handy way of writing <code>{foo: .foo}</code>, so
+<code>{$foo}</code> is a handy way of writing <code>{foo:$foo}</code>.</p>
+<p>Multiple variables may be declared using a single <code>as</code> expression by
+providing a pattern that matches the structure of the input
+(this is known as "destructuring"):</p>
+<pre><code>. as {realnames: $names, posts: [$first, $second]} | ...
+</code></pre>
<p>The variable declarations in array patterns (e.g., <code>. as
-[$first, $second]</code>) bind to the elements of the array in from the element at index zero on up, in order. When there is no value at the index for an array pattern element, <code>null</code> is bound to that variable.</p>
-
-<p>Variables are scoped over the rest of the expression that defines them, so</p>
-
-<pre><code>.realnames as $names | (.posts[] | {title, author: $names[.author]})</code></pre>
-
+[$first, $second]</code>) bind to the elements of the array in from
+the element at index zero on up, in order. When there is no
+value at the index for an array pattern element, <code>null</code> is
+bound to that variable.</p>
+<p>Variables are scoped over the rest of the expression that defines
+them, so</p>
+<pre><code>.realnames as $names | (.posts[] | {title, author: $names[.author]})
+</code></pre>
<p>will work, but</p>
-
-<pre><code>(.realnames as $names | .posts[]) | {title, author: $names[.author]}</code></pre>
-
-<p>won’t.</p>
-
-<p>For programming language theorists, it’s more accurate to say that jq variables are lexically-scoped bindings. In particular there’s no way to change the value of a binding; one can only setup a new binding with the same name, but which will not be visible where the old one was.</p>
-
+<pre><code>(.realnames as $names | .posts[]) | {title, author: $names[.author]}
+</code></pre>
+<p>won't.</p>
+<p>For programming language theorists, it's more accurate to
+say that jq variables are lexically-scoped bindings. In
+particular there's no way to change the value of a binding;
+one can only setup a new binding with the same name, but which
+will not be visible where the old one was.</p>
<div>
@@ -5961,7 +5863,7 @@ Variable / Symbolic Binding Operator: <code>... as $identifier | ...</code>
<table>
<tr><th></th><td class="jqprogram">jq '.bar as $x | .foo | . + $x'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;:10, &quot;bar&quot;:200}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;:10, &#34;bar&#34;:200}</td></tr>
<tr>
@@ -5989,7 +5891,7 @@ Variable / Symbolic Binding Operator: <code>... as $identifier | ...</code>
<table>
<tr><th></th><td class="jqprogram">jq '. as [$a, $b, {c: $c}] | $a + $b + $c'</td></tr>
- <tr><th>Input</th><td>[2, 3, {&quot;c&quot;: 4, &quot;d&quot;: 5}]</td></tr>
+ <tr><th>Input</th><td>[2, 3, {&#34;c&#34;: 4, &#34;d&#34;: 5}]</td></tr>
<tr>
@@ -6010,21 +5912,21 @@ Variable / Symbolic Binding Operator: <code>... as $identifier | ...</code>
<th>Output</th>
- <td>{&quot;a&quot;:0,&quot;b&quot;:null}</td>
+ <td>{&#34;a&#34;:0,&#34;b&#34;:null}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;a&quot;:0,&quot;b&quot;:1}</td>
+ <td>{&#34;a&#34;:0,&#34;b&#34;:1}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;a&quot;:2,&quot;b&quot;:1}</td>
+ <td>{&#34;a&#34;:2,&#34;b&#34;:1}</td>
</tr>
</table>
@@ -6036,35 +5938,35 @@ Variable / Symbolic Binding Operator: <code>... as $identifier | ...</code>
<section id="DestructuringAlternativeOperator:?//">
<h3>
-
-Destructuring Alternative Operator: <code>?//</code>
-
+ Destructuring Alternative Operator: <code>?//</code>
</h3>
-
-<p>The destructuring alternative operator provides a concise mechanism for destructuring an input that can take one of several forms.</p>
-
-<p>Suppose we have an API that returns a list of resources and events associated with them, and we want to get the user_id and timestamp of the first event for each resource. The API (having been clumsily converted from XML) will only wrap the events in an array if the resource has multiple events:</p>
-
-<pre><code>{&quot;resources&quot;: [{&quot;id&quot;: 1, &quot;kind&quot;: &quot;widget&quot;, &quot;events&quot;: {&quot;action&quot;: &quot;create&quot;, &quot;user_id&quot;: 1, &quot;ts&quot;: 13}},
- {&quot;id&quot;: 2, &quot;kind&quot;: &quot;widget&quot;, &quot;events&quot;: [{&quot;action&quot;: &quot;create&quot;, &quot;user_id&quot;: 1, &quot;ts&quot;: 14}, {&quot;action&quot;: &quot;destroy&quot;, &quot;user_id&quot;: 1, &quot;ts&quot;: 15}]}]}</code></pre>
-
+ <p>The destructuring alternative operator provides a concise mechanism
+for destructuring an input that can take one of several forms.</p>
+<p>Suppose we have an API that returns a list of resources and events
+associated with them, and we want to get the user_id and timestamp of
+the first event for each resource. The API (having been clumsily
+converted from XML) will only wrap the events in an array if the resource
+has multiple events:</p>
+<pre><code>{"resources": [{"id": 1, "kind": "widget", "events": {"action": "create", "user_id": 1, "ts": 13}},
+ {"id": 2, "kind": "widget", "events": [{"action": "create", "user_id": 1, "ts": 14}, {"action": "destroy", "user_id": 1, "ts": 15}]}]}
+</code></pre>
<p>We can use the destructuring alternative operator to handle this structural change simply:</p>
-
-<pre><code>.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}</code></pre>
-
-<p>Or, if we aren’t sure if the input is an array of values or an object:</p>
-
-<pre><code>.[] as [$id, $kind, $user_id, $ts] ?// {$id, $kind, $user_id, $ts} | ...</code></pre>
-
-<p>Each alternative need not define all of the same variables, but all named variables will be available to the subsequent expression. Variables not matched in the alternative that succeeded will be <code>null</code>:</p>
-
-<pre><code>.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$first_user_id, $first_ts}]} | {$user_id, $first_user_id, $kind, $id, $ts, $first_ts}</code></pre>
-
-<p>Additionally, if the subsequent expression returns an error, the alternative operator will attempt to try the next binding. Errors that occur during the final alternative are passed through.</p>
-
-<pre><code>[[3]] | .[] as [$a] ?// [$b] | if $a != null then error(&quot;err: \($a)&quot;) else {$a,$b} end</code></pre>
-
+<pre><code>.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}
+</code></pre>
+<p>Or, if we aren't sure if the input is an array of values or an object:</p>
+<pre><code>.[] as [$id, $kind, $user_id, $ts] ?// {$id, $kind, $user_id, $ts} | ...
+</code></pre>
+<p>Each alternative need not define all of the same variables, but all named
+variables will be available to the subsequent expression. Variables not
+matched in the alternative that succeeded will be <code>null</code>:</p>
+<pre><code>.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$first_user_id, $first_ts}]} | {$user_id, $first_user_id, $kind, $id, $ts, $first_ts}
+</code></pre>
+<p>Additionally, if the subsequent expression returns an error, the
+alternative operator will attempt to try the next binding. Errors
+that occur during the final alternative are passed through.</p>
+<pre><code>[[3]] | .[] as [$a] ?// [$b] | if $a != null then error("err: \($a)") else {$a,$b} end
+</code></pre>
<div>
@@ -6077,48 +5979,48 @@ Destructuring Alternative Operator: <code>?//</code>
<table>
<tr><th></th><td class="jqprogram">jq '.[] as {$a, $b, c: {$d, $e}} ?// {$a, $b, c: [{$d, $e}]} | {$a, $b, $d, $e}'</td></tr>
- <tr><th>Input</th><td>[{&quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: {&quot;d&quot;: 3, &quot;e&quot;: 4}}, {&quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: [{&quot;d&quot;: 3, &quot;e&quot;: 4}]}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;a&#34;: 1, &#34;b&#34;: 2, &#34;c&#34;: {&#34;d&#34;: 3, &#34;e&#34;: 4}}, {&#34;a&#34;: 1, &#34;b&#34;: 2, &#34;c&#34;: [{&#34;d&#34;: 3, &#34;e&#34;: 4}]}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;:1,&quot;b&quot;:2,&quot;d&quot;:3,&quot;e&quot;:4}</td>
+ <td>{&#34;a&#34;:1,&#34;b&#34;:2,&#34;d&#34;:3,&#34;e&#34;:4}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;a&quot;:1,&quot;b&quot;:2,&quot;d&quot;:3,&quot;e&quot;:4}</td>
+ <td>{&#34;a&#34;:1,&#34;b&#34;:2,&#34;d&#34;:3,&#34;e&#34;:4}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[] as {$a, $b, c: {$d}} ?// {$a, $b, c: [{$e}]} | {$a, $b, $d, $e}'</td></tr>
- <tr><th>Input</th><td>[{&quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: {&quot;d&quot;: 3, &quot;e&quot;: 4}}, {&quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: [{&quot;d&quot;: 3, &quot;e&quot;: 4}]}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;a&#34;: 1, &#34;b&#34;: 2, &#34;c&#34;: {&#34;d&#34;: 3, &#34;e&#34;: 4}}, {&#34;a&#34;: 1, &#34;b&#34;: 2, &#34;c&#34;: [{&#34;d&#34;: 3, &#34;e&#34;: 4}]}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;:1,&quot;b&quot;:2,&quot;d&quot;:3,&quot;e&quot;:null}</td>
+ <td>{&#34;a&#34;:1,&#34;b&#34;:2,&#34;d&#34;:3,&#34;e&#34;:null}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;a&quot;:1,&quot;b&quot;:2,&quot;d&quot;:null,&quot;e&quot;:4}</td>
+ <td>{&#34;a&#34;:1,&#34;b&#34;:2,&#34;d&#34;:null,&#34;e&#34;:4}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[] as [$a] ?// [$b] | if $a != null then error(&quot;err: \($a)&quot;) else {$a,$b} end'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[] as [$a] ?// [$b] | if $a != null then error(&#34;err: \($a)&#34;) else {$a,$b} end'</td></tr>
<tr><th>Input</th><td>[[3]]</td></tr>
@@ -6126,7 +6028,7 @@ Destructuring Alternative Operator: <code>?//</code>
<th>Output</th>
- <td>{&quot;a&quot;:null,&quot;b&quot;:3}</td>
+ <td>{&#34;a&#34;:null,&#34;b&#34;:3}</td>
</tr>
</table>
@@ -6138,39 +6040,48 @@ Destructuring Alternative Operator: <code>?//</code>
<section id="DefiningFunctions">
<h3>
-
-Defining Functions
-
+ Defining Functions
</h3>
-
-<p>You can give a filter a name using “def” syntax:</p>
-
-<pre><code>def increment: . + 1;</code></pre>
-
-<p>From then on, <code>increment</code> is usable as a filter just like a builtin function (in fact, this is how many of the builtins are defined). A function may take arguments:</p>
-
-<pre><code>def map(f): [.[] | f];</code></pre>
-
-<p>Arguments are passed as <em>filters</em> (functions with no arguments), <em>not</em> as values. The same argument may be referenced multiple times with different inputs (here <code>f</code> is run for each element of the input array). Arguments to a function work more like callbacks than like value arguments. This is important to understand. Consider:</p>
-
+ <p>You can give a filter a name using "def" syntax:</p>
+<pre><code>def increment: . + 1;
+</code></pre>
+<p>From then on, <code>increment</code> is usable as a filter just like a
+builtin function (in fact, this is how many of the builtins
+are defined). A function may take arguments:</p>
+<pre><code>def map(f): [.[] | f];
+</code></pre>
+<p>Arguments are passed as <em>filters</em> (functions with no
+arguments), <em>not</em> as values. The same argument may be
+referenced multiple times with different inputs (here <code>f</code> is
+run for each element of the input array). Arguments to a
+function work more like callbacks than like value arguments.
+This is important to understand. Consider:</p>
<pre><code>def foo(f): f|f;
-5|foo(.*2)</code></pre>
-
-<p>The result will be 20 because <code>f</code> is <code>.*2</code>, and during the first invocation of <code>f</code> <code>.</code> will be 5, and the second time it will be 10 (5 * 2), so the result will be 20. Function arguments are filters, and filters expect an input when invoked.</p>
-
-<p>If you want the value-argument behaviour for defining simple functions, you can just use a variable:</p>
-
-<pre><code>def addvalue(f): f as $f | map(. + $f);</code></pre>
-
+5|foo(.*2)
+</code></pre>
+<p>The result will be 20 because <code>f</code> is <code>.*2</code>, and during the
+first invocation of <code>f</code> <code>.</code> will be 5, and the second time it
+will be 10 (5 * 2), so the result will be 20. Function
+arguments are filters, and filters expect an input when
+invoked.</p>
+<p>If you want the value-argument behaviour for defining simple
+functions, you can just use a variable:</p>
+<pre><code>def addvalue(f): f as $f | map(. + $f);
+</code></pre>
<p>Or use the short-hand:</p>
-
-<pre><code>def addvalue($f): ...;</code></pre>
-
-<p>With either definition, <code>addvalue(.foo)</code> will add the current input’s <code>.foo</code> field to each element of the array. Do note that calling <code>addvalue(.[])</code> will cause the <code>map(. + $f)</code> part to be evaluated once per value in the value of <code>.</code> at the call site.</p>
-
-<p>Multiple definitions using the same function name are allowed. Each re-definition replaces the previous one for the same number of function arguments, but only for references from functions (or main program) subsequent to the re-definition. See also the section below on scoping.</p>
-
+<pre><code>def addvalue($f): ...;
+</code></pre>
+<p>With either definition, <code>addvalue(.foo)</code> will add the current
+input's <code>.foo</code> field to each element of the array. Do note
+that calling <code>addvalue(.[])</code> will cause the <code>map(. + $f)</code> part
+to be evaluated once per value in the value of <code>.</code> at the call
+site.</p>
+<p>Multiple definitions using the same function name are allowed.
+Each re-definition replaces the previous one for the same
+number of function arguments, but only for references from
+functions (or main program) subsequent to the re-definition.
+See also the section below on scoping.</p>
<div>
@@ -6216,40 +6127,43 @@ Defining Functions
<section id="Scoping">
<h3>
-
-Scoping
-
+ Scoping
</h3>
-
-<p>There are two types of symbols in jq: value bindings (a.k.a., “variables”), and functions. Both are scoped lexically, with expressions being able to refer only to symbols that have been defined “to the left” of them. The only exception to this rule is that functions can refer to themselves so as to be able to create recursive functions.</p>
-
-<p>For example, in the following expression there is a binding which is visible “to the right” of it, <code>... | .*3 as
-$times_three | [. + $times_three] | ...</code>, but not “to the left”. Consider this expression now, <code>... | (.*3 as
-$times_three | [.+ $times_three]) | ...</code>: here the binding <code>$times_three</code> is <em>not</em> visible past the closing parenthesis.</p>
-
+ <p>There are two types of symbols in jq: value bindings (a.k.a.,
+"variables"), and functions. Both are scoped lexically,
+with expressions being able to refer only to symbols that
+have been defined "to the left" of them. The only exception
+to this rule is that functions can refer to themselves so as
+to be able to create recursive functions.</p>
+<p>For example, in the following expression there is a binding
+which is visible "to the right" of it, <code>... | .*3 as
+$times_three | [. + $times_three] | ...</code>, but not "to the
+left". Consider this expression now, <code>... | (.*3 as
+$times_three | [. + $times_three]) | ...</code>: here the binding
+<code>$times_three</code> is <em>not</em> visible past the closing parenthesis.</p>
</section>
<section id="Reduce">
<h3>
-
-Reduce
-
+ Reduce
</h3>
-
-<p>The <code>reduce</code> syntax in jq allows you to combine all of the results of an expression by accumulating them into a single answer. As an example, we’ll pass <code>[3,2,1]</code> to this expression:</p>
-
-<pre><code>reduce .[] as $item (0; . + $item)</code></pre>
-
-<p>For each result that <code>.[]</code> produces, <code>. + $item</code> is run to accumulate a running total, starting from 0. In this example, <code>.[]</code> produces the results 3, 2, and 1, so the effect is similar to running something like this:</p>
-
+ <p>The <code>reduce</code> syntax in jq allows you to combine all of the
+results of an expression by accumulating them into a single
+answer. As an example, we'll pass <code>[3,2,1]</code> to this expression:</p>
+<pre><code>reduce .[] as $item (0; . + $item)
+</code></pre>
+<p>For each result that <code>.[]</code> produces, <code>. + $item</code> is run to
+accumulate a running total, starting from 0. In this
+example, <code>.[]</code> produces the results 3, 2, and 1, so the
+effect is similar to running something like this:</p>
<pre><code>0 | (3 as $item | . + $item) |
(2 as $item | . + $item) |
- (1 as $item | . + $item)</code></pre>
-
+ (1 as $item | . + $item)
+</code></pre>
<div>
@@ -6281,14 +6195,10 @@ Reduce
<section id="isempty(exp)">
<h3>
-
-<code>isempty(exp)</code>
-
+ <code>isempty(exp)</code>
</h3>
-
-<p>Returns true if <code>exp</code> produces no outputs, false otherwise.</p>
-
+ <p>Returns true if <code>exp</code> produces no outputs, false otherwise.</p>
<div>
@@ -6320,14 +6230,10 @@ Reduce
<section id="limit(n;exp)">
<h3>
-
-<code>limit(n; exp)</code>
-
+ <code>limit(n; exp)</code>
</h3>
-
-<p>The <code>limit</code> function extracts up to <code>n</code> outputs from <code>exp</code>.</p>
-
+ <p>The <code>limit</code> function extracts up to <code>n</code> outputs from <code>exp</code>.</p>
<div>
@@ -6359,17 +6265,15 @@ Reduce
<section id="first(expr),last(expr),nth(n;expr)">
<h3>
-
-<code>first(expr)</code>, <code>last(expr)</code>, <code>nth(n; expr)</code>
-
+ <code>first(expr)</code>, <code>last(expr)</code>, <code>nth(n; expr)</code>
</h3>
-
-<p>The <code>first(expr)</code> and <code>last(expr)</code> functions extract the first and last values from <code>expr</code>, respectively.</p>
-
-<p>The <code>nth(n; expr)</code> function extracts the nth value output by <code>expr</code>. This can be defined as <code>def nth(n; expr):
-last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t support negative values of <code>n</code>.</p>
-
+ <p>The <code>first(expr)</code> and <code>last(expr)</code> functions extract the first
+and last values from <code>expr</code>, respectively.</p>
+<p>The <code>nth(n; expr)</code> function extracts the nth value output by
+<code>expr</code>. This can be defined as <code>def nth(n; expr):
+last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn't
+support negative values of <code>n</code>.</p>
<div>
@@ -6401,17 +6305,13 @@ last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t
<section id="first,last,nth(n)">
<h3>
-
-<code>first</code>, <code>last</code>, <code>nth(n)</code>
-
+ <code>first</code>, <code>last</code>, <code>nth(n)</code>
</h3>
-
-<p>The <code>first</code> and <code>last</code> functions extract the first and last values from any array at <code>.</code>.</p>
-
+ <p>The <code>first</code> and <code>last</code> functions extract the first
+and last values from any array at <code>.</code>.</p>
<p>The <code>nth(n)</code> function extracts the nth value of any array at <code>.</code>.</p>
-
<div>
@@ -6442,18 +6342,22 @@ last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t
<section id="foreach">
<h3>
-
-<code>foreach</code>
-
+ <code>foreach</code>
</h3>
-
-<p>The <code>foreach</code> syntax is similar to <code>reduce</code>, but intended to allow the construction of <code>limit</code> and reducers that produce intermediate results (see example).</p>
-
-<p>The form is <code>foreach EXP as $var (INIT; UPDATE; EXTRACT)</code>. Like <code>reduce</code>, <code>INIT</code> is evaluated once to produce a state value, then each output of <code>EXP</code> is bound to <code>$var</code>, <code>UPDATE</code> is evaluated for each output of <code>EXP</code> with the current state and with <code>$var</code> visible. Each value output by <code>UPDATE</code> replaces the previous state. Finally, <code>EXTRACT</code> is evaluated for each new state to extract an output of <code>foreach</code>.</p>
-
-<p>This is mostly useful only for constructing <code>reduce</code>- and <code>limit</code>-like functions. But it is much more general, as it allows for partial reductions (see the example below).</p>
-
+ <p>The <code>foreach</code> syntax is similar to <code>reduce</code>, but intended to
+allow the construction of <code>limit</code> and reducers that produce
+intermediate results (see example).</p>
+<p>The form is <code>foreach EXP as $var (INIT; UPDATE; EXTRACT)</code>.
+Like <code>reduce</code>, <code>INIT</code> is evaluated once to produce a state
+value, then each output of <code>EXP</code> is bound to <code>$var</code>, <code>UPDATE</code>
+is evaluated for each output of <code>EXP</code> with the current state
+and with <code>$var</code> visible. Each value output by <code>UPDATE</code>
+replaces the previous state. Finally, <code>EXTRACT</code> is evaluated
+for each new state to extract an output of <code>foreach</code>.</p>
+<p>This is mostly useful only for constructing <code>reduce</code>- and
+<code>limit</code>-like functions. But it is much more general, as it
+allows for partial reductions (see the example below).</p>
<div>
@@ -6466,14 +6370,14 @@ last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t
<table>
<tr><th></th><td class="jqprogram">jq '[foreach .[] as $item ([[],[]]; if $item == null then [[],.[0]] else [(.[0] + [$item]),[]] end; if $item == null then .[1] else empty end)]'</td></tr>
- <tr><th>Input</th><td>[1,2,3,4,null,&quot;a&quot;,&quot;b&quot;,null]</td></tr>
+ <tr><th>Input</th><td>[1,2,3,4,null,&#34;a&#34;,&#34;b&#34;,null]</td></tr>
<tr>
<th>Output</th>
- <td>[[1,2,3,4],[&quot;a&quot;,&quot;b&quot;]]</td>
+ <td>[[1,2,3,4],[&#34;a&#34;,&#34;b&#34;]]</td>
</tr>
</table>
@@ -6485,18 +6389,17 @@ last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t
<section id="Recursion">
<h3>
-
-Recursion
-
+ Recursion
</h3>
-
-<p>As described above, <code>recurse</code> uses recursion, and any jq function can be recursive. The <code>while</code> builtin is also implemented in terms of recursion.</p>
-
-<p>Tail calls are optimized whenever the expression to the left of the recursive call outputs its last value. In practice this means that the expression to the left of the recursive call should not produce more than one output for each input.</p>
-
+ <p>As described above, <code>recurse</code> uses recursion, and any jq
+function can be recursive. The <code>while</code> builtin is also
+implemented in terms of recursion.</p>
+<p>Tail calls are optimized whenever the expression to the left of
+the recursive call outputs its last value. In practice this
+means that the expression to the left of the recursive call
+should not produce more than one output for each input.</p>
<p>For example:</p>
-
<pre><code>def recurse(f): def r: ., (f | select(. != null) | r); r;
def while(cond; update):
@@ -6507,28 +6410,39 @@ def while(cond; update):
def repeat(exp):
def _repeat:
exp, _repeat;
- _repeat;</code></pre>
-
+ _repeat;
+</code></pre>
</section>
<section id="Generatorsanditerators">
<h3>
-
-Generators and iterators
-
+ Generators and iterators
</h3>
-
-<p>Some jq operators and functions are actually generators in that they can produce zero, one, or more values for each input, just as one might expect in other programming languages that have generators. For example, <code>.[]</code> generates all the values in its input (which must be an array or an object), <code>range(0; 10)</code> generates the integers between 0 and 10, and so on.</p>
-
-<p>Even the comma operator is a generator, generating first the values generated by the expression to the left of the comma, then for each of those, the values generate by the expression on the right of the comma.</p>
-
-<p>The <code>empty</code> builtin is the generator that produces zero outputs. The <code>empty</code> builtin backtracks to the preceding generator expression.</p>
-
-<p>All jq functions can be generators just by using builtin generators. It is also possible to define new generators using only recursion and the comma operator. If the recursive call(s) is(are) “in tail position” then the generator will be efficient. In the example below the recursive call by <code>_range</code> to itself is in tail position. The example shows off three advanced topics: tail recursion, generator construction, and sub-functions.</p>
-
+ <p>Some jq operators and functions are actually generators in
+that they can produce zero, one, or more values for each
+input, just as one might expect in other programming
+languages that have generators. For example, <code>.[]</code>
+generates all the values in its input (which must be an
+array or an object), <code>range(0; 10)</code> generates the integers
+between 0 and 10, and so on.</p>
+<p>Even the comma operator is a generator, generating first the
+values generated by the expression to the left of the comma,
+then for each of those, the values generate by the
+expression on the right of the comma.</p>
+<p>The <code>empty</code> builtin is the generator that produces zero
+outputs. The <code>empty</code> builtin backtracks to the preceding
+generator expression.</p>
+<p>All jq functions can be generators just by using builtin
+generators. It is also possible to define new generators
+using only recursion and the comma operator. If the
+recursive call(s) is(are) "in tail position" then the
+generator will be efficient. In the example below the
+recursive call by <code>_range</code> to itself is in tail position.
+The example shows off three advanced topics: tail recursion,
+generator construction, and sub-functions.</p>
<div>
@@ -6597,116 +6511,117 @@ Generators and iterators
<section id="Math">
<h2>Math</h2>
-
-<p>jq currently only has IEEE754 double-precision (64-bit) floating point number support.</p>
-
-<p>Besides simple arithmetic operators such as <code>+</code>, jq also has most standard math functions from the C math library. C math functions that take a single input argument (e.g., <code>sin()</code>) are available as zero-argument jq functions. C math functions that take two input arguments (e.g., <code>pow()</code>) are available as two-argument jq functions that ignore <code>.</code>. C math functions that take three input arguments are available as three-argument jq functions that ignore <code>.</code>.</p>
-
-<p>Availability of standard math functions depends on the availability of the corresponding math functions in your operating system and C math library. Unavailable math functions will be defined but will raise an error.</p>
-
-<p>One-input C math functions: <code>acos</code> <code>acosh</code> <code>asin</code> <code>asinh</code> <code>atan</code> <code>atanh</code> <code>cbrt</code> <code>ceil</code> <code>cos</code> <code>cosh</code> <code>erf</code> <code>erfc</code> <code>exp</code> <code>exp10</code> <code>exp2</code> <code>expm1</code> <code>fabs</code> <code>floor</code> <code>gamma</code> <code>j0</code> <code>j1</code> <code>lgamma</code> <code>log</code> <code>log10</code> <code>log1p</code> <code>log2</code> <code>logb</code> <code>nearbyint</code> <code>pow10</code> <code>rint</code> <code>round</code> <code>significand</code> <code>sin</code> <code>sinh</code> <code>sqrt</code> <code>tan</code> <code>tanh</code> <code>tgamma</code> <code>trunc</code> <code>y0</code> <code>y1</code>.</p>
-
-<p>Two-input C math functions: <code>atan2</code> <code>copysign</code> <code>drem</code> <code>fdim</code> <code>fmax</code> <code>fmin</code> <code>fmod</code> <code>frexp</code> <code>hypot</code> <code>jn</code> <code>ldexp</code> <code>modf</code> <code>nextafter</code> <code>nexttoward</code> <code>pow</code> <code>remainder</code> <code>scalb</code> <code>scalbln</code> <code>yn</code>.</p>
-
+ <p>jq currently only has IEEE754 double-precision (64-bit) floating
+point number support.</p>
+<p>Besides simple arithmetic operators such as <code>+</code>, jq also has most
+standard math functions from the C math library. C math functions
+that take a single input argument (e.g., <code>sin()</code>) are available as
+zero-argument jq functions. C math functions that take two input
+arguments (e.g., <code>pow()</code>) are available as two-argument jq
+functions that ignore <code>.</code>. C math functions that take three input
+arguments are available as three-argument jq functions that ignore
+<code>.</code>.</p>
+<p>Availability of standard math functions depends on the
+availability of the corresponding math functions in your operating
+system and C math library. Unavailable math functions will be
+defined but will raise an error.</p>
+<p>One-input C math functions: <code>acos</code> <code>acosh</code> <code>asin</code> <code>asinh</code> <code>atan</code>
+<code>atanh</code> <code>cbrt</code> <code>ceil</code> <code>cos</code> <code>cosh</code> <code>erf</code> <code>erfc</code> <code>exp</code> <code>exp10</code>
+<code>exp2</code> <code>expm1</code> <code>fabs</code> <code>floor</code> <code>gamma</code> <code>j0</code> <code>j1</code> <code>lgamma</code> <code>log</code>
+<code>log10</code> <code>log1p</code> <code>log2</code> <code>logb</code> <code>nearbyint</code> <code>pow10</code> <code>rint</code> <code>round</code>
+<code>significand</code> <code>sin</code> <code>sinh</code> <code>sqrt</code> <code>tan</code> <code>tanh</code> <code>tgamma</code> <code>trunc</code>
+<code>y0</code> <code>y1</code>.</p>
+<p>Two-input C math functions: <code>atan2</code> <code>copysign</code> <code>drem</code> <code>fdim</code>
+<code>fmax</code> <code>fmin</code> <code>fmod</code> <code>frexp</code> <code>hypot</code> <code>jn</code> <code>ldexp</code> <code>modf</code>
+<code>nextafter</code> <code>nexttoward</code> <code>pow</code> <code>remainder</code> <code>scalb</code> <code>scalbln</code> <code>yn</code>.</p>
<p>Three-input C math functions: <code>fma</code>.</p>
-
-<p>See your system’s manual for more information on each of these.</p>
-
+<p>See your system's manual for more information on each of these.</p>
</section>
<section id="IO">
<h2>I/O</h2>
-
-<p>At this time jq has minimal support for I/O, mostly in the form of control over when inputs are read. Two builtins functions are provided for this, <code>input</code> and <code>inputs</code>, that read from the same sources (e.g., <code>stdin</code>, files named on the command-line) as jq itself. These two builtins, and jq’s own reading actions, can be interleaved with each other.</p>
-
-<p>Two builtins provide minimal output capabilities, <code>debug</code>, and <code>stderr</code>. (Recall that a jq program’s output values are always output as JSON texts on <code>stdout</code>.) The <code>debug</code> builtin can have application-specific behavior, such as for executables that use the libjq C API but aren’t the jq executable itself. The <code>stderr</code> builtin outputs its input in raw mode to stder with no additional decoration, not even a newline.</p>
-
-<p>Most jq builtins are referentially transparent, and yield constant and repeatable value streams when applied to constant inputs. This is not true of I/O builtins.</p>
-
+ <p>At this time jq has minimal support for I/O, mostly in the
+form of control over when inputs are read. Two builtins functions
+are provided for this, <code>input</code> and <code>inputs</code>, that read from the
+same sources (e.g., <code>stdin</code>, files named on the command-line) as
+jq itself. These two builtins, and jq's own reading actions, can
+be interleaved with each other.</p>
+<p>Two builtins provide minimal output capabilities, <code>debug</code>, and
+<code>stderr</code>. (Recall that a jq program's output values are always
+output as JSON texts on <code>stdout</code>.) The <code>debug</code> builtin can have
+application-specific behavior, such as for executables that use
+the libjq C API but aren't the jq executable itself. The <code>stderr</code>
+builtin outputs its input in raw mode to stder with no additional
+decoration, not even a newline.</p>
+<p>Most jq builtins are referentially transparent, and yield constant
+and repeatable value streams when applied to constant inputs.
+This is not true of I/O builtins.</p>
<section id="input">
<h3>
-
-<code>input</code>
-
+ <code>input</code>
</h3>
-
-<p>Outputs one new input.</p>
-
+ <p>Outputs one new input.</p>
</section>
<section id="inputs">
<h3>
-
-<code>inputs</code>
-
+ <code>inputs</code>
</h3>
-
-<p>Outputs all remaining inputs, one by one.</p>
-
-<p>This is primarily useful for reductions over a program’s inputs.</p>
-
+ <p>Outputs all remaining inputs, one by one.</p>
+<p>This is primarily useful for reductions over a program's
+inputs.</p>
</section>
<section id="debug">
<h3>
-
-<code>debug</code>
-
+ <code>debug</code>
</h3>
-
-<p>Causes a debug message based on the input value to be produced. The jq executable wraps the input value with <code>[&quot;DEBUG:&quot;, &lt;input-value&gt;]</code> and prints that and a newline on stderr, compactly. This may change in the future.</p>
-
+ <p>Causes a debug message based on the input value to be
+produced. The jq executable wraps the input value with
+<code>["DEBUG:", &lt;input-value&gt;]</code> and prints that and a newline on
+stderr, compactly. This may change in the future.</p>
</section>
<section id="stderr">
<h3>
-
-<code>stderr</code>
-
+ <code>stderr</code>
</h3>
-
-<p>Prints its input in raw and compact mode to stderr with no additional decoration, not even a newline.</p>
-
+ <p>Prints its input in raw and compact mode to stderr with no
+additional decoration, not even a newline.</p>
</section>
<section id="input_filename">
<h3>
-
-<code>input_filename</code>
-
+ <code>input_filename</code>
</h3>
-
-<p>Returns the name of the file whose input is currently being filtered. Note that this will not work well unless jq is running in a UTF-8 locale.</p>
-
+ <p>Returns the name of the file whose input is currently being
+filtered. Note that this will not work well unless jq is
+running in a UTF-8 locale.</p>
</section>
<section id="input_line_number">
<h3>
-
-<code>input_line_number</code>
-
+ <code>input_line_number</code>
</h3>
-
-<p>Returns the line number of the input currently being filtered.</p>
-
+ <p>Returns the line number of the input currently being filtered.</p>
</section>
@@ -6715,28 +6630,30 @@ Generators and iterators
<section id="Streaming">
<h2>Streaming</h2>
-
-<p>With the <code>--stream</code> option jq can parse input texts in a streaming fashion, allowing jq programs to start processing large JSON texts immediately rather than after the parse completes. If you have a single JSON text that is 1GB in size, streaming it will allow you to process it much more quickly.</p>
-
-<p>However, streaming isn’t easy to deal with as the jq program will have <code>[&lt;path&gt;, &lt;leaf-value&gt;]</code> (and a few other forms) as inputs.</p>
-
+ <p>With the <code>--stream</code> option jq can parse input texts in a streaming
+fashion, allowing jq programs to start processing large JSON texts
+immediately rather than after the parse completes. If you have a
+single JSON text that is 1GB in size, streaming it will allow you
+to process it much more quickly.</p>
+<p>However, streaming isn't easy to deal with as the jq program will
+have <code>[&lt;path&gt;, &lt;leaf-value&gt;]</code> (and a few other forms) as inputs.</p>
<p>Several builtins are provided to make handling streams easier.</p>
-
-<p>The examples below use the streamed form of <code>[0,[1]]</code>, which is <code>[[0],0],[[1,0],1],[[1,0]],[[1]]</code>.</p>
-
-<p>Streaming forms include <code>[&lt;path&gt;, &lt;leaf-value&gt;]</code> (to indicate any scalar value, empty array, or empty object), and <code>[&lt;path&gt;]</code> (to indicate the end of an array or object). Future versions of jq run with <code>--stream</code> and <code>-seq</code> may output additional forms such as <code>[&quot;error message&quot;]</code> when an input text fails to parse.</p>
-
+<p>The examples below use the streamed form of <code>[0,[1]]</code>, which is
+<code>[[0],0],[[1,0],1],[[1,0]],[[1]]</code>.</p>
+<p>Streaming forms include <code>[&lt;path&gt;, &lt;leaf-value&gt;]</code> (to indicate any
+scalar value, empty array, or empty object), and <code>[&lt;path&gt;]</code> (to
+indicate the end of an array or object). Future versions of jq
+run with <code>--stream</code> and <code>-seq</code> may output additional forms such as
+<code>["error message"]</code> when an input text fails to parse.</p>
<section id="truncate_stream(stream_expression)">
<h3>
-
-<code>truncate_stream(stream_expression)</code>
-
+ <code>truncate_stream(stream_expression)</code>
</h3>
-
-<p>Consumes a number as input and truncates the corresponding number of path elements from the left of the outputs of the given streaming expression.</p>
-
+ <p>Consumes a number as input and truncates the corresponding
+number of path elements from the left of the outputs of the
+given streaming expression.</p>
<div>
@@ -6768,14 +6685,11 @@ Generators and iterators
<section id="fromstream(stream_expression)">
<h3>
-
-<code>fromstream(stream_expression)</code>
-
+ <code>fromstream(stream_expression)</code>
</h3>
-
-<p>Outputs values corresponding to the stream expression’s outputs.</p>
-
+ <p>Outputs values corresponding to the stream expression's
+outputs.</p>
<div>
@@ -6807,14 +6721,10 @@ Generators and iterators
<section id="tostream">
<h3>
-
-<code>tostream</code>
-
+ <code>tostream</code>
</h3>
-
-<p>The <code>tostream</code> builtin outputs the streamed form of its input.</p>
-
+ <p>The <code>tostream</code> builtin outputs the streamed form of its input.</p>
<div>
@@ -6827,7 +6737,7 @@ Generators and iterators
<table>
<tr><th></th><td class="jqprogram">jq '. as $dot|fromstream($dot|tostream)|.==$dot'</td></tr>
- <tr><th>Input</th><td>[0,[1,{&quot;a&quot;:1},{&quot;b&quot;:2}]]</td></tr>
+ <tr><th>Input</th><td>[0,[1,{&#34;a&#34;:1},{&#34;b&#34;:2}]]</td></tr>
<tr>
@@ -6848,44 +6758,64 @@ Generators and iterators
<section id="Assignment">
<h2>Assignment</h2>
-
-<p>Assignment works a little differently in jq than in most programming languages. jq doesn’t distinguish between references to and copies of something - two objects or arrays are either equal or not equal, without any further notion of being “the same object” or “not the same object”.</p>
-
-<p>If an object has two fields which are arrays, <code>.foo</code> and <code>.bar</code>, and you append something to <code>.foo</code>, then <code>.bar</code> will not get bigger, even if you’ve previously set <code>.bar = .foo</code>. If you’re used to programming in languages like Python, Java, Ruby, Javascript, etc. then you can think of it as though jq does a full deep copy of every object before it does the assignment (for performance it doesn’t actually do that, but that’s the general idea).</p>
-
-<p>This means that it’s impossible to build circular values in jq (such as an array whose first element is itself). This is quite intentional, and ensures that anything a jq program can produce can be represented in JSON.</p>
-
-<p>All the assignment operators in jq have path expressions on the left-hand side (LHS). The right-hand side (RHS) provides values to set to the paths named by the LHS path expressions.</p>
-
-<p>Values in jq are always immutable. Internally, assignment works by using a reduction to compute new, replacement values for <code>.</code> that have had all the desired assignments applied to <code>.</code>, then outputting the modified value. This might be made clear by this example: <code>{a:{b:{c:1}}} | (.a.b|=3), .</code>. This will output <code>{&quot;a&quot;:{&quot;b&quot;:3}}</code> and <code>{&quot;a&quot;:{&quot;b&quot;:{&quot;c&quot;:1}}}</code> because the last sub-expression, <code>.</code>, sees the original value, not the modified value.</p>
-
-<p>Most users will want to use modification assignment operators, such as <code>|=</code> or <code>+=</code>, rather than <code>=</code>.</p>
-
-<p>Note that the LHS of assignment operators refers to a value in <code>.</code>. Thus <code>$var.foo = 1</code> won’t work as expected (<code>$var.foo</code> is not a valid or useful path expression in <code>.</code>); use <code>$var | .foo =
+ <p>Assignment works a little differently in jq than in most
+programming languages. jq doesn't distinguish between references
+to and copies of something - two objects or arrays are either
+equal or not equal, without any further notion of being "the
+same object" or "not the same object".</p>
+<p>If an object has two fields which are arrays, <code>.foo</code> and <code>.bar</code>,
+and you append something to <code>.foo</code>, then <code>.bar</code> will not get
+bigger, even if you've previously set <code>.bar = .foo</code>. If you're
+used to programming in languages like Python, Java, Ruby,
+Javascript, etc. then you can think of it as though jq does a full
+deep copy of every object before it does the assignment (for
+performance it doesn't actually do that, but that's the general
+idea).</p>
+<p>This means that it's impossible to build circular values in jq
+(such as an array whose first element is itself). This is quite
+intentional, and ensures that anything a jq program can produce
+can be represented in JSON.</p>
+<p>All the assignment operators in jq have path expressions on the
+left-hand side (LHS). The right-hand side (RHS) provides values
+to set to the paths named by the LHS path expressions.</p>
+<p>Values in jq are always immutable. Internally, assignment works
+by using a reduction to compute new, replacement values for <code>.</code> that
+have had all the desired assignments applied to <code>.</code>, then
+outputting the modified value. This might be made clear by this
+example: <code>{a:{b:{c:1}}} | (.a.b|=3), .</code>. This will output
+<code>{"a":{"b":3}}</code> and <code>{"a":{"b":{"c":1}}}</code> because the last
+sub-expression, <code>.</code>, sees the original value, not the modified
+value.</p>
+<p>Most users will want to use modification assignment operators,
+such as <code>|=</code> or <code>+=</code>, rather than <code>=</code>.</p>
+<p>Note that the LHS of assignment operators refers to a value in
+<code>.</code>. Thus <code>$var.foo = 1</code> won't work as expected (<code>$var.foo</code> is
+not a valid or useful path expression in <code>.</code>); use <code>$var | .foo =
1</code> instead.</p>
-
-<p>Note too that <code>.a,.b=0</code> does not set <code>.a</code> and <code>.b</code>, but <code>(.a,.b)=0</code> sets both.</p>
-
+<p>Note too that <code>.a,.b=0</code> does not set <code>.a</code> and <code>.b</code>, but
+<code>(.a,.b)=0</code> sets both.</p>
<section id="Update-assignment:|=">
<h3>
-
-Update-assignment: <code>|=</code>
-
+ Update-assignment: <code>|=</code>
</h3>
-
-<p>This is the “update” operator ‘|=’. It takes a filter on the right-hand side and works out the new value for the property of <code>.</code> being assigned to by running the old value through this expression. For instance, (.foo, .bar) |= .+1 will build an object with the “foo” field set to the input’s “foo” plus 1, and the “bar” field set to the input’s “bar” plus 1.</p>
-
+ <p>This is the "update" operator '|='. It takes a filter on the
+right-hand side and works out the new value for the property
+of <code>.</code> being assigned to by running the old value through this
+expression. For instance, (.foo, .bar) |= .+1 will build an
+object with the "foo" field set to the input's "foo" plus 1,
+and the "bar" field set to the input's "bar" plus 1.</p>
<p>The left-hand side can be any general path expression; see <code>path()</code>.</p>
-
-<p>Note that the left-hand side of ‘|=’ refers to a value in <code>.</code>. Thus <code>$var.foo |= . + 1</code> won’t work as expected (<code>$var.foo</code> is not a valid or useful path expression in <code>.</code>); use <code>$var |
+<p>Note that the left-hand side of '|=' refers to a value in <code>.</code>.
+Thus <code>$var.foo |= . + 1</code> won't work as expected (<code>$var.foo</code> is
+not a valid or useful path expression in <code>.</code>); use <code>$var |
.foo |= . + 1</code> instead.</p>
-
-<p>If the right-hand side outputs no values (i.e., <code>empty</code>), then the left-hand side path will be deleted, as with <code>del(path)</code>.</p>
-
-<p>If the right-hand side outputs multiple values, only the first one will be used (COMPATIBILITY NOTE: in jq 1.5 and earlier releases, it used to be that only the last one was used).</p>
-
+<p>If the right-hand side outputs no values (i.e., <code>empty</code>), then
+the left-hand side path will be deleted, as with <code>del(path)</code>.</p>
+<p>If the right-hand side outputs multiple values, only the first
+one will be used (COMPATIBILITY NOTE: in jq 1.5 and earlier
+releases, it used to be that only the last one was used).</p>
<div>
@@ -6897,7 +6827,7 @@ Update-assignment: <code>|=</code>
<div id="example96" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '(..|select(type==&quot;boolean&quot;)) |= if . then 1 else 0 end'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '(..|select(type==&#34;boolean&#34;)) |= if . then 1 else 0 end'</td></tr>
<tr><th>Input</th><td>[true,false,[5,true,[true,[false]],false]]</td></tr>
@@ -6917,14 +6847,12 @@ Update-assignment: <code>|=</code>
<section id="Arithmeticupdate-assignment:+=,-=,*=,/=,%=,//=">
<h3>
-
-Arithmetic update-assignment: <code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>, <code>%=</code>, <code>//=</code>
-
+ Arithmetic update-assignment: <code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>, <code>%=</code>, <code>//=</code>
</h3>
-
-<p>jq has a few operators of the form <code>a op= b</code>, which are all equivalent to <code>a |= . op b</code>. So, <code>+= 1</code> can be used to increment values, being the same as <code>|= . + 1</code>.</p>
-
+ <p>jq has a few operators of the form <code>a op= b</code>, which are all
+equivalent to <code>a |= . op b</code>. So, <code>+= 1</code> can be used to
+increment values, being the same as <code>|= . + 1</code>.</p>
<div>
@@ -6937,14 +6865,14 @@ Arithmetic update-assignment: <code>+=</code>, <code>-=</code>, <code>*=</code>,
<table>
<tr><th></th><td class="jqprogram">jq '.foo += 1'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;: 43}</td>
+ <td>{&#34;foo&#34;: 43}</td>
</tr>
</table>
@@ -6956,69 +6884,75 @@ Arithmetic update-assignment: <code>+=</code>, <code>-=</code>, <code>*=</code>,
<section id="Plainassignment:=">
<h3>
-
-Plain assignment: <code>=</code>
-
+ Plain assignment: <code>=</code>
</h3>
-
-<p>This is the plain assignment operator. Unlike the others, the input to the right-hand-side (RHS) is the same as the input to the left-hand-side (LHS) rather than the value at the LHS path, and all values output by the RHS will be used (as shown below).</p>
-
-<p>If the RHS of ‘=’ produces multiple values, then for each such value jq will set the paths on the left-hand side to the value and then it will output the modified <code>.</code>. For example, <code>(.a,.b)=range(2)</code> outputs <code>{&quot;a&quot;:0,&quot;b&quot;:0}</code>, then <code>{&quot;a&quot;:1,&quot;b&quot;:1}</code>. The “update” assignment forms (see above) do not do this.</p>
-
-<p>This example should show the difference between ‘=’ and ‘|=’:</p>
-
-<p>Provide input ‘{“a”: {“b”: 10}, “b”: 20}’ to the programs:</p>
-
+ <p>This is the plain assignment operator. Unlike the others, the
+input to the right-hand-side (RHS) is the same as the input to
+the left-hand-side (LHS) rather than the value at the LHS
+path, and all values output by the RHS will be used (as shown
+below).</p>
+<p>If the RHS of '=' produces multiple values, then for each such
+value jq will set the paths on the left-hand side to the value
+and then it will output the modified <code>.</code>. For example,
+<code>(.a,.b)=range(2)</code> outputs <code>{"a":0,"b":0}</code>, then
+<code>{"a":1,"b":1}</code>. The "update" assignment forms (see above) do
+not do this.</p>
+<p>This example should show the difference between '=' and '|=':</p>
+<p>Provide input '{"a": {"b": 10}, "b": 20}' to the programs:</p>
<p>.a = .b</p>
-
<p>.a |= .b</p>
-
-<p>The former will set the “a” field of the input to the “b” field of the input, and produce the output {“a”: 20, “b”: 20}. The latter will set the “a” field of the input to the “a” field’s “b” field, producing {“a”: 10, “b”: 20}.</p>
-
-<p>Another example of the difference between ‘=’ and ‘|=’:</p>
-
+<p>The former will set the "a" field of the input to the "b"
+field of the input, and produce the output {"a": 20, "b": 20}.
+The latter will set the "a" field of the input to the "a"
+field's "b" field, producing {"a": 10, "b": 20}.</p>
+<p>Another example of the difference between '=' and '|=':</p>
<p>null|(.a,.b)=range(3)</p>
-
-<p>outputs ‘{“a”:0,“b”:0}’, ‘{“a”:1,“b”:1}’, and ‘{“a”:2,“b”:2}’, while</p>
-
+<p>outputs '{"a":0,"b":0}', '{"a":1,"b":1}', and '{"a":2,"b":2}',
+while</p>
<p>null|(.a,.b)|=range(3)</p>
-
-<p>outputs just ‘{“a”:0,“b”:0}’.</p>
-
+<p>outputs just '{"a":0,"b":0}'.</p>
</section>
<section id="Complexassignments">
<h3>
-
-Complex assignments
-
+ Complex assignments
</h3>
-
-<p>Lots more things are allowed on the left-hand side of a jq assignment than in most languages. We’ve already seen simple field accesses on the left hand side, and it’s no surprise that array accesses work just as well:</p>
-
-<pre><code>.posts[0].title = &quot;JQ Manual&quot;</code></pre>
-
-<p>What may come as a surprise is that the expression on the left may produce multiple results, referring to different points in the input document:</p>
-
-<pre><code>.posts[].comments |= . + [&quot;this is great&quot;]</code></pre>
-
-<p>That example appends the string “this is great” to the “comments” array of each post in the input (where the input is an object with a field “posts” which is an array of posts).</p>
-
-<p>When jq encounters an assignment like ‘a = b’, it records the “path” taken to select a part of the input document while executing a. This path is then used to find which part of the input to change while executing the assignment. Any filter may be used on the left-hand side of an equals - whichever paths it selects from the input will be where the assignment is performed.</p>
-
-<p>This is a very powerful operation. Suppose we wanted to add a comment to blog posts, using the same “blog” input above. This time, we only want to comment on the posts written by “stedolan”. We can find those posts using the “select” function described earlier:</p>
-
-<pre><code>.posts[] | select(.author == &quot;stedolan&quot;)</code></pre>
-
-<p>The paths provided by this operation point to each of the posts that “stedolan” wrote, and we can comment on each of them in the same way that we did before:</p>
-
-<pre><code>(.posts[] | select(.author == &quot;stedolan&quot;) | .comments) |=
- . + [&quot;terrible.&quot;]</code></pre>
-
+ <p>Lots more things are allowed on the left-hand side of a jq assignment
+than in most languages. We've already seen simple field accesses on
+the left hand side, and it's no surprise that array accesses work just
+as well:</p>
+<pre><code>.posts[0].title = "JQ Manual"
+</code></pre>
+<p>What may come as a surprise is that the expression on the left may
+produce multiple results, referring to different points in the input
+document:</p>
+<pre><code>.posts[].comments |= . + ["this is great"]
+</code></pre>
+<p>That example appends the string "this is great" to the "comments"
+array of each post in the input (where the input is an object with a
+field "posts" which is an array of posts).</p>
+<p>When jq encounters an assignment like 'a = b', it records the "path"
+taken to select a part of the input document while executing a. This
+path is then used to find which part of the input to change while
+executing the assignment. Any filter may be used on the
+left-hand side of an equals - whichever paths it selects from the
+input will be where the assignment is performed.</p>
+<p>This is a very powerful operation. Suppose we wanted to add a comment
+to blog posts, using the same "blog" input above. This time, we only
+want to comment on the posts written by "stedolan". We can find those
+posts using the "select" function described earlier:</p>
+<pre><code>.posts[] | select(.author == "stedolan")
+</code></pre>
+<p>The paths provided by this operation point to each of the posts that
+"stedolan" wrote, and we can comment on each of them in the same way
+that we did before:</p>
+<pre><code>(.posts[] | select(.author == "stedolan") | .comments) |=
+ . + ["terrible."]
+</code></pre>
</section>
@@ -7027,115 +6961,125 @@ Complex assignments
<section id="Modules">
<h2>Modules</h2>
-
-<p>jq has a library/module system. Modules are files whose names end in <code>.jq</code>.</p>
-
-<p>Modules imported by a program are searched for in a default search path (see below). The <code>import</code> and <code>include</code> directives allow the importer to alter this path.</p>
-
+ <p>jq has a library/module system. Modules are files whose names end
+in <code>.jq</code>.</p>
+<p>Modules imported by a program are searched for in a default search
+path (see below). The <code>import</code> and <code>include</code> directives allow the
+importer to alter this path.</p>
<p>Paths in the a search path are subject to various substitutions.</p>
-
-<p>For paths starting with “~/”, the user’s home directory is substituted for “~”.</p>
-
-<p>For paths starting with “$ORIGIN/”, the path of the jq executable is substituted for “$ORIGIN”.</p>
-
-<p>For paths starting with “./” or paths that are “.”, the path of the including file is substituted for “.”. For top-level programs given on the command-line, the current directory is used.</p>
-
-<p>Import directives can optionally specify a search path to which the default is appended.</p>
-
-<p>The default search path is the search path given to the <code>-L</code> command-line option, else <code>[&quot;~/.jq&quot;, &quot;$ORIGIN/../lib/jq&quot;,
-&quot;$ORIGIN/../lib&quot;]</code>.</p>
-
-<p>Null and empty string path elements terminate search path processing.</p>
-
-<p>A dependency with relative path “foo/bar” would be searched for in “foo/bar.jq” and “foo/bar/bar.jq” in the given search path. This is intended to allow modules to be placed in a directory along with, for example, version control files, README files, and so on, but also to allow for single-file modules.</p>
-
-<p>Consecutive components with the same name are not allowed to avoid ambiguities (e.g., “foo/foo”).</p>
-
-<p>For example, with <code>-L$HOME/.jq</code> a module <code>foo</code> can be found in <code>$HOME/.jq/foo.jq</code> and <code>$HOME/.jq/foo/foo.jq</code>.</p>
-
-<p>If “$HOME/.jq” is a file, it is sourced into the main program.</p>
-
-
- <section id="importRelativePathStringasNAME[<metadata>];">
+<p>For paths starting with "~/", the user's home directory is
+substituted for "~".</p>
+<p>For paths starting with "$ORIGIN/", the path of the jq executable
+is substituted for "$ORIGIN".</p>
+<p>For paths starting with "./" or paths that are ".", the path of
+the including file is substituted for ".". For top-level programs
+given on the command-line, the current directory is used.</p>
+<p>Import directives can optionally specify a search path to which
+the default is appended.</p>
+<p>The default search path is the search path given to the <code>-L</code>
+command-line option, else <code>["~/.jq", "$ORIGIN/../lib/jq",
+"$ORIGIN/../lib"]</code>.</p>
+<p>Null and empty string path elements terminate search path
+processing.</p>
+<p>A dependency with relative path "foo/bar" would be searched for in
+"foo/bar.jq" and "foo/bar/bar.jq" in the given search path. This
+is intended to allow modules to be placed in a directory along
+with, for example, version control files, README files, and so on,
+but also to allow for single-file modules.</p>
+<p>Consecutive components with the same name are not allowed to avoid
+ambiguities (e.g., "foo/foo").</p>
+<p>For example, with <code>-L$HOME/.jq</code> a module <code>foo</code> can be found in
+<code>$HOME/.jq/foo.jq</code> and <code>$HOME/.jq/foo/foo.jq</code>.</p>
+<p>If "$HOME/.jq" is a file, it is sourced into the main program.</p>
+
+ <section id="importRelativePathStringasNAME[&lt;metadata&gt;];">
<h3>
-
-<code>import RelativePathString as NAME [&lt;metadata&gt;];</code>
-
+ <code>import RelativePathString as NAME [&lt;metadata&gt;];</code>
</h3>
-
-<p>Imports a module found at the given path relative to a directory in a search path. A “.jq” suffix will be added to the relative path string. The module’s symbols are prefixed with “NAME::”.</p>
-
-<p>The optional metadata must be a constant jq expression. It should be an object with keys like “homepage” and so on. At this time jq only uses the “search” key/value of the metadata. The metadata is also made available to users via the <code>modulemeta</code> builtin.</p>
-
-<p>The “search” key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top-level search path.</p>
-
+ <p>Imports a module found at the given path relative to a
+directory in a search path. A ".jq" suffix will be added to
+the relative path string. The module's symbols are prefixed
+with "NAME::".</p>
+<p>The optional metadata must be a constant jq expression. It
+should be an object with keys like "homepage" and so on. At
+this time jq only uses the "search" key/value of the metadata.
+The metadata is also made available to users via the
+<code>modulemeta</code> builtin.</p>
+<p>The "search" key in the metadata, if present, should have a
+string or array value (array of strings); this is the search
+path to be prefixed to the top-level search path.</p>
</section>
- <section id="includeRelativePathString[<metadata>];">
+ <section id="includeRelativePathString[&lt;metadata&gt;];">
<h3>
-
-<code>include RelativePathString [&lt;metadata&gt;];</code>
-
+ <code>include RelativePathString [&lt;metadata&gt;];</code>
</h3>
-
-<p>Imports a module found at the given path relative to a directory in a search path as if it were included in place. A “.jq” suffix will be added to the relative path string. The module’s symbols are imported into the caller’s namespace as if the module’s content had been included directly.</p>
-
-<p>The optional metadata must be a constant jq expression. It should be an object with keys like “homepage” and so on. At this time jq only uses the “search” key/value of the metadata. The metadata is also made available to users via the <code>modulemeta</code> builtin.</p>
-
+ <p>Imports a module found at the given path relative to a
+directory in a search path as if it were included in place. A
+".jq" suffix will be added to the relative path string. The
+module's symbols are imported into the caller's namespace as
+if the module's content had been included directly.</p>
+<p>The optional metadata must be a constant jq expression. It
+should be an object with keys like "homepage" and so on. At
+this time jq only uses the "search" key/value of the metadata.
+The metadata is also made available to users via the
+<code>modulemeta</code> builtin.</p>
</section>
- <section id="importRelativePathStringas$NAME[<metadata>];">
+ <section id="importRelativePathStringas$NAME[&lt;metadata&gt;];">
<h3>
-
-<code>import RelativePathString as $NAME [&lt;metadata&gt;];</code>
-
+ <code>import RelativePathString as $NAME [&lt;metadata&gt;];</code>
</h3>
-
-<p>Imports a JSON file found at the given path relative to a directory in a search path. A “.json” suffix will be added to the relative path string. The file’s data will be available as <code>$NAME::NAME</code>.</p>
-
-<p>The optional metadata must be a constant jq expression. It should be an object with keys like “homepage” and so on. At this time jq only uses the “search” key/value of the metadata. The metadata is also made available to users via the <code>modulemeta</code> builtin.</p>
-
-<p>The “search” key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top-level search path.</p>
-
+ <p>Imports a JSON file found at the given path relative to a
+directory in a search path. A ".json" suffix will be added to
+the relative path string. The file's data will be available
+as <code>$NAME::NAME</code>.</p>
+<p>The optional metadata must be a constant jq expression. It
+should be an object with keys like "homepage" and so on. At
+this time jq only uses the "search" key/value of the metadata.
+The metadata is also made available to users via the
+<code>modulemeta</code> builtin.</p>
+<p>The "search" key in the metadata, if present, should have a
+string or array value (array of strings); this is the search
+path to be prefixed to the top-level search path.</p>
</section>
- <section id="module<metadata>;">
+ <section id="module&lt;metadata&gt;;">
<h3>
-
-<code>module &lt;metadata&gt;;</code>
-
+ <code>module &lt;metadata&gt;;</code>
</h3>
-
-<p>This directive is entirely optional. It’s not required for proper operation. It serves only the purpose of providing metadata that can be read with the <code>modulemeta</code> builtin.</p>
-
-<p>The metadata must be a constant jq expression. It should be an object with keys like “homepage”. At this time jq doesn’t use this metadata, but it is made available to users via the <code>modulemeta</code> builtin.</p>
-
+ <p>This directive is entirely optional. It's not required for
+proper operation. It serves only the purpose of providing
+metadata that can be read with the <code>modulemeta</code> builtin.</p>
+<p>The metadata must be a constant jq expression. It should be
+an object with keys like "homepage". At this time jq doesn't
+use this metadata, but it is made available to users via the
+<code>modulemeta</code> builtin.</p>
</section>
<section id="modulemeta">
<h3>
-
-<code>modulemeta</code>
-
+ <code>modulemeta</code>
</h3>
-
-<p>Takes a module name as input and outputs the module’s metadata as an object, with the module’s imports (including metadata) as an array value for the “deps” key.</p>
-
-<p>Programs can use this to query a module’s metadata, which they could then use to, for example, search for, download, and install missing dependencies.</p>
-
+ <p>Takes a module name as input and outputs the module's metadata
+as an object, with the module's imports (including metadata)
+as an array value for the "deps" key.</p>
+<p>Programs can use this to query a module's metadata, which they
+could then use to, for example, search for, download, and
+install missing dependencies.</p>
</section>
@@ -7144,63 +7088,42 @@ Complex assignments
<section id="Colors">
<h2>Colors</h2>
-
-<p>To configure alternative colors just set the <code>JQ_COLORS</code> environment variable to colon-delimited list of partial terminal escape sequences like <code>&quot;1;31&quot;</code>, in this order:</p>
-
+ <p>To configure alternative colors just set the <code>JQ_COLORS</code>
+environment variable to colon-delimited list of partial terminal
+escape sequences like <code>"1;31"</code>, in this order:</p>
<ul>
<li>color for <code>null</code></li>
-
<li>color for <code>false</code></li>
-
<li>color for <code>true</code></li>
-
<li>color for numbers</li>
-
<li>color for strings</li>
-
<li>color for arrays</li>
-
<li>color for objects</li>
</ul>
-
-<p>The default color scheme is the same as setting <code>&quot;JQ_COLORS=1;30:0;39:0;39:0;39:0;32:1;39:1;39&quot;</code>.</p>
-
-<p>This is not a manual for VT100/ANSI escapes. However, each of these color specifications should consist of two numbers separated by a semi-colon, where the first number is one of these:</p>
-
+<p>The default color scheme is the same as setting
+<code>"JQ_COLORS=1;30:0;37:0;37:0;37:0;32:1;37:1;37"</code>.</p>
+<p>This is not a manual for VT100/ANSI escapes. However, each of
+these color specifications should consist of two numbers separated
+by a semi-colon, where the first number is one of these:</p>
<ul>
<li>1 (bright)</li>
-
<li>2 (dim)</li>
-
<li>4 (underscore)</li>
-
<li>5 (blink)</li>
-
<li>7 (reverse)</li>
-
<li>8 (hidden)</li>
</ul>
-
<p>and the second is one of these:</p>
-
<ul>
<li>30 (black)</li>
-
<li>31 (red)</li>
-
<li>32 (green)</li>
-
<li>33 (yellow)</li>
-
<li>34 (blue)</li>
-
<li>35 (magenta)</li>
-
<li>36 (cyan)</li>
-
<li>37 (white)</li>
</ul>
-
</section>
@@ -7210,7 +7133,7 @@ Complex assignments
<footer>
<div class="container">
- <p>This website is made with <a href="http://www.tinytree.info">Bonsai</a> and <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
+ <p>This website is made with <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
<p>jq is licensed under the MIT license (code) and the <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a> license (docs).</p>
</div>
</footer>
@@ -7218,7 +7141,6 @@ Complex assignments
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<script src="https://twitter.github.io/typeahead.js/releases/0.11.1/typeahead.bundle.js"></script>
-
<script>
var section_map = {
@@ -7233,7 +7155,7 @@ Complex assignments
"Optional Object Identifier-Index: .foo?" : "OptionalObjectIdentifier-Index:.foo?",
- "Generic Object Index: .[<string>]" : "GenericObjectIndex:.[<string>]",
+ "Generic Object Index: .[\u003cstring\u003e]" : "GenericObjectIndex:.[\u003cstring\u003e]",
"Array Index: .[2]" : "ArrayIndex:.[2]",
@@ -7403,7 +7325,7 @@ Complex assignments
"if-then-else" : "if-then-else",
- ">, >=, <=, <" : ">,>=,<=,<",
+ "\u003e, \u003e=, \u003c=, \u003c" : "\u003e,\u003e=,\u003c=,\u003c",
"and/or/not" : "and/or/not",
@@ -7509,13 +7431,13 @@ Complex assignments
,
- "import RelativePathString as NAME [<metadata>];" : "importRelativePathStringasNAME[<metadata>];",
+ "import RelativePathString as NAME [\u003cmetadata\u003e];" : "importRelativePathStringasNAME[\u003cmetadata\u003e];",
- "include RelativePathString [<metadata>];" : "includeRelativePathString[<metadata>];",
+ "include RelativePathString [\u003cmetadata\u003e];" : "includeRelativePathString[\u003cmetadata\u003e];",
- "import RelativePathString as $NAME [<metadata>];" : "importRelativePathStringas$NAME[<metadata>];",
+ "import RelativePathString as $NAME [\u003cmetadata\u003e];" : "importRelativePathStringas$NAME[\u003cmetadata\u003e];",
- "module <metadata>;" : "module<metadata>;",
+ "module \u003cmetadata\u003e;" : "module\u003cmetadata\u003e;",
"modulemeta" : "modulemeta",
@@ -7530,4 +7452,4 @@ Complex assignments
</script>
<script src="/jq/js/manual-search.js"></script>
</body>
-</html>
+</html> \ No newline at end of file
diff --git a/manual/v1.3/index.html b/manual/v1.3/index.html
index 4b2931f..6ea2c97 100644
--- a/manual/v1.3/index.html
+++ b/manual/v1.3/index.html
@@ -18,7 +18,6 @@
<![endif]-->
</head>
-
<body id="v1.3" data-spy="scroll" data-target="#navcolumn" data-offset="100">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
@@ -56,7 +55,6 @@
</div>
</div>
-
<div class="container">
<div class="row">
<div class="affix" id="navcolumn">
@@ -104,82 +102,90 @@
<div id="manualcontent">
<h1>jq 1.3 Manual</h1>
<p><em>The manual for the development version of jq can be found
-<a href='/jq/manual'>here</a>.</em></p>
- <p>A jq program is a &ldquo;filter&rdquo;: it takes an input, and produces an
+<a href="/jq/manual">here</a>.</em></p>
+ <p>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.</p><p>Filters can be combined in various ways - you can pipe the output of
+or various other standard tasks.</p>
+<p>Filters can be combined in various ways - you can pipe the output of
one filter into another filter, or collect the output of a filter
-into an array.</p><p>Some filters produce multiple results, for instance there&rsquo;s one that
+into an array.</p>
+<p>Some filters produce multiple results, for instance there's one that
produces all the elements of its input array. Piping that filter
into a second runs the second filter for each element of the
array. Generally, things that would be done with loops and iteration
-in other languages are just done by gluing filters together in jq.</p><p>It&rsquo;s important to remember that every filter has an input and an
-output. Even literals like &ldquo;hello&rdquo; or 42 are filters - they take an
+in other languages are just done by gluing filters together in jq.</p>
+<p>It's important to remember that every filter has an input and an
+output. Even literals like "hello" or 42 are filters - they take an
input but always produce the same literal as output. Operations that
combine two filters, like addition, generally feed the same input to
both and combine the results. So, you can implement an averaging
filter as <code>add / length</code> - feeding the input array both to the <code>add</code>
-filter and the <code>length</code> filter and dividing the results.</p><p>But that&rsquo;s getting ahead of ourselves. :) Let&rsquo;s start with something
+filter and the <code>length</code> filter and dividing the results.</p>
+<p>But that's getting ahead of ourselves. :) Let's start with something
simpler:</p>
<section id="Invokingjq">
<h2>Invoking jq</h2>
-
-<p>jq filters run on a stream of JSON data. The input to jq is parsed as a sequence of whitespace-separated JSON values which are passed through the provided filter one at a time. The output(s) of the filter are written to standard out, again as a sequence of whitespace-separated JSON data.</p>
-
-<p>You can affect how jq reads and writes its input and output using some command-line options:</p>
-
+ <p>jq filters run on a stream of JSON data. The input to jq is
+parsed as a sequence of whitespace-separated JSON values which
+are passed through the provided filter one at a time. The
+output(s) of the filter are written to standard out, again as a
+sequence of whitespace-separated JSON data.</p>
+<p>You can affect how jq reads and writes its input and output
+using some command-line options:</p>
<ul>
-<li>
-<p><code>--slurp</code>/<code>-s</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--raw-input</code>/<code>-R</code>:</p>
-
-<p>Don’t parse the input as JSON. Instead, each line of text is passed to the filter as a string. If combined with <code>--slurp</code>, then the entire input is passed to the filter as a single long string.</p>
-</li>
-
-<li>
-<p><code>--null-input</code>/<code>-n</code>:</p>
-
-<p>Don’t read any input at all! Instead, the filter is run once using <code>null</code> as the input. This is useful when using jq as a simple calculator or to construct JSON data from scratch.</p>
-</li>
-
-<li>
-<p><code>--compact-output</code> / <code>-c</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--color-output</code> / <code>-C</code> and <code>--monochrome-output</code> / <code>-M</code>:</p>
-
-<p>By default, jq outputs colored JSON if writing to a terminal. You can force it to produce color even if writing to a pipe or a file using <code>-C</code>, and disable color with <code>-M</code>.</p>
-</li>
-
-<li>
-<p><code>--ascii-output</code> / <code>-a</code>:</p>
-
-<p>jq usually outputs non-ASCII Unicode codepoints as UTF-8, even if the input specified them as escape sequences (like “\u03bc”). Using this option, you can force jq to produce pure ASCII output with every non-ASCII character replaced with the equivalent escape sequence.</p>
-</li>
-
-<li>
-<p><code>--raw-output</code> / <code>-r</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--arg name value</code>:</p>
-
-<p>This option passes a value to the jq program as a predefined variable. If you run jq with <code>--arg foo bar</code>, then <code>$foo</code> is available in the program and has the value <code>&quot;bar&quot;</code>.</p>
-</li>
+<li><code>--slurp</code>/<code>-s</code>:</li>
</ul>
-
+<p>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.</p>
+<ul>
+<li><code>--raw-input</code>/<code>-R</code>:</li>
+</ul>
+<p>Don't parse the input as JSON. Instead, each line of text is
+ passed to the filter as a string. If combined with <code>--slurp</code>,
+ then the entire input is passed to the filter as a single long
+ string.</p>
+<ul>
+<li><code>--null-input</code>/<code>-n</code>:</li>
+</ul>
+<p>Don't read any input at all! Instead, the filter is run once
+ using <code>null</code> as the input. This is useful when using jq as a
+ simple calculator or to construct JSON data from scratch.</p>
+<ul>
+<li><code>--compact-output</code> / <code>-c</code>:</li>
+</ul>
+<p>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.</p>
+<ul>
+<li><code>--color-output</code> / <code>-C</code> and <code>--monochrome-output</code> / <code>-M</code>:</li>
+</ul>
+<p>By default, jq outputs colored JSON if writing to a
+ terminal. You can force it to produce color even if writing to
+ a pipe or a file using <code>-C</code>, and disable color with <code>-M</code>.</p>
+<ul>
+<li><code>--ascii-output</code> / <code>-a</code>:</li>
+</ul>
+<p>jq usually outputs non-ASCII Unicode codepoints as UTF-8, even
+ if the input specified them as escape sequences (like
+ "\u03bc"). Using this option, you can force jq to produce pure
+ ASCII output with every non-ASCII character replaced with the
+ equivalent escape sequence.</p>
+<ul>
+<li><code>--raw-output</code> / <code>-r</code>:</li>
+</ul>
+<p>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.</p>
+<ul>
+<li><code>--arg name value</code>:</li>
+</ul>
+<p>This option passes a value to the jq program as a predefined
+ variable. If you run jq with <code>--arg foo bar</code>, then <code>$foo</code> is
+ available in the program and has the value <code>"bar"</code>.</p>
</section>
@@ -189,16 +195,15 @@ simpler:</p>
<section id=".">
<h3>
-
-<code>.</code>
-
+ <code>.</code>
</h3>
-
-<p>The absolute simplest (and least interesting) filter is <code>.</code>. This is a filter that takes its input and produces it unchanged as output.</p>
-
-<p>Since jq by default pretty-prints all output, this trivial program can be a useful way of formatting JSON output from, say, <code>curl</code>.</p>
-
+ <p>The absolute simplest (and least interesting) filter
+is <code>.</code>. This is a filter that takes its input and
+produces it unchanged as output.</p>
+<p>Since jq by default pretty-prints all output, this trivial
+program can be a useful way of formatting JSON output from,
+say, <code>curl</code>.</p>
<div>
@@ -211,14 +216,14 @@ simpler:</p>
<table>
<tr><th></th><td class="jqprogram">jq '.'</td></tr>
- <tr><th>Input</th><td>&quot;Hello, world!&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;Hello, world!&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;Hello, world!&quot;</td>
+ <td>&#34;Hello, world!&#34;</td>
</tr>
</table>
@@ -230,14 +235,12 @@ simpler:</p>
<section id=".foo">
<h3>
-
-<code>.foo</code>
-
+ <code>.foo</code>
</h3>
-
-<p>The simplest <em>useful</em> filter is .foo. When given a JSON object (aka dictionary or hash) as input, it produces the value at the key “foo”, or null if there’s none present.</p>
-
+ <p>The simplest <em>useful</em> filter is .foo. When given a
+JSON object (aka dictionary or hash) as input, it produces
+the value at the key "foo", or null if there's none present.</p>
<div>
@@ -250,7 +253,7 @@ simpler:</p>
<table>
<tr><th></th><td class="jqprogram">jq '.foo'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;less interesting data&quot;}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;less interesting data&#34;}</td></tr>
<tr>
@@ -264,7 +267,7 @@ simpler:</p>
<table>
<tr><th></th><td class="jqprogram">jq '.foo'</td></tr>
- <tr><th>Input</th><td>{&quot;notfoo&quot;: true, &quot;alsonotfoo&quot;: false}</td></tr>
+ <tr><th>Input</th><td>{&#34;notfoo&#34;: true, &#34;alsonotfoo&#34;: false}</td></tr>
<tr>
@@ -283,16 +286,20 @@ simpler:</p>
<section id=".[foo],.[2],.[10:15]">
<h3>
-
-<code>.[foo]</code>, <code>.[2]</code>, <code>.[10:15]</code>
-
+ <code>.[foo]</code>, <code>.[2]</code>, <code>.[10:15]</code>
</h3>
-
-<p>You can also look up fields of an object using syntax like <code>.[&quot;foo&quot;]</code> (.foo above is a shorthand version of this). This one works for arrays as well, if the key is an integer. Arrays are zero-based (like javascript), so <code>.[2]</code> returns the third element of the array.</p>
-
-<p>The <code>.[10:15]</code> syntax can be used to return a subarray of an array. The array returned by <code>.[10:15]</code> will be of length 5, containing the elements from index 10 (inclusive) to index 15 (exclusive). Either index may be negative (in which case it counts backwards from the end of the array), or omitted (in which case it refers to the start or end of the array).</p>
-
+ <p>You can also look up fields of an object using syntax like
+<code>.["foo"]</code> (.foo above is a shorthand version of this). This
+one works for arrays as well, if the key is an
+integer. Arrays are zero-based (like javascript), so <code>.[2]</code>
+returns the third element of the array.</p>
+<p>The <code>.[10:15]</code> syntax can be used to return a subarray of an
+array. The array returned by <code>.[10:15]</code> will be of length 5,
+containing the elements from index 10 (inclusive) to index
+15 (exclusive). Either index may be negative (in which case
+it counts backwards from the end of the array), or omitted
+(in which case it refers to the start or end of the array).</p>
<div>
@@ -305,21 +312,21 @@ simpler:</p>
<table>
<tr><th></th><td class="jqprogram">jq '.[0]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}</td>
+ <td>{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[2]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
@@ -333,42 +340,42 @@ simpler:</p>
<table>
<tr><th></th><td class="jqprogram">jq '.[2:4]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;c&quot;, &quot;d&quot;]</td>
+ <td>[&#34;c&#34;, &#34;d&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[:3]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</td>
+ <td>[&#34;a&#34;, &#34;b&#34;, &#34;c&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[-2:]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;d&quot;, &quot;e&quot;]</td>
+ <td>[&#34;d&#34;, &#34;e&#34;]</td>
</tr>
</table>
@@ -380,16 +387,16 @@ simpler:</p>
<section id=".[]">
<h3>
-
-<code>.[]</code>
-
+ <code>.[]</code>
</h3>
-
-<p>If you use the <code>.[foo]</code> syntax, but omit the index entirely, it will return <em>all</em> of the elements of an array. Running <code>.[]</code> with the input <code>[1,2,3]</code> will produce the numbers as three separate results, rather than as a single array.</p>
-
-<p>You can also use this on an object, and it will return all the values of the object.</p>
-
+ <p>If you use the <code>.[foo]</code> syntax, but omit the index
+entirely, it will return <em>all</em> of the elements of an
+array. Running <code>.[]</code> with the input <code>[1,2,3]</code> will produce the
+numbers as three separate results, rather than as a single
+array.</p>
+<p>You can also use this on an object, and it will return all
+the values of the object.</p>
<div>
@@ -402,21 +409,21 @@ simpler:</p>
<table>
<tr><th></th><td class="jqprogram">jq '.[]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}</td>
+ <td>{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}</td>
+ <td>{&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}</td>
</tr>
</table>
@@ -435,7 +442,7 @@ simpler:</p>
<table>
<tr><th></th><td class="jqprogram">jq '.[]'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 1}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 1}</td></tr>
<tr>
@@ -461,14 +468,15 @@ simpler:</p>
<section id=",">
<h3>
-
-<code>,</code>
-
+ <code>,</code>
</h3>
-
-<p>If two filters are separated by a comma, then the input will be fed into both and there will be multiple outputs: first, all of the outputs produced by the left expression, and then all of the outputs produced by the right. For instance, filter <code>.foo, .bar</code>, produces both the “foo” fields and “bar” fields as separate outputs.</p>
-
+ <p>If two filters are separated by a comma, then the
+input will be fed into both and there will be multiple
+outputs: first, all of the outputs produced by the left
+expression, and then all of the outputs produced by the
+right. For instance, filter <code>.foo, .bar</code>, produces
+both the "foo" fields and "bar" fields as separate outputs.</p>
<div>
@@ -481,7 +489,7 @@ simpler:</p>
<table>
<tr><th></th><td class="jqprogram">jq '.foo, .bar'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;something else&quot;, &quot;baz&quot;: true}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;something else&#34;, &#34;baz&#34;: true}</td></tr>
<tr>
@@ -495,56 +503,56 @@ simpler:</p>
<th></th>
- <td>&quot;something else&quot;</td>
+ <td>&#34;something else&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.user, .projects[]'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;projects&quot;: [&quot;jq&quot;, &quot;wikiflow&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;projects&#34;: [&#34;jq&#34;, &#34;wikiflow&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>&quot;stedolan&quot;</td>
+ <td>&#34;stedolan&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;jq&quot;</td>
+ <td>&#34;jq&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;wikiflow&quot;</td>
+ <td>&#34;wikiflow&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[4,2]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;e&quot;</td>
+ <td>&#34;e&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;c&quot;</td>
+ <td>&#34;c&#34;</td>
</tr>
</table>
@@ -556,16 +564,17 @@ simpler:</p>
<section id="|">
<h3>
-
-<code>|</code>
-
+ <code>|</code>
</h3>
-
-<p>The | operator combines two filters by feeding the output(s) of the one on the left into the input of the one on the right. It’s pretty much the same as the Unix shell’s pipe, if you’re used to that.</p>
-
-<p>If the one on the left produces multiple results, the one on the right will be run for each of those results. So, the expression <code>.[] | .foo</code> retrieves the “foo” field of each element of the input array.</p>
-
+ <p>The | operator combines two filters by feeding the output(s) of
+the one on the left into the input of the one on the right. It's
+pretty much the same as the Unix shell's pipe, if you're used to
+that.</p>
+<p>If the one on the left produces multiple results, the one on
+the right will be run for each of those results. So, the
+expression <code>.[] | .foo</code> retrieves the "foo" field of each
+element of the input array.</p>
<div>
@@ -578,21 +587,21 @@ simpler:</p>
<table>
<tr><th></th><td class="jqprogram">jq '.[] | .name'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;JSON&quot;</td>
+ <td>&#34;JSON&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;XML&quot;</td>
+ <td>&#34;XML&#34;</td>
</tr>
</table>
@@ -606,26 +615,35 @@ simpler:</p>
<section id="TypesandValues">
<h2>Types and Values</h2>
-
-<p>jq supports the same set of datatypes as JSON - numbers, strings, booleans, arrays, objects (which in JSON-speak are hashes with only string keys), and “null”.</p>
-
-<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 - <code>42</code> is a valid jq expression that takes an input, ignores it, and returns 42 instead.</p>
-
+ <p>jq supports the same set of datatypes as JSON - numbers,
+strings, booleans, arrays, objects (which in JSON-speak are
+hashes with only string keys), and "null".</p>
+<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 - <code>42</code> is a valid jq
+expression that takes an input, ignores it, and returns 42
+instead.</p>
<section id="Arrayconstruction-[]">
<h3>
-
-Array construction - <code>[]</code>
-
+ Array construction - <code>[]</code>
</h3>
-
-<p>As in JSON, <code>[]</code> is used to construct arrays, as in <code>[1,2,3]</code>. The elements of the arrays can be any jq expression. 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 <code>[.foo, .bar, .baz]</code>) or to “collect” all the results of a filter into an array (as in <code>[.items[].name]</code>)</p>
-
-<p>Once you understand the “,” operator, you can look at jq’s array syntax in a different light: the expression <code>[1,2,3]</code> is not using a built-in syntax for comma-separated arrays, but is instead applying the <code>[]</code> operator (collect results) to the expression 1,2,3 (which produces three different results).</p>
-
-<p>If you have a filter <code>X</code> that produces four results, then the expression <code>[X]</code> will produce a single result, an array of four elements.</p>
-
+ <p>As in JSON, <code>[]</code> is used to construct arrays, as in
+<code>[1,2,3]</code>. The elements of the arrays can be any jq
+expression. 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 <code>[.foo, .bar, .baz]</code>) or to "collect" all the results of a
+filter into an array (as in <code>[.items[].name]</code>)</p>
+<p>Once you understand the "," operator, you can look at jq's array
+syntax in a different light: the expression <code>[1,2,3]</code> is not using a
+built-in syntax for comma-separated arrays, but is instead applying
+the <code>[]</code> operator (collect results) to the expression 1,2,3 (which
+produces three different results).</p>
+<p>If you have a filter <code>X</code> that produces four results,
+then the expression <code>[X]</code> will produce a single result, an
+array of four elements.</p>
<div>
@@ -638,14 +656,14 @@ Array construction - <code>[]</code>
<table>
<tr><th></th><td class="jqprogram">jq '[.user, .projects[]]'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;projects&quot;: [&quot;jq&quot;, &quot;wikiflow&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;projects&#34;: [&#34;jq&#34;, &#34;wikiflow&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;stedolan&quot;, &quot;jq&quot;, &quot;wikiflow&quot;]</td>
+ <td>[&#34;stedolan&#34;, &#34;jq&#34;, &#34;wikiflow&#34;]</td>
</tr>
</table>
@@ -657,45 +675,45 @@ Array construction - <code>[]</code>
<section id="Objects-{}">
<h3>
-
-Objects - <code>{}</code>
-
+ Objects - <code>{}</code>
</h3>
-
-<p>Like JSON, <code>{}</code> is for constructing objects (aka dictionaries or hashes), as in: <code>{&quot;a&quot;: 42, &quot;b&quot;: 17}</code>.</p>
-
-<p>If the keys are “sensible” (all alphabetic characters), then the quotes can be left off. 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).</p>
-
-<pre><code>{foo: .bar}</code></pre>
-
-<p>will produce the JSON object <code>{&quot;foo&quot;: 42}</code> if given the JSON object <code>{&quot;bar&quot;:42, &quot;baz&quot;:43}</code>. You can use this to select particular fields of an object: if the input is an object with “user”, “title”, “id”, and “content” fields and you just want “user” and “title”, you can write</p>
-
-<pre><code>{user: .user, title: .title}</code></pre>
-
-<p>Because that’s so common, there’s a shortcut syntax: <code>{user, title}</code>.</p>
-
-<p>If one of the expressions produces multiple results, multiple dictionaries will be produced. If the input’s</p>
-
-<pre><code>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</code></pre>
-
+ <p>Like JSON, <code>{}</code> is for constructing objects (aka
+dictionaries or hashes), as in: <code>{"a": 42, "b": 17}</code>.</p>
+<p>If the keys are "sensible" (all alphabetic characters), then
+the quotes can be left off. 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).</p>
+<pre><code>{foo: .bar}
+</code></pre>
+<p>will produce the JSON object <code>{"foo": 42}</code> if given the JSON
+object <code>{"bar":42, "baz":43}</code>. You can use this to select
+particular fields of an object: if the input is an object
+with "user", "title", "id", and "content" fields and you
+just want "user" and "title", you can write</p>
+<pre><code>{user: .user, title: .title}
+</code></pre>
+<p>Because that's so common, there's a shortcut syntax: <code>{user, title}</code>.</p>
+<p>If one of the expressions produces multiple results,
+multiple dictionaries will be produced. If the input's</p>
+<pre><code>{"user":"stedolan","titles":["JQ Primer", "More JQ"]}
+</code></pre>
<p>then the expression</p>
-
-<pre><code>{user, title: .titles[]}</code></pre>
-
+<pre><code>{user, title: .titles[]}
+</code></pre>
<p>will produce two outputs:</p>
-
-<pre><code>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;JQ Primer&quot;}
-{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;More JQ&quot;}</code></pre>
-
-<p>Putting parentheses around the key means it will be evaluated as an expression. With the same input as above,</p>
-
-<pre><code>{(.user): .titles}</code></pre>
-
+<pre><code>{"user":"stedolan", "title": "JQ Primer"}
+{"user":"stedolan", "title": "More JQ"}
+</code></pre>
+<p>Putting parentheses around the key means it will be evaluated as an
+expression. With the same input as above,</p>
+<pre><code>{(.user): .titles}
+</code></pre>
<p>produces</p>
-
-<pre><code>{&quot;stedolan&quot;: [&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</code></pre>
-
+<pre><code>{"stedolan": ["JQ Primer", "More JQ"]}
+</code></pre>
<div>
@@ -708,35 +726,35 @@ Objects - <code>{}</code>
<table>
<tr><th></th><td class="jqprogram">jq '{user, title: .titles[]}'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;,&#34;titles&#34;:[&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;JQ Primer&quot;}</td>
+ <td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;title&#34;: &#34;JQ Primer&#34;}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;More JQ&quot;}</td>
+ <td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;title&#34;: &#34;More JQ&#34;}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '{(.user): .titles}'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;,&#34;titles&#34;:[&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;stedolan&quot;: [&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td>
+ <td>{&#34;stedolan&#34;: [&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td>
</tr>
</table>
@@ -750,40 +768,39 @@ Objects - <code>{}</code>
<section id="Builtinoperatorsandfunctions">
<h2>Builtin operators and functions</h2>
-
-<p>Some jq operator (for instance, <code>+</code>) 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>
-
+ <p>Some jq operator (for instance, <code>+</code>) 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>
<section id="Addition-+">
<h3>
-
-Addition - <code>+</code>
-
+ Addition - <code>+</code>
</h3>
-
-<p>The operator <code>+</code> takes two filters, applies them both to the same input, and adds the results together. What “adding” means depends on the types involved:</p>
-
+ <p>The operator <code>+</code> takes two filters, applies them both
+to the same input, and adds the results together. What
+"adding" means depends on the types involved:</p>
<ul>
<li>
<p><strong>Numbers</strong> are added by normal arithmetic.</p>
</li>
-
<li>
<p><strong>Arrays</strong> are added by being concatenated into a larger array.</p>
</li>
-
<li>
<p><strong>Strings</strong> are added by being joined into a larger string.</p>
</li>
-
<li>
-<p><strong>Objects</strong> are added by merging, that is, inserting all the key-value pairs from both objects into a single combined object. If both objects contain a value for the same key, the object on the right of the <code>+</code> wins.</p>
+<p><strong>Objects</strong> are added by merging, that is, inserting all
+ the key-value pairs from both objects into a single
+ combined object. If both objects contain a value for the
+ same key, the object on the right of the <code>+</code> wins.</p>
</li>
</ul>
-
-<p><code>null</code> can be added to any value, and returns the other value unchanged.</p>
-
+<p><code>null</code> can be added to any value, and returns the other
+value unchanged.</p>
<div>
@@ -796,7 +813,7 @@ Addition - <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + 1'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 7}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 7}</td></tr>
<tr>
@@ -810,7 +827,7 @@ Addition - <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + .b'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: [1,2], &quot;b&quot;: [3,4]}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: [1,2], &#34;b&#34;: [3,4]}</td></tr>
<tr>
@@ -824,7 +841,7 @@ Addition - <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + null'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1}</td></tr>
<tr>
@@ -859,7 +876,7 @@ Addition - <code>+</code>
<th>Output</th>
- <td>{&quot;a&quot;: 42, &quot;b&quot;: 2, &quot;c&quot;: 3}</td>
+ <td>{&#34;a&#34;: 42, &#34;b&#34;: 2, &#34;c&#34;: 3}</td>
</tr>
</table>
@@ -871,14 +888,12 @@ Addition - <code>+</code>
<section id="Subtraction--">
<h3>
-
-Subtraction - <code>-</code>
-
+ Subtraction - <code>-</code>
</h3>
-
-<p>As well as normal arithmetic subtraction on numbers, the <code>-</code> operator can be used on arrays to remove all occurences of the second array’s elements from the first array.</p>
-
+ <p>As well as normal arithmetic subtraction on numbers, the <code>-</code>
+operator can be used on arrays to remove all occurrences of
+the second array's elements from the first array.</p>
<div>
@@ -891,7 +906,7 @@ Subtraction - <code>-</code>
<table>
<tr><th></th><td class="jqprogram">jq '4 - .a'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:3}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:3}</td></tr>
<tr>
@@ -904,15 +919,15 @@ Subtraction - <code>-</code>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '. - [&quot;xml&quot;, &quot;yaml&quot;]'</td></tr>
- <tr><th>Input</th><td>[&quot;xml&quot;, &quot;yaml&quot;, &quot;json&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '. - [&#34;xml&#34;, &#34;yaml&#34;]'</td></tr>
+ <tr><th>Input</th><td>[&#34;xml&#34;, &#34;yaml&#34;, &#34;json&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;json&quot;]</td>
+ <td>[&#34;json&#34;]</td>
</tr>
</table>
@@ -924,14 +939,10 @@ Subtraction - <code>-</code>
<section id="Multiplication,division-*and/">
<h3>
-
-Multiplication, division - <code>*</code> and <code>/</code>
-
+ Multiplication, division - <code>*</code> and <code>/</code>
</h3>
-
-<p>These operators only work on numbers, and do the expected.</p>
-
+ <p>These operators only work on numbers, and do the expected.</p>
<div>
@@ -963,33 +974,28 @@ Multiplication, division - <code>*</code> and <code>/</code>
<section id="length">
<h3>
-
-<code>length</code>
-
+ <code>length</code>
</h3>
-
-<p>The builtin function <code>length</code> gets the length of various different types of value:</p>
-
+ <p>The builtin function <code>length</code> gets the length of various
+different types of value:</p>
<ul>
<li>
-<p>The length of a <strong>string</strong> is the number of Unicode codepoints it contains (which will be the same as its JSON-encoded length in bytes if it’s pure ASCII).</p>
+<p>The length of a <strong>string</strong> is the number of Unicode
+ codepoints it contains (which will be the same as its
+ JSON-encoded length in bytes if it's pure ASCII).</p>
</li>
-
<li>
<p>The length of an <strong>array</strong> is the number of elements.</p>
</li>
-
<li>
<p>The length of an <strong>object</strong> is the number of key-value pairs.</p>
</li>
-
<li>
<p>The length of <strong>null</strong> is zero.</p>
</li>
</ul>
-
<div>
@@ -1001,7 +1007,7 @@ Multiplication, division - <code>*</code> and <code>/</code>
<table>
<tr><th></th><td class="jqprogram">jq '.[] | length'</td></tr>
- <tr><th>Input</th><td>[[1,2], &quot;string&quot;, {&quot;a&quot;:2}, null]</td></tr>
+ <tr><th>Input</th><td>[[1,2], &#34;string&#34;, {&#34;a&#34;:2}, null]</td></tr>
<tr>
@@ -1041,18 +1047,18 @@ Multiplication, division - <code>*</code> and <code>/</code>
<section id="keys">
<h3>
-
-<code>keys</code>
-
+ <code>keys</code>
</h3>
-
-<p>The builtin function <code>keys</code>, when given an object, returns its keys in an array.</p>
-
-<p>The keys are sorted “alphabetically”, by unicode codepoint order. This is not an order that makes particular sense in any particular language, but you can count on it being the same for any two objects with the same set of keys, regardless of locale settings.</p>
-
-<p>When <code>keys</code> is given an array, it returns the valid indices for that array: the integers from 0 to length-1.</p>
-
+ <p>The builtin function <code>keys</code>, when given an object, returns
+its keys in an array.</p>
+<p>The keys are sorted "alphabetically", by unicode codepoint
+order. This is not an order that makes particular sense in
+any particular language, but you can count on it being the
+same for any two objects with the same set of keys,
+regardless of locale settings.</p>
+<p>When <code>keys</code> is given an array, it returns the valid indices
+for that array: the integers from 0 to length-1.</p>
<div>
@@ -1065,14 +1071,14 @@ Multiplication, division - <code>*</code> and <code>/</code>
<table>
<tr><th></th><td class="jqprogram">jq 'keys'</td></tr>
- <tr><th>Input</th><td>{&quot;abc&quot;: 1, &quot;abcd&quot;: 2, &quot;Foo&quot;: 3}</td></tr>
+ <tr><th>Input</th><td>{&#34;abc&#34;: 1, &#34;abcd&#34;: 2, &#34;Foo&#34;: 3}</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;Foo&quot;, &quot;abc&quot;, &quot;abcd&quot;]</td>
+ <td>[&#34;Foo&#34;, &#34;abc&#34;, &#34;abcd&#34;]</td>
</tr>
</table>
@@ -1098,16 +1104,15 @@ Multiplication, division - <code>*</code> and <code>/</code>
<section id="has">
<h3>
-
-<code>has</code>
-
+ <code>has</code>
</h3>
-
-<p>The builtin function <code>has</code> returns whether the input object has the given key, or the input array has an element at the given index.</p>
-
-<p><code>has($key)</code> has the same effect as checking whether <code>$key</code> is a member of the array returned by <code>keys</code>, although <code>has</code> will be faster.</p>
-
+ <p>The builtin function <code>has</code> returns whether the input object
+has the given key, or the input array has an element at the
+given index.</p>
+<p><code>has($key)</code> has the same effect as checking whether <code>$key</code>
+is a member of the array returned by <code>keys</code>, although <code>has</code>
+will be faster.</p>
<div>
@@ -1119,8 +1124,8 @@ Multiplication, division - <code>*</code> and <code>/</code>
<div id="example14" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'map(has(&quot;foo&quot;))'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;: 42}, {}]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'map(has(&#34;foo&#34;))'</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;: 42}, {}]</td></tr>
<tr>
@@ -1134,7 +1139,7 @@ Multiplication, division - <code>*</code> and <code>/</code>
<table>
<tr><th></th><td class="jqprogram">jq 'map(has(2))'</td></tr>
- <tr><th>Input</th><td>[[0,1], [&quot;a&quot;,&quot;b&quot;,&quot;c&quot;]]</td></tr>
+ <tr><th>Input</th><td>[[0,1], [&#34;a&#34;,&#34;b&#34;,&#34;c&#34;]]</td></tr>
<tr>
@@ -1153,17 +1158,17 @@ Multiplication, division - <code>*</code> and <code>/</code>
<section id="to_entries,from_entries,with_entries">
<h3>
-
-<code>to_entries</code>, <code>from_entries</code>, <code>with_entries</code>
-
+ <code>to_entries</code>, <code>from_entries</code>, <code>with_entries</code>
</h3>
-
-<p>These functions convert between an object and an array of key-value pairs. If <code>to_entries</code> is passed an object, then for each <code>k: v</code> entry in the input, the output array includes <code>{&quot;key&quot;: k, &quot;value&quot;: v}</code>.</p>
-
-<p><code>from_entries</code> does the opposite conversion, and <code>with_entries(foo)</code> is a shorthand for <code>to_entries |
-map(foo) | from_entries</code>, useful for doing some operation to all keys and values of an object.</p>
-
+ <p>These functions convert between an object and an array of
+key-value pairs. If <code>to_entries</code> is passed an object, then
+for each <code>k: v</code> entry in the input, the output array
+includes <code>{"key": k, "value": v}</code>.</p>
+<p><code>from_entries</code> does the opposite conversion, and
+<code>with_entries(foo)</code> is a shorthand for <code>to_entries |
+map(foo) | from_entries</code>, useful for doing some operation to
+all keys and values of an object.</p>
<div>
@@ -1176,42 +1181,42 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'to_entries'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;key&quot;:&quot;a&quot;, &quot;value&quot;:1}, {&quot;key&quot;:&quot;b&quot;, &quot;value&quot;:2}]</td>
+ <td>[{&#34;key&#34;:&#34;a&#34;, &#34;value&#34;:1}, {&#34;key&#34;:&#34;b&#34;, &#34;value&#34;:2}]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'from_entries'</td></tr>
- <tr><th>Input</th><td>[{&quot;key&quot;:&quot;a&quot;, &quot;value&quot;:1}, {&quot;key&quot;:&quot;b&quot;, &quot;value&quot;:2}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;key&#34;:&#34;a&#34;, &#34;value&#34;:1}, {&#34;key&#34;:&#34;b&#34;, &#34;value&#34;:2}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td>
+ <td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'with_entries(.key |= &quot;KEY_&quot; + .)'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'with_entries(.key |= &#34;KEY_&#34; + .)'</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;KEY_a&quot;: 1, &quot;KEY_b&quot;: 2}</td>
+ <td>{&#34;KEY_a&#34;: 1, &#34;KEY_b&#34;: 2}</td>
</tr>
</table>
@@ -1223,16 +1228,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="select">
<h3>
-
-<code>select</code>
-
+ <code>select</code>
</h3>
-
-<p>The function <code>select(foo)</code> produces its input unchanged if <code>foo</code> returns true for that input, and produces no output otherwise.</p>
-
-<p>It’s useful for filtering lists: <code>[1,2,3] | map(select(. &gt;= 2))</code> will give you <code>[3]</code>.</p>
-
+ <p>The function <code>select(foo)</code> produces its input unchanged if
+<code>foo</code> returns true for that input, and produces no output
+otherwise.</p>
+<p>It's useful for filtering lists: '<code>[1,2,3] | map(select(. &gt;= 2))</code>'
+will give you <code>[3]</code>.</p>
<div>
@@ -1264,16 +1267,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="empty">
<h3>
-
-<code>empty</code>
-
+ <code>empty</code>
</h3>
-
-<p><code>empty</code> returns no results. None at all. Not even <code>null</code>.</p>
-
-<p>It’s useful on occasion. You’ll know if you need it :)</p>
-
+ <p><code>empty</code> returns no results. None at all. Not even <code>null</code>.</p>
+<p>It's useful on occasion. You'll know if you need it :)</p>
<div>
@@ -1326,16 +1324,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="map(x)">
<h3>
-
-<code>map(x)</code>
-
+ <code>map(x)</code>
</h3>
-
-<p>For any filter <code>x</code>, <code>map(x)</code> will run that filter for each element of the input array, and produce the outputs a new array. <code>map(.+1)</code> will increment each element of an array of numbers.</p>
-
-<p><code>map(x)</code> is equivalent to <code>[.[] | x]</code>. In fact, this is how it’s defined.</p>
-
+ <p>For any filter <code>x</code>, <code>map(x)</code> will run that filter for each
+element of the input array, and produce the outputs a new
+array. <code>map(.+1)</code> will increment each element of an array of numbers.</p>
+<p><code>map(x)</code> is equivalent to <code>[.[] | x]</code>. In fact, this is how
+it's defined.</p>
<div>
@@ -1367,17 +1363,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="add">
<h3>
-
-<code>add</code>
-
+ <code>add</code>
</h3>
-
-<p>The filter <code>add</code> takes as input an array, and produces as output the elements of the array added together. This might mean summed, concatenated or merged depending on the types of the elements of the input array - the rules are the same as those for the <code>+</code> operator (described above).</p>
-
+ <p>The filter <code>add</code> takes as input an array, and produces as
+output the elements of the array added together. This might
+mean summed, concatenated or merged depending on the types
+of the elements of the input array - the rules are the same
+as those for the <code>+</code> operator (described above).</p>
<p>If the input is an empty array, <code>add</code> returns <code>null</code>.</p>
-
<div>
@@ -1389,14 +1384,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'add'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;abc&quot;</td>
+ <td>&#34;abc&#34;</td>
</tr>
</table>
@@ -1436,14 +1431,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="range">
<h3>
-
-<code>range</code>
-
+ <code>range</code>
</h3>
-
-<p>The <code>range</code> function produces a range of numbers. <code>range(4;10)</code> produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers are produced as separate outputs. Use <code>[range(4;10)]</code> to get a range as an array.</p>
-
+ <p>The <code>range</code> function produces a range of numbers. <code>range(4;10)</code>
+produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers
+are produced as separate outputs. Use <code>[range(4;10)]</code> to get a range as
+an array.</p>
<div>
@@ -1496,14 +1490,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="tonumber">
<h3>
-
-<code>tonumber</code>
-
+ <code>tonumber</code>
</h3>
-
-<p>The <code>tonumber</code> function parses its input as a number. It will convert correctly-formatted strings to their numeric equivalent, leave numbers alone, and give an error on all other input.</p>
-
+ <p>The <code>tonumber</code> function parses its input as a number. It
+will convert correctly-formatted strings to their numeric
+equivalent, leave numbers alone, and give an error on all other input.</p>
<div>
@@ -1516,7 +1508,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[] | tonumber'</td></tr>
- <tr><th>Input</th><td>[1, &quot;1&quot;]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;1&#34;]</td></tr>
<tr>
@@ -1542,14 +1534,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="tostring">
<h3>
-
-<code>tostring</code>
-
+ <code>tostring</code>
</h3>
-
-<p>The <code>tostring</code> function prints its input as a string. Strings are left unchanged, and all other values are JSON-encoded.</p>
-
+ <p>The <code>tostring</code> function prints its input as a
+string. Strings are left unchanged, and all other values are
+JSON-encoded.</p>
<div>
@@ -1562,28 +1552,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[] | tostring'</td></tr>
- <tr><th>Input</th><td>[1, &quot;1&quot;, [1]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;1&#34;, [1]]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;1&quot;</td>
+ <td>&#34;1&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;1&quot;</td>
+ <td>&#34;1&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;[1]&quot;</td>
+ <td>&#34;[1]&#34;</td>
</tr>
</table>
@@ -1595,14 +1585,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="type">
<h3>
-
-<code>type</code>
-
+ <code>type</code>
</h3>
-
-<p>The <code>type</code> function returns the type of its argument as a string, which is one of null, boolean, number, string, array or object.</p>
-
+ <p>The <code>type</code> function returns the type of its argument as a
+string, which is one of null, boolean, number, string, array
+or object.</p>
<div>
@@ -1615,14 +1603,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'map(type)'</td></tr>
- <tr><th>Input</th><td>[0, false, [], {}, null, &quot;hello&quot;]</td></tr>
+ <tr><th>Input</th><td>[0, false, [], {}, null, &#34;hello&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;number&quot;, &quot;boolean&quot;, &quot;array&quot;, &quot;object&quot;, &quot;null&quot;, &quot;string&quot;]</td>
+ <td>[&#34;number&#34;, &#34;boolean&#34;, &#34;array&#34;, &#34;object&#34;, &#34;null&#34;, &#34;string&#34;]</td>
</tr>
</table>
@@ -1634,34 +1622,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="sort,sort_by">
<h3>
-
-<code>sort, sort_by</code>
-
+ <code>sort, sort_by</code>
</h3>
-
-<p>The <code>sort</code> functions sorts its input, which must be an array. Values are sorted in the following order:</p>
-
+ <p>The <code>sort</code> functions sorts its input, which must be an
+array. Values are sorted in the following order:</p>
<ul>
<li><code>null</code></li>
-
<li><code>false</code></li>
-
<li><code>true</code></li>
-
<li>numbers</li>
-
<li>strings, in alphabetical order (by unicode codepoint value)</li>
-
<li>arrays, in lexical order</li>
-
<li>objects</li>
</ul>
-
-<p>The ordering for objects is a little complex: first they’re compared by comparing their sets of keys (as arrays in sorted order), and if their keys are equal then the values are compared key by key.</p>
-
-<p><code>sort_by</code> may be used to sort by a particular field of an object, or by applying any jq filter. <code>sort_by(foo)</code> compares two elements by comparing the result of <code>foo</code> on each element.</p>
-
+<p>The ordering for objects is a little complex: first they're
+compared by comparing their sets of keys (as arrays in
+sorted order), and if their keys are equal then the values
+are compared key by key.</p>
+<p><code>sort_by</code> may be used to sort by a particular field of an
+object, or by applying any jq filter. <code>sort_by(foo)</code>
+compares two elements by comparing the result of <code>foo</code> on
+each element.</p>
<div>
@@ -1688,14 +1670,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'sort_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:4, &quot;bar&quot;:10}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:2, &quot;bar&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:4, &#34;bar&#34;:10}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:2, &#34;bar&#34;:1}]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;foo&quot;:2, &quot;bar&quot;:1}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:4, &quot;bar&quot;:10}]</td>
+ <td>[{&#34;foo&#34;:2, &#34;bar&#34;:1}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:4, &#34;bar&#34;:10}]</td>
</tr>
</table>
@@ -1707,16 +1689,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="group_by">
<h3>
-
-<code>group_by</code>
-
+ <code>group_by</code>
</h3>
-
-<p><code>group_by(.foo)</code> takes as input an array, groups the elements having the same <code>.foo</code> field into separate arrays, and produces all of these arrays as elements of a larger array, sorted by the value of the <code>.foo</code> field.</p>
-
-<p>Any jq expression, not just a field access, may be used in place of <code>.foo</code>. The sorting order is the same as described in the <code>sort</code> function above.</p>
-
+ <p><code>group_by(.foo)</code> takes as input an array, groups the
+elements having the same <code>.foo</code> field into separate arrays,
+and produces all of these arrays as elements of a larger
+array, sorted by the value of the <code>.foo</code> field.</p>
+<p>Any jq expression, not just a field access, may be used in
+place of <code>.foo</code>. The sorting order is the same as described
+in the <code>sort</code> function above.</p>
<div>
@@ -1729,14 +1711,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'group_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:1, &quot;bar&quot;:10}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:1, &quot;bar&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:1, &#34;bar&#34;:10}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:1, &#34;bar&#34;:1}]</td></tr>
<tr>
<th>Output</th>
- <td>[[{&quot;foo&quot;:1, &quot;bar&quot;:10}, {&quot;foo&quot;:1, &quot;bar&quot;:1}], [{&quot;foo&quot;:3, &quot;bar&quot;:100}]]</td>
+ <td>[[{&#34;foo&#34;:1, &#34;bar&#34;:10}, {&#34;foo&#34;:1, &#34;bar&#34;:1}], [{&#34;foo&#34;:3, &#34;bar&#34;:100}]]</td>
</tr>
</table>
@@ -1748,14 +1730,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="min,max,min_by,max_by">
<h3>
-
-<code>min</code>, <code>max</code>, <code>min_by</code>, <code>max_by</code>
-
+ <code>min</code>, <code>max</code>, <code>min_by</code>, <code>max_by</code>
</h3>
-
-<p>Find the minimum or maximum element of the input array. The <code>_by</code> versions allow you to specify a particular field or property to examine, e.g. <code>min_by(.foo)</code> finds the object with the smallest <code>foo</code> field.</p>
-
+ <p>Find the minimum or maximum element of the input array. The
+<code>_by</code> versions allow you to specify a particular field or
+property to examine, e.g. <code>min_by(.foo)</code> finds the object
+with the smallest <code>foo</code> field.</p>
<div>
@@ -1782,14 +1763,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'max_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:1, &quot;bar&quot;:14}, {&quot;foo&quot;:2, &quot;bar&quot;:3}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:1, &#34;bar&#34;:14}, {&#34;foo&#34;:2, &#34;bar&#34;:3}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;:2, &quot;bar&quot;:3}</td>
+ <td>{&#34;foo&#34;:2, &#34;bar&#34;:3}</td>
</tr>
</table>
@@ -1801,14 +1782,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="unique">
<h3>
-
-<code>unique</code>
-
+ <code>unique</code>
</h3>
-
-<p>The <code>unique</code> function takes as input an array and produces an array of the same elements, in sorted order, with duplicates removed.</p>
-
+ <p>The <code>unique</code> function takes as input an array and produces
+an array of the same elements, in sorted order, with
+duplicates removed.</p>
<div>
@@ -1840,14 +1819,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="reverse">
<h3>
-
-<code>reverse</code>
-
+ <code>reverse</code>
</h3>
-
-<p>This function reverses an array.</p>
-
+ <p>This function reverses an array.</p>
<div>
@@ -1879,14 +1854,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="contains">
<h3>
-
-<code>contains</code>
-
+ <code>contains</code>
</h3>
-
-<p>The filter <code>contains(b)</code> will produce true if b is completely contained within the input. A string B is contained in a string A if B is a substring of A. An array B is contained in an array A is all elements in B are contained in any element in A. An object B is contained in object A if all of the values in B are contained in the value in A with the same key. All other types are assumed to be contained in each other if they are equal.</p>
-
+ <p>The filter <code>contains(b)</code> will produce true if b is
+completely contained within the input. A string B is
+contained in a string A if B is a substring of A. An array B
+is contained in an array A is all elements in B are
+contained in any element in A. An object B is contained in
+object A if all of the values in B are contained in the
+value in A with the same key. All other types are assumed to
+be contained in each other if they are equal.</p>
<div>
@@ -1898,8 +1876,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example29" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'contains(&quot;bar&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foobar&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains(&#34;bar&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foobar&#34;</td></tr>
<tr>
@@ -1912,8 +1890,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'contains([&quot;baz&quot;, &quot;bar&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains([&#34;baz&#34;, &#34;bar&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;]</td></tr>
<tr>
@@ -1926,8 +1904,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'contains([&quot;bazzzzz&quot;, &quot;bar&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains([&#34;bazzzzz&#34;, &#34;bar&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;]</td></tr>
<tr>
@@ -1941,7 +1919,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'contains({foo: 12, bar: [{barp: 12}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]}</td></tr>
<tr>
@@ -1955,7 +1933,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'contains({foo: 12, bar: [{barp: 15}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]}</td></tr>
<tr>
@@ -1974,26 +1952,26 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="recurse">
<h3>
-
-<code>recurse</code>
-
+ <code>recurse</code>
</h3>
-
-<p>The <code>recurse</code> function allows you to search through a recursive structure, and extract interesting data from all levels. Suppose your input represents a filesystem:</p>
-
-<pre><code>{&quot;name&quot;: &quot;/&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/bin&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/bin/ls&quot;, &quot;children&quot;: []},
- {&quot;name&quot;: &quot;/bin/sh&quot;, &quot;children&quot;: []}]},
- {&quot;name&quot;: &quot;/home&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/home/stephen&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/home/stephen/jq&quot;, &quot;children&quot;: []}]}]}]}</code></pre>
-
-<p>Now suppose you want to extract all of the filenames present. You need to retrieve <code>.name</code>, <code>.children[].name</code>, <code>.children[].children[].name</code>, and so on. You can do this with:</p>
-
-<pre><code>recurse(.children[]) | .name</code></pre>
-
+ <p>The <code>recurse</code> function allows you to search through a
+recursive structure, and extract interesting data from all
+levels. Suppose your input represents a filesystem:</p>
+<pre><code>{"name": "/", "children": [
+ {"name": "/bin", "children": [
+ {"name": "/bin/ls", "children": []},
+ {"name": "/bin/sh", "children": []}]},
+ {"name": "/home", "children": [
+ {"name": "/home/stephen", "children": [
+ {"name": "/home/stephen/jq", "children": []}]}]}]}
+</code></pre>
+<p>Now suppose you want to extract all of the filenames
+present. You need to retrieve <code>.name</code>, <code>.children[].name</code>,
+<code>.children[].children[].name</code>, and so on. You can do this
+with:</p>
+<pre><code>recurse(.children[]) | .name
+</code></pre>
<div>
@@ -2006,35 +1984,35 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'recurse(.foo[])'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;:[{&quot;foo&quot;: []}, {&quot;foo&quot;:[{&quot;foo&quot;:[]}]}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;:[{&#34;foo&#34;: []}, {&#34;foo&#34;:[{&#34;foo&#34;:[]}]}]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;:[{&quot;foo&quot;:[]},{&quot;foo&quot;:[{&quot;foo&quot;:[]}]}]}</td>
+ <td>{&#34;foo&#34;:[{&#34;foo&#34;:[]},{&#34;foo&#34;:[{&#34;foo&#34;:[]}]}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[]}</td>
+ <td>{&#34;foo&#34;:[]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[{&quot;foo&quot;:[]}]}</td>
+ <td>{&#34;foo&#34;:[{&#34;foo&#34;:[]}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[]}</td>
+ <td>{&#34;foo&#34;:[]}</td>
</tr>
</table>
@@ -2046,14 +2024,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="Stringinterpolation-\(foo)">
<h3>
-
-String interpolation - <code>\(foo)</code>
-
+ String interpolation - <code>\(foo)</code>
</h3>
-
-<p>Inside a string, you can put an expression inside parens after a backslash. Whatever the expression returns will be interpolated into the string.</p>
-
+ <p>Inside a string, you can put an expression inside parens
+after a backslash. Whatever the expression returns will be
+interpolated into the string.</p>
<div>
@@ -2065,7 +2041,7 @@ String interpolation - <code>\(foo)</code>
<div id="example31" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '&quot;The input was \(.), which is one less than \(.+1)&quot;'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '&#34;The input was \(.), which is one less than \(.+1)&#34;'</td></tr>
<tr><th>Input</th><td>42</td></tr>
@@ -2073,7 +2049,7 @@ String interpolation - <code>\(foo)</code>
<th>Output</th>
- <td>&quot;The input was 42, which is one less than 43&quot;</td>
+ <td>&#34;The input was 42, which is one less than 43&#34;</td>
</tr>
</table>
@@ -2085,68 +2061,61 @@ String interpolation - <code>\(foo)</code>
<section id="Formatstringsandescaping">
<h3>
-
-Format strings and escaping
-
+ Format strings and escaping
</h3>
-
-<p>The <code>@foo</code> syntax is used to format and escape strings, which is useful for building URLs, documents in a language like HTML or XML, and so forth. <code>@foo</code> can be used as a filter on its own, the possible escapings are:</p>
-
+ <p>The <code>@foo</code> syntax is used to format and escape strings,
+which is useful for building URLs, documents in a language
+like HTML or XML, and so forth. <code>@foo</code> can be used as a
+filter on its own, the possible escapings are:</p>
<ul>
-<li>
-<p><code>@text</code>:</p>
-
+<li><code>@text</code>:</li>
+</ul>
<p>Calls <code>tostring</code>, see that function for details.</p>
-</li>
-
-<li>
-<p><code>@json</code>:</p>
-
+<ul>
+<li><code>@json</code>:</li>
+</ul>
<p>Serialises the input as JSON.</p>
-</li>
-
-<li>
-<p><code>@html</code>:</p>
-
-<p>Applies HTML/XML escaping, by mapping the characters <code>&lt;&gt;&amp;'&quot;</code> to their entity equivalents <code>&amp;lt;</code>, <code>&amp;gt;</code>, <code>&amp;amp;</code>, <code>&amp;apos;</code>, <code>&amp;quot;</code>.</p>
-</li>
-
-<li>
-<p><code>@uri</code>:</p>
-
-<p>Applies percent-encoding, by mapping all reserved URI characters to a <code>%xx</code> sequence.</p>
-</li>
-
-<li>
-<p><code>@csv</code>:</p>
-
-<p>The input must be an array, and it is rendered as CSV with double quotes for strings, and quotes escaped by repetition.</p>
-</li>
-
-<li>
-<p><code>@sh</code>:</p>
-
-<p>The input is escaped suitable for use in a command-line for a POSIX shell. If the input is an array, the output will be a series of space-separated strings.</p>
-</li>
-
-<li>
-<p><code>@base64</code>:</p>
-
-<p>The input is converted to base64 as specified by RFC 4648.</p>
-</li>
+<ul>
+<li><code>@html</code>:</li>
</ul>
-
-<p>This syntax can be combined with string interpolation in a useful way. You can follow a <code>@foo</code> token with a string literal. The contents of the string literal will <em>not</em> be escaped. However, all interpolations made inside that string literal will be escaped. For instance,</p>
-
-<pre><code>@uri &quot;https://www.google.com/search?q=\(.search)&quot;</code></pre>
-
-<p>will produce the following output for the input <code>{&quot;search&quot;:&quot;jq!&quot;}</code>:</p>
-
-<pre><code>https://www.google.com/search?q=jq%21</code></pre>
-
-<p>Note that the slashes, question mark, etc. in the URL are not escaped, as they were part of the string literal.</p>
-
+<p>Applies HTML/XML escaping, by mapping the characters
+ <code>&lt;&gt;&amp;'"</code> to their entity equivalents <code>&amp;lt;</code>, <code>&amp;gt;</code>,
+ <code>&amp;amp;</code>, <code>&amp;apos;</code>, <code>&amp;quot;</code>.</p>
+<ul>
+<li><code>@uri</code>:</li>
+</ul>
+<p>Applies percent-encoding, by mapping all reserved URI
+ characters to a <code>%xx</code> sequence.</p>
+<ul>
+<li><code>@csv</code>:</li>
+</ul>
+<p>The input must be an array, and it is rendered as CSV
+ with double quotes for strings, and quotes escaped by
+ repetition.</p>
+<ul>
+<li><code>@sh</code>:</li>
+</ul>
+<p>The input is escaped suitable for use in a command-line
+ for a POSIX shell. If the input is an array, the output
+ will be a series of space-separated strings.</p>
+<ul>
+<li><code>@base64</code>:</li>
+</ul>
+<p>The input is converted to base64 as specified by RFC 4648.</p>
+<p>This syntax can be combined with string interpolation in a
+useful way. You can follow a <code>@foo</code> token with a string
+literal. The contents of the string literal will <em>not</em> be
+escaped. However, all interpolations made inside that string
+literal will be escaped. For instance,</p>
+<pre><code>@uri "https://www.google.com/search?q=\(.search)"
+</code></pre>
+<p>will produce the following output for the input
+<code>{"search":"jq!"}</code>:</p>
+<pre><code>https://www.google.com/search?q=jq%21
+</code></pre>
+<p>Note that the slashes, question mark, etc. in the URL are
+not escaped, as they were part of the string literal.</p>
<div>
@@ -2159,28 +2128,28 @@ Format strings and escaping
<table>
<tr><th></th><td class="jqprogram">jq '@html'</td></tr>
- <tr><th>Input</th><td>&quot;This works if x &lt; y&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;This works if x &lt; y&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;This works if x &amp;lt; y&quot;</td>
+ <td>&#34;This works if x &amp;lt; y&#34;</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '@sh &quot;echo \(.)&quot;'</td></tr>
- <tr><th>Input</th><td>&quot;O'Hara's Ale&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq '@sh &#34;echo \(.)&#34;'</td></tr>
+ <tr><th>Input</th><td>&#34;O&#39;Hara&#39;s Ale&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;echo 'O'\\''Hara'\\''s Ale'&quot;</td>
+ <td>&#34;echo &#39;O&#39;\\&#39;&#39;Hara&#39;\\&#39;&#39;s Ale&#39;&#34;</td>
</tr>
</table>
@@ -2198,16 +2167,16 @@ Format strings and escaping
<section id="==,!=">
<h3>
-
-<code>==</code>, <code>!=</code>
-
+ <code>==</code>, <code>!=</code>
</h3>
-
-<p>The expression ‘a == b’ will produce ‘true’ if the result of a and b are equal (that is, if they represent equivalent JSON documents) and ‘false’ otherwise. In particular, strings are never considered equal to numbers. If you’re coming from Javascript, jq’s == is like Javascript’s === - considering values equal only when they have the same type as well as the same value.</p>
-
-<p>!= is “not equal”, and ‘a != b’ returns the opposite value of ‘a == b’</p>
-
+ <p>The expression 'a == b' will produce 'true' if the result of a and b
+are equal (that is, if they represent equivalent JSON documents) and
+'false' otherwise. In particular, strings are never considered equal
+to numbers. If you're coming from Javascript, jq's == is like
+Javascript's === - considering values equal only when they have the
+same type as well as the same value.</p>
+<p>!= is "not equal", and 'a != b' returns the opposite value of 'a == b'</p>
<div>
@@ -2220,7 +2189,7 @@ Format strings and escaping
<table>
<tr><th></th><td class="jqprogram">jq '.[] == 1'</td></tr>
- <tr><th>Input</th><td>[1, 1.0, &quot;1&quot;, &quot;banana&quot;]</td></tr>
+ <tr><th>Input</th><td>[1, 1.0, &#34;1&#34;, &#34;banana&#34;]</td></tr>
<tr>
@@ -2260,22 +2229,24 @@ Format strings and escaping
<section id="if-then-else">
<h3>
-
-if-then-else
-
+ if-then-else
</h3>
-
-<p><code>if A then B else C end</code> will act the same as <code>B</code> if <code>A</code> produces a value other than false or null, but act the same as <code>C</code> otherwise.</p>
-
-<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 <code>if .name then A else B end</code>, you’ll need something more like <code>if (.name | count) &gt; 0 then A else
+ <p><code>if A then B else C end</code> will act the same as <code>B</code> if <code>A</code>
+produces a value other than false or null, but act the same
+as <code>C</code> otherwise.</p>
+<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 <code>if .name then A else B end</code>, you'll
+need something more like <code>if (.name | count) &gt; 0 then A else
B end</code> instead.</p>
-
-<p>If the condition <code>A</code> produces multiple results, then <code>B</code> is evaluated once for each result that is not false or null, and <code>C</code> is evaluated once for each false or null.</p>
-
+<p>If the condition <code>A</code> produces multiple results, then <code>B</code> is evaluated
+once for each result that is not false or null, and <code>C</code> is evaluated
+once for each false or null.</p>
<p>More cases can be added to an if using <code>elif A then B</code> syntax.</p>
-
<div>
@@ -2287,11 +2258,11 @@ B end</code> instead.</p>
<table>
<tr><th></th><td class="jqprogram">jq 'if . == 0 then
- &quot;zero&quot;
+ &#34;zero&#34;
elif . == 1 then
- &quot;one&quot;
+ &#34;one&#34;
else
- &quot;many&quot;
+ &#34;many&#34;
end'</td></tr>
<tr><th>Input</th><td>2</td></tr>
@@ -2300,7 +2271,7 @@ end'</td></tr>
<th>Output</th>
- <td>&quot;many&quot;</td>
+ <td>&#34;many&#34;</td>
</tr>
</table>
@@ -2310,19 +2281,17 @@ end'</td></tr>
</section>
- <section id=">,>=,<=,<">
+ <section id="&gt;,&gt;=,&lt;=,&lt;">
<h3>
-
-<code>&gt;, &gt;=, &lt;=, &lt;</code>
-
+ <code>&gt;, &gt;=, &lt;=, &lt;</code>
</h3>
-
-<p>The comparison operators <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;=</code>, <code>&lt;</code> 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).</p>
-
+ <p>The comparison operators <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;=</code>, <code>&lt;</code> 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).</p>
<p>The ordering is the same as that described for <code>sort</code>, above.</p>
-
<div>
@@ -2353,21 +2322,24 @@ end'</td></tr>
<section id="and/or/not">
<h3>
-
-and/or/not
-
+ and/or/not
</h3>
-
-<p>jq supports the normal Boolean operators and/or/not. They have the same standard of truth as if expressions - false and null are considered “false values”, and anything else is a “true value”.</p>
-
-<p>If an operand of one of these operators produces multiple results, the operator itself will produce a result for each input.</p>
-
-<p><code>not</code> is in fact a builtin function rather than an operator, so it is called as a filter to which things can be piped rather than with special syntax, as in <code>.foo and .bar |
+ <p>jq supports the normal Boolean operators and/or/not. They have the
+same standard of truth as if expressions - false and null are
+considered "false values", and anything else is a "true value".</p>
+<p>If an operand of one of these operators produces multiple
+results, the operator itself will produce a result for each input.</p>
+<p><code>not</code> is in fact a builtin function rather than an operator,
+so it is called as a filter to which things can be piped
+rather than with special syntax, as in <code>.foo and .bar |
not</code>.</p>
-
-<p>These three only produce the values “true” and “false”, and so are only useful for genuine Boolean operations, rather than the common Perl/Python/Ruby idiom of “value_that_may_be_null or default”. If you want to use this form of “or”, picking between two values rather than evaluating a condition, see the “//” operator below.</p>
-
+<p>These three only produce the values "true" and "false", and
+so are only useful for genuine Boolean operations, rather
+than the common Perl/Python/Ruby idiom of
+"value_that_may_be_null or default". If you want to use this
+form of "or", picking between two values rather than
+evaluating a condition, see the "//" operator below.</p>
<div>
@@ -2379,7 +2351,7 @@ not</code>.</p>
<div id="example36" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '42 and &quot;a string&quot;'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '42 and &#34;a string&#34;'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -2469,16 +2441,17 @@ not</code>.</p>
<section id="Alternativeoperator-//">
<h3>
-
-Alternative operator - <code>//</code>
-
+ Alternative operator - <code>//</code>
</h3>
-
-<p>A filter of the form <code>a // b</code> produces the same results as <code>a</code>, if <code>a</code> produces results other than <code>false</code> and <code>null</code>. Otherwise, <code>a // b</code> produces the same results as <code>b</code>.</p>
-
-<p>This is useful for providing defaults: <code>.foo // 1</code> will evaluate to <code>1</code> if there’s no <code>.foo</code> element in the input. It’s similar to how <code>or</code> is sometimes used in Python (jq’s <code>or</code> operator is reserved for strictly Boolean operations).</p>
-
+ <p>A filter of the form <code>a // b</code> produces the same
+results as <code>a</code>, if <code>a</code> produces results other than <code>false</code>
+and <code>null</code>. Otherwise, <code>a // b</code> produces the same results as <code>b</code>.</p>
+<p>This is useful for providing defaults: <code>.foo // 1</code> will
+evaluate to <code>1</code> if there's no <code>.foo</code> element in the
+input. It's similar to how <code>or</code> is sometimes used in Python
+(jq's <code>or</code> operator is reserved for strictly Boolean
+operations).</p>
<div>
@@ -2491,7 +2464,7 @@ Alternative operator - <code>//</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo // 42'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 19}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 19}</td></tr>
<tr>
@@ -2526,62 +2499,77 @@ Alternative operator - <code>//</code>
<section id="Advancedfeatures">
<h2>Advanced features</h2>
-
-<p>Variables are an absolute necessity in most programming languages, but they’re relegated to an “advanced feature” in jq.</p>
-
-<p>In most languages, variables are the only means of passing around data. If you calculate a value, and you want to use it more than once, you’ll need to store it in a variable. To pass a value to another part of the program, you’ll need that part of the program to define a variable (as a function parameter, object member, or whatever) in which to place the data.</p>
-
-<p>It is also possible to define functions in jq, although this is is a feature whose biggest use is defining jq’s standard library (many jq functions such as <code>map</code> and <code>find</code> are in fact written in jq).</p>
-
-<p>Finally, jq has a <code>reduce</code> operation, which is very powerful but a bit tricky. Again, it’s mostly used internally, to define some useful bits of jq’s standard library.</p>
-
+ <p>Variables are an absolute necessity in most programming languages, but
+they're relegated to an "advanced feature" in jq.</p>
+<p>In most languages, variables are the only means of passing around
+data. If you calculate a value, and you want to use it more than once,
+you'll need to store it in a variable. To pass a value to another part
+of the program, you'll need that part of the program to define a
+variable (as a function parameter, object member, or whatever) in
+which to place the data.</p>
+<p>It is also possible to define functions in jq, although this is
+is a feature whose biggest use is defining jq's standard library
+(many jq functions such as <code>map</code> and <code>find</code> are in fact written
+in jq).</p>
+<p>Finally, jq has a <code>reduce</code> operation, which is very powerful but a
+bit tricky. Again, it's mostly used internally, to define some
+useful bits of jq's standard library.</p>
<section id="Variables">
<h3>
-
-Variables
-
+ Variables
</h3>
-
-<p>In jq, all filters have an input and an output, so manual plumbing is not necessary to pass a value from one part of a program to the next. Many expressions, for instance <code>a + b</code>, pass their input to two distinct subexpressions (here <code>a</code> and <code>b</code> are both passed the same input), so variables aren’t usually necessary in order to use a value twice.</p>
-
-<p>For instance, calculating the average value of an array of numbers requires a few variables in most languages - at least one to hold the array, perhaps one for each element or for a loop counter. In jq, it’s simply <code>add / length</code> - the <code>add</code> expression is given the array and produces its sum, and the <code>length</code> expression is given the array and produces its length.</p>
-
-<p>So, there’s generally a cleaner way to solve most problems in jq that defining variables. Still, sometimes they do make things easier, so jq lets you define variables using <code>expression as $variable</code>. All variable names start with <code>$</code>. Here’s a slightly uglier version of the array-averaging example:</p>
-
-<pre><code>length as $array_length | add / $array_length</code></pre>
-
-<p>We’ll need a more complicated problem to find a situation where using variables actually makes our lives easier.</p>
-
-<p>Suppose we have an array of blog posts, with “author” and “title” fields, and another object which is used to map author usernames to real names. Our input looks like:</p>
-
-<pre><code>{&quot;posts&quot;: [{&quot;title&quot;: &quot;Frist psot&quot;, &quot;author&quot;: &quot;anon&quot;},
- {&quot;title&quot;: &quot;A well-written article&quot;, &quot;author&quot;: &quot;person1&quot;}],
- &quot;realnames&quot;: {&quot;anon&quot;: &quot;Anonymous Coward&quot;,
- &quot;person1&quot;: &quot;Person McPherson&quot;}}</code></pre>
-
-<p>We want to produce the posts with the author field containing a real name, as in:</p>
-
-<pre><code>{&quot;title&quot;: &quot;Frist psot&quot;, &quot;author&quot;: &quot;Anonymous Coward&quot;}
-{&quot;title&quot;: &quot;A well-written article&quot;, &quot;author&quot;: &quot;Person McPherson&quot;}</code></pre>
-
-<p>We use a variable, $names, to store the realnames object, so that we can refer to it later when looking up author usernames:</p>
-
-<pre><code>.realnames as $names | .posts[] | {title, author: $names[.author]}</code></pre>
-
-<p>The expression <code>exp as $x | ...</code> means: for each value of expression <code>exp</code>, run the rest of the pipeline with the entire original input, and with <code>$x</code> set to that value. Thus <code>as</code> functions as something of a foreach loop.</p>
-
-<p>Variables are scoped over the rest of the expression that defines them, so</p>
-
-<pre><code>.realnames as $names | (.posts[] | {title, author: $names[.author]})</code></pre>
-
+ <p>In jq, all filters have an input and an output, so manual
+plumbing is not necessary to pass a value from one part of a program
+to the next. Many expressions, for instance <code>a + b</code>, pass their input
+to two distinct subexpressions (here <code>a</code> and <code>b</code> are both passed the
+same input), so variables aren't usually necessary in order to use a
+value twice.</p>
+<p>For instance, calculating the average value of an array of numbers
+requires a few variables in most languages - at least one to hold the
+array, perhaps one for each element or for a loop counter. In jq, it's
+simply <code>add / length</code> - the <code>add</code> expression is given the array and
+produces its sum, and the <code>length</code> expression is given the array and
+produces its length.</p>
+<p>So, there's generally a cleaner way to solve most problems in jq that
+defining variables. Still, sometimes they do make things easier, so jq
+lets you define variables using <code>expression as $variable</code>. All
+variable names start with <code>$</code>. Here's a slightly uglier version of the
+array-averaging example:</p>
+<pre><code>length as $array_length | add / $array_length
+</code></pre>
+<p>We'll need a more complicated problem to find a situation where using
+variables actually makes our lives easier.</p>
+<p>Suppose we have an array of blog posts, with "author" and "title"
+fields, and another object which is used to map author usernames to
+real names. Our input looks like:</p>
+<pre><code>{"posts": [{"title": "Frist psot", "author": "anon"},
+ {"title": "A well-written article", "author": "person1"}],
+ "realnames": {"anon": "Anonymous Coward",
+ "person1": "Person McPherson"}}
+</code></pre>
+<p>We want to produce the posts with the author field containing a real
+name, as in:</p>
+<pre><code>{"title": "Frist psot", "author": "Anonymous Coward"}
+{"title": "A well-written article", "author": "Person McPherson"}
+</code></pre>
+<p>We use a variable, $names, to store the realnames object, so that we
+can refer to it later when looking up author usernames:</p>
+<pre><code>.realnames as $names | .posts[] | {title, author: $names[.author]}
+</code></pre>
+<p>The expression <code>exp as $x | ...</code> means: for each value of expression
+<code>exp</code>, run the rest of the pipeline with the entire original input, and
+with <code>$x</code> set to that value. Thus <code>as</code> functions as something of a
+foreach loop.</p>
+<p>Variables are scoped over the rest of the expression that defines
+them, so</p>
+<pre><code>.realnames as $names | (.posts[] | {title, author: $names[.author]})
+</code></pre>
<p>will work, but</p>
-
-<pre><code>(.realnames as $names | .posts[]) | {title, author: $names[.author]}</code></pre>
-
-<p>won’t.</p>
-
+<pre><code>(.realnames as $names | .posts[]) | {title, author: $names[.author]}
+</code></pre>
+<p>won't.</p>
<div>
@@ -2594,7 +2582,7 @@ Variables
<table>
<tr><th></th><td class="jqprogram">jq '.bar as $x | .foo | . + $x'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;:10, &quot;bar&quot;:200}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;:10, &#34;bar&#34;:200}</td></tr>
<tr>
@@ -2613,28 +2601,28 @@ Variables
<section id="DefiningFunctions">
<h3>
-
-Defining Functions
-
+ Defining Functions
</h3>
-
-<p>You can give a filter a name using “def” syntax:</p>
-
-<pre><code>def increment: . + 1;</code></pre>
-
-<p>From then on, <code>increment</code> is usable as a filter just like a builtin function (in fact, this is how some of the builtins are defined). A function may take arguments:</p>
-
-<pre><code>def map(f): [.[] | f];</code></pre>
-
-<p>Arguments are passed as filters, not as values. The same argument may be referenced multiple times with different inputs (here <code>f</code> is run for each element of the input array). Arguments to a function work more like callbacks than like value arguments.</p>
-
-<p>If you want the value-argument behaviour for defining simple functions, you can just use a variable:</p>
-
-<pre><code>def addvalue(f): f as $value | map(. + $value);</code></pre>
-
-<p>With that definition, <code>addvalue(.foo)</code> will add the current input’s <code>.foo</code> field to each element of the array.</p>
-
+ <p>You can give a filter a name using "def" syntax:</p>
+<pre><code>def increment: . + 1;
+</code></pre>
+<p>From then on, <code>increment</code> is usable as a filter just like a
+builtin function (in fact, this is how some of the builtins
+are defined). A function may take arguments:</p>
+<pre><code>def map(f): [.[] | f];
+</code></pre>
+<p>Arguments are passed as filters, not as values. The
+same argument may be referenced multiple times with
+different inputs (here <code>f</code> is run for each element of the
+input array). Arguments to a function work more like
+callbacks than like value arguments.</p>
+<p>If you want the value-argument behaviour for defining simple
+functions, you can just use a variable:</p>
+<pre><code>def addvalue(f): f as $value | map(. + $value);
+</code></pre>
+<p>With that definition, <code>addvalue(.foo)</code> will add the current
+input's <code>.foo</code> field to each element of the array.</p>
<div>
@@ -2680,22 +2668,22 @@ Defining Functions
<section id="Reduce">
<h3>
-
-Reduce
-
+ Reduce
</h3>
-
-<p>The <code>reduce</code> syntax in jq allows you to combine all of the results of an expression by accumulating them into a single answer. As an example, we’ll pass <code>[3,2,1]</code> to this expression:</p>
-
-<pre><code>reduce .[] as $item (0; . + $item)</code></pre>
-
-<p>For each result that <code>.[]</code> produces, <code>. + $item</code> is run to accumulate a running total, starting from 0. In this example, <code>.[]</code> produces the results 3, 2, and 1, so the effect is similar to running something like this:</p>
-
+ <p>The <code>reduce</code> syntax in jq allows you to combine all of the
+results of an expression by accumulating them into a single
+answer. As an example, we'll pass <code>[3,2,1]</code> to this expression:</p>
+<pre><code>reduce .[] as $item (0; . + $item)
+</code></pre>
+<p>For each result that <code>.[]</code> produces, <code>. + $item</code> is run to
+accumulate a running total, starting from 0. In this
+example, <code>.[]</code> produces the results 3, 2, and 1, so the
+effect is similar to running something like this:</p>
<pre><code>0 | (3 as $item | . + $item) |
(2 as $item | . + $item) |
- (1 as $item | . + $item)</code></pre>
-
+ (1 as $item | . + $item)
+</code></pre>
<div>
@@ -2729,64 +2717,73 @@ Reduce
<section id="Assignment">
<h2>Assignment</h2>
-
-<p>Assignment works a little differently in jq than in most programming languages. jq doesn’t distinguish between references to and copies of something - two objects or arrays are either equal or not equal, without any further notion of being “the same object” or “not the same object”.</p>
-
-<p>If an object has two fields which are arrays, <code>.foo</code> and <code>.bar</code>, and you append something to <code>.foo</code>, then <code>.bar</code> will not get bigger. Even if you’ve just set <code>.bar = .foo</code>. If you’re used to programming in languages like Python, Java, Ruby, Javascript, etc. then you can think of it as though jq does a full deep copy of every object before it does the assignment (for performance, it doesn’t actually do that, but that’s the general idea).</p>
-
+ <p>Assignment works a little differently in jq than in most
+programming languages. jq doesn't distinguish between references
+to and copies of something - two objects or arrays are either
+equal or not equal, without any further notion of being "the
+same object" or "not the same object".</p>
+<p>If an object has two fields which are arrays, <code>.foo</code> and <code>.bar</code>,
+and you append something to <code>.foo</code>, then <code>.bar</code> will not get
+bigger. Even if you've just set <code>.bar = .foo</code>. If you're used to
+programming in languages like Python, Java, Ruby, Javascript,
+etc. then you can think of it as though jq does a full deep copy
+of every object before it does the assignment (for performance,
+it doesn't actually do that, but that's the general idea).</p>
<section id="=">
<h3>
-
-<code>=</code>
-
+ <code>=</code>
</h3>
-
-<p>The filter <code>.foo = 1</code> will take as input an object and produce as output an object with the “foo” field set to 1. There is no notion of “modifying” or “changing” something in jq - all jq values are immutable. For instance,</p>
-
+ <p>The filter <code>.foo = 1</code> will take as input an object
+and produce as output an object with the "foo" field set to
+1. There is no notion of "modifying" or "changing" something
+in jq - all jq values are immutable. For instance,</p>
<p>.foo = .bar | .foo.baz = 1</p>
-
-<p>will not have the side-effect of setting .bar.baz to be set to 1, as the similar-looking program in Javascript, Python, Ruby or other languages would. Unlike these languages (but like Haskell and some other functional languages), there is no notion of two arrays or objects being “the same array” or “the same object”. They can be equal, or not equal, but if we change one of them in no circumstances will the other change behind our backs.</p>
-
-<p>This means that it’s impossible to build circular values in jq (such as an array whose first element is itself). This is quite intentional, and ensures that anything a jq program can produce can be represented in JSON.</p>
-
+<p>will not have the side-effect of setting .bar.baz to be set
+to 1, as the similar-looking program in Javascript, Python,
+Ruby or other languages would. Unlike these languages (but
+like Haskell and some other functional languages), there is
+no notion of two arrays or objects being "the same array" or
+"the same object". They can be equal, or not equal, but if
+we change one of them in no circumstances will the other
+change behind our backs.</p>
+<p>This means that it's impossible to build circular values in
+jq (such as an array whose first element is itself). This is
+quite intentional, and ensures that anything a jq program
+can produce can be represented in JSON.</p>
</section>
<section id="|=">
<h3>
-
-<code>|=</code>
-
+ <code>|=</code>
</h3>
-
-<p>As well as the assignment operator ‘=’, jq provides the “update” operator ‘|=’, which takes a filter on the right-hand side and works out the new value for the property being assigned to by running the old value through this expression. For instance, .foo |= .+1 will build an object with the “foo” field set to the input’s “foo” plus 1.</p>
-
-<p>This example should show the difference between ‘=’ and ‘|=’:</p>
-
-<p>Provide input ‘{“a”: {“b”: 10}, “b”: 20}’ to the programs:</p>
-
-<p>.a = .b .a |= .b</p>
-
-<p>The former will set the “a” field of the input to the “b” field of the input, and produce the output {“a”: 20}. The latter will set the “a” field of the input to the “a” field’s “b” field, producing {“a”: 10}.</p>
-
+ <p>As well as the assignment operator '=', jq provides the "update"
+operator '|=', which takes a filter on the right-hand side and
+works out the new value for the property being assigned to by running
+the old value through this expression. For instance, .foo |= .+1 will
+build an object with the "foo" field set to the input's "foo" plus 1.</p>
+<p>This example should show the difference between '=' and '|=':</p>
+<p>Provide input '{"a": {"b": 10}, "b": 20}' to the programs:</p>
+<p>.a = .b
+.a |= .b</p>
+<p>The former will set the "a" field of the input to the "b" field of the
+input, and produce the output {"a": 20}. The latter will set the "a"
+field of the input to the "a" field's "b" field, producing {"a": 10}.</p>
</section>
<section id="+=,-=,*=,/=,//=">
<h3>
-
-<code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>, <code>//=</code>
-
+ <code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>, <code>//=</code>
</h3>
-
-<p>jq has a few operators of the form <code>a op= b</code>, which are all equivalent to <code>a |= . op b</code>. So, <code>+= 1</code> can be used to increment values.</p>
-
+ <p>jq has a few operators of the form <code>a op= b</code>, which are all
+equivalent to <code>a |= . op b</code>. So, <code>+= 1</code> can be used to increment values.</p>
<div>
@@ -2799,14 +2796,14 @@ Reduce
<table>
<tr><th></th><td class="jqprogram">jq '.foo += 1'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;: 43}</td>
+ <td>{&#34;foo&#34;: 43}</td>
</tr>
</table>
@@ -2818,33 +2815,41 @@ Reduce
<section id="Complexassignments">
<h3>
-
-Complex assignments
-
+ Complex assignments
</h3>
-
-<p>Lots more things are allowed on the left-hand side of a jq assignment than in most langauges. We’ve already seen simple field accesses on the left hand side, and it’s no surprise that array accesses work just as well:</p>
-
-<pre><code>.posts[0].title = &quot;JQ Manual&quot;</code></pre>
-
-<p>What may come as a surprise is that the expression on the left may produce multiple results, referring to different points in the input document:</p>
-
-<pre><code>.posts[].comments |= . + [&quot;this is great&quot;]</code></pre>
-
-<p>That example appends the string “this is great” to the “comments” array of each post in the input (where the input is an object with a field “posts” which is an array of posts).</p>
-
-<p>When jq encounters an assignment like ‘a = b’, it records the “path” taken to select a part of the input document while executing a. This path is then used to find which part of the input to change while executing the assignment. Any filter may be used on the left-hand side of an equals - whichever paths it selects from the input will be where the assignment is performed.</p>
-
-<p>This is a very powerful operation. Suppose we wanted to add a comment to blog posts, using the same “blog” input above. This time, we only want to comment on the posts written by “stedolan”. We can find those posts using the “select” function described earlier:</p>
-
-<pre><code>.posts[] | select(.author == &quot;stedolan&quot;)</code></pre>
-
-<p>The paths provided by this operation point to each of the posts that “stedolan” wrote, and we can comment on each of them in the same way that we did before:</p>
-
-<pre><code>(.posts[] | select(.author == &quot;stedolan&quot;) | .comments) |=
- . + [&quot;terrible.&quot;]</code></pre>
-
+ <p>Lots more things are allowed on the left-hand side of a jq assignment
+than in most languages. We've already seen simple field accesses on
+the left hand side, and it's no surprise that array accesses work just
+as well:</p>
+<pre><code>.posts[0].title = "JQ Manual"
+</code></pre>
+<p>What may come as a surprise is that the expression on the left may
+produce multiple results, referring to different points in the input
+document:</p>
+<pre><code>.posts[].comments |= . + ["this is great"]
+</code></pre>
+<p>That example appends the string "this is great" to the "comments"
+array of each post in the input (where the input is an object with a
+field "posts" which is an array of posts).</p>
+<p>When jq encounters an assignment like 'a = b', it records the "path"
+taken to select a part of the input document while executing a. This
+path is then used to find which part of the input to change while
+executing the assignment. Any filter may be used on the
+left-hand side of an equals - whichever paths it selects from the
+input will be where the assignment is performed.</p>
+<p>This is a very powerful operation. Suppose we wanted to add a comment
+to blog posts, using the same "blog" input above. This time, we only
+want to comment on the posts written by "stedolan". We can find those
+posts using the "select" function described earlier:</p>
+<pre><code>.posts[] | select(.author == "stedolan")
+</code></pre>
+<p>The paths provided by this operation point to each of the posts that
+"stedolan" wrote, and we can comment on each of them in the same way
+that we did before:</p>
+<pre><code>(.posts[] | select(.author == "stedolan") | .comments) |=
+ . + ["terrible."]
+</code></pre>
</section>
@@ -2857,7 +2862,7 @@ Complex assignments
<footer>
<div class="container">
- <p>This website is made with <a href="http://www.tinytree.info">Bonsai</a> and <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
+ <p>This website is made with <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
<p>jq is licensed under the MIT license (code) and the <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a> license (docs).</p>
</div>
</footer>
@@ -2865,7 +2870,6 @@ Complex assignments
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<script src="https://twitter.github.io/typeahead.js/releases/0.11.1/typeahead.bundle.js"></script>
-
<script>
var section_map = {
@@ -2954,7 +2958,7 @@ Complex assignments
"if-then-else" : "if-then-else",
- ">, >=, <=, <" : ">,>=,<=,<",
+ "\u003e, \u003e=, \u003c=, \u003c" : "\u003e,\u003e=,\u003c=,\u003c",
"and/or/not" : "and/or/not",
@@ -2989,4 +2993,4 @@ Complex assignments
</script>
<script src="/jq/js/manual-search.js"></script>
</body>
-</html>
+</html> \ No newline at end of file
diff --git a/manual/v1.4/index.html b/manual/v1.4/index.html
index 812ac58..b722c3d 100644
--- a/manual/v1.4/index.html
+++ b/manual/v1.4/index.html
@@ -18,7 +18,6 @@
<![endif]-->
</head>
-
<body id="v1.4" data-spy="scroll" data-target="#navcolumn" data-offset="100">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
@@ -56,7 +55,6 @@
</div>
</div>
-
<div class="container">
<div class="row">
<div class="affix" id="navcolumn">
@@ -104,128 +102,142 @@
<div id="manualcontent">
<h1>jq 1.4 Manual</h1>
<p><em>The manual for the development version of jq can be found
-<a href='/jq/manual'>here</a>.</em></p>
- <p>A jq program is a &ldquo;filter&rdquo;: it takes an input, and produces an
+<a href="/jq/manual">here</a>.</em></p>
+ <p>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.</p><p>Filters can be combined in various ways - you can pipe the output of
+or various other standard tasks.</p>
+<p>Filters can be combined in various ways - you can pipe the output of
one filter into another filter, or collect the output of a filter
-into an array.</p><p>Some filters produce multiple results, for instance there&rsquo;s one that
+into an array.</p>
+<p>Some filters produce multiple results, for instance there's one that
produces all the elements of its input array. Piping that filter
into a second runs the second filter for each element of the
array. Generally, things that would be done with loops and iteration
-in other languages are just done by gluing filters together in jq.</p><p>It&rsquo;s important to remember that every filter has an input and an
-output. Even literals like &ldquo;hello&rdquo; or 42 are filters - they take an
+in other languages are just done by gluing filters together in jq.</p>
+<p>It's important to remember that every filter has an input and an
+output. Even literals like "hello" or 42 are filters - they take an
input but always produce the same literal as output. Operations that
combine two filters, like addition, generally feed the same input to
both and combine the results. So, you can implement an averaging
filter as <code>add / length</code> - feeding the input array both to the <code>add</code>
-filter and the <code>length</code> filter and dividing the results.</p><p>But that&rsquo;s getting ahead of ourselves. :) Let&rsquo;s start with something
+filter and the <code>length</code> filter and dividing the results.</p>
+<p>But that's getting ahead of ourselves. :) Let's start with something
simpler:</p>
<section id="Invokingjq">
<h2>Invoking jq</h2>
-
-<p>jq filters run on a stream of JSON data. The input to jq is parsed as a sequence of whitespace-separated JSON values which are passed through the provided filter one at a time. The output(s) of the filter are written to standard out, again as a sequence of whitespace-separated JSON data.</p>
-
-<p>Note: it is important to mind the shell’s quoting rules. As a general rule it’s best to always quote (with single-quote characters) the jq program, as too many characters with special meaning to jq are also shell meta-characters. For example, <code>jq
-&quot;foo&quot;</code> will fail on most Unix shells because that will be the same as <code>jq foo</code>, which will generally fail because <code>foo is not
-defined</code>. When using the Windows command shell (cmd.exe) it’s best to use double quotes around your jq program when given on the command-line (instead of the <code>-f program-file</code> option), but then double-quotes in the jq program need backslash escaping.</p>
-
-<p>You can affect how jq reads and writes its input and output using some command-line options:</p>
-
+ <p>jq filters run on a stream of JSON data. The input to jq is
+parsed as a sequence of whitespace-separated JSON values which
+are passed through the provided filter one at a time. The
+output(s) of the filter are written to standard out, again as a
+sequence of whitespace-separated JSON data.</p>
+<p>Note: it is important to mind the shell's quoting rules. As a
+general rule it's best to always quote (with single-quote
+characters) the jq program, as too many characters with special
+meaning to jq are also shell meta-characters. For example, <code>jq
+"foo"</code> will fail on most Unix shells because that will be the same
+as <code>jq foo</code>, which will generally fail because <code>foo is not
+defined</code>. When using the Windows command shell (cmd.exe) it's
+best to use double quotes around your jq program when given on the
+command-line (instead of the <code>-f program-file</code> option), but then
+double-quotes in the jq program need backslash escaping.</p>
+<p>You can affect how jq reads and writes its input and output
+using some command-line options:</p>
<ul>
-<li>
-<p><code>--version</code>:</p>
-
+<li><code>--version</code>:</li>
+</ul>
<p>Output the jq version and exit with zero.</p>
-</li>
-
-<li>
-<p><code>--slurp</code>/<code>-s</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--online-input</code>/<code>-I</code>:</p>
-
-<p>When the top-level input value is an array produce its elements instead of the array. This allows on-line processing of potentially very large top-level arrays’ elements.</p>
-</li>
-
-<li>
-<p><code>--raw-input</code>/<code>-R</code>:</p>
-
-<p>Don’t parse the input as JSON. Instead, each line of text is passed to the filter as a string. If combined with <code>--slurp</code>, then the entire input is passed to the filter as a single long string.</p>
-</li>
-
-<li>
-<p><code>--null-input</code>/<code>-n</code>:</p>
-
-<p>Don’t read any input at all! Instead, the filter is run once using <code>null</code> as the input. This is useful when using jq as a simple calculator or to construct JSON data from scratch.</p>
-</li>
-
-<li>
-<p><code>--compact-output</code> / <code>-c</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--color-output</code> / <code>-C</code> and <code>--monochrome-output</code> / <code>-M</code>:</p>
-
-<p>By default, jq outputs colored JSON if writing to a terminal. You can force it to produce color even if writing to a pipe or a file using <code>-C</code>, and disable color with <code>-M</code>.</p>
-</li>
-
-<li>
-<p><code>--ascii-output</code> / <code>-a</code>:</p>
-
-<p>jq usually outputs non-ASCII Unicode codepoints as UTF-8, even if the input specified them as escape sequences (like “\u03bc”). Using this option, you can force jq to produce pure ASCII output with every non-ASCII character replaced with the equivalent escape sequence.</p>
-</li>
-
-<li>
-<p><code>--unbuffered</code></p>
-
-<p>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).</p>
-</li>
-
-<li>
-<p><code>--sort-keys</code> / <code>-S</code>:</p>
-
+<ul>
+<li><code>--slurp</code>/<code>-s</code>:</li>
+</ul>
+<p>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.</p>
+<ul>
+<li><code>--online-input</code>/<code>-I</code>:</li>
+</ul>
+<p>When the top-level input value is an array produce its elements
+ instead of the array. This allows on-line processing of
+ potentially very large top-level arrays' elements.</p>
+<ul>
+<li><code>--raw-input</code>/<code>-R</code>:</li>
+</ul>
+<p>Don't parse the input as JSON. Instead, each line of text is
+ passed to the filter as a string. If combined with <code>--slurp</code>,
+ then the entire input is passed to the filter as a single long
+ string.</p>
+<ul>
+<li><code>--null-input</code>/<code>-n</code>:</li>
+</ul>
+<p>Don't read any input at all! Instead, the filter is run once
+ using <code>null</code> as the input. This is useful when using jq as a
+ simple calculator or to construct JSON data from scratch.</p>
+<ul>
+<li><code>--compact-output</code> / <code>-c</code>:</li>
+</ul>
+<p>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.</p>
+<ul>
+<li><code>--color-output</code> / <code>-C</code> and <code>--monochrome-output</code> / <code>-M</code>:</li>
+</ul>
+<p>By default, jq outputs colored JSON if writing to a
+ terminal. You can force it to produce color even if writing to
+ a pipe or a file using <code>-C</code>, and disable color with <code>-M</code>.</p>
+<ul>
+<li><code>--ascii-output</code> / <code>-a</code>:</li>
+</ul>
+<p>jq usually outputs non-ASCII Unicode codepoints as UTF-8, even
+ if the input specified them as escape sequences (like
+ "\u03bc"). Using this option, you can force jq to produce pure
+ ASCII output with every non-ASCII character replaced with the
+ equivalent escape sequence.</p>
+<ul>
+<li><code>--unbuffered</code></li>
+</ul>
+<p>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).</p>
+<ul>
+<li><code>--sort-keys</code> / <code>-S</code>:</li>
+</ul>
<p>Output the fields of each object with the keys in sorted order.</p>
-</li>
-
-<li>
-<p><code>--raw-output</code> / <code>-r</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>-f filename</code> / <code>--from-file filename</code>:</p>
-
-<p>Read filter from the file rather than from a command line, like awk’s -f option. You can also use ‘#’ to make comments.</p>
-</li>
-
-<li>
-<p><code>-e</code> / <code>--exit-status</code>:</p>
-
-<p>Sets the exit status of jq to 0 if the last output values was neither <code>false</code> nor <code>null</code>, 1 if the last output value was either <code>false</code> or <code>null</code>, or 4 if no valid result was ever produced. Normally jq exits with 2 if there was any usage problem or system error, 3 if there was a jq program compile error, or 0 if the jq program ran.</p>
-</li>
-
-<li>
-<p><code>--arg name value</code>:</p>
-
-<p>This option passes a value to the jq program as a predefined variable. If you run jq with <code>--arg foo bar</code>, then <code>$foo</code> is available in the program and has the value <code>&quot;bar&quot;</code>.</p>
-</li>
-
-<li>
-<p><code>--argfile name filename</code>:</p>
-
-<p>This option passes the first value from the named file as a value to the jq program as a predefined variable. If you run jq with <code>--argfile foo bar</code>, then <code>$foo</code> is available in the program and has the value resulting from parsing the content of the file named <code>bar</code>.</p>
-</li>
+<ul>
+<li><code>--raw-output</code> / <code>-r</code>:</li>
</ul>
-
+<p>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.</p>
+<ul>
+<li><code>-f filename</code> / <code>--from-file filename</code>:</li>
+</ul>
+<p>Read filter from the file rather than from a command line, like
+ awk's -f option. You can also use '#' to make comments.</p>
+<ul>
+<li><code>-e</code> / <code>--exit-status</code>:</li>
+</ul>
+<p>Sets the exit status of jq to 0 if the last output values was
+ neither <code>false</code> nor <code>null</code>, 1 if the last output value was
+ either <code>false</code> or <code>null</code>, or 4 if no valid result was ever
+ produced. Normally jq exits with 2 if there was any usage
+ problem or system error, 3 if there was a jq program compile
+ error, or 0 if the jq program ran.</p>
+<ul>
+<li><code>--arg name value</code>:</li>
+</ul>
+<p>This option passes a value to the jq program as a predefined
+ variable. If you run jq with <code>--arg foo bar</code>, then <code>$foo</code> is
+ available in the program and has the value <code>"bar"</code>.</p>
+<ul>
+<li><code>--argfile name filename</code>:</li>
+</ul>
+<p>This option passes the first value from the named file as a
+ value to the jq program as a predefined variable. If you run jq
+ with <code>--argfile foo bar</code>, then <code>$foo</code> is available in the
+ program and has the value resulting from parsing the content of
+ the file named <code>bar</code>.</p>
</section>
@@ -235,16 +247,15 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id=".">
<h3>
-
-<code>.</code>
-
+ <code>.</code>
</h3>
-
-<p>The absolute simplest (and least interesting) filter is <code>.</code>. This is a filter that takes its input and produces it unchanged as output.</p>
-
-<p>Since jq by default pretty-prints all output, this trivial program can be a useful way of formatting JSON output from, say, <code>curl</code>.</p>
-
+ <p>The absolute simplest (and least interesting) filter
+is <code>.</code>. This is a filter that takes its input and
+produces it unchanged as output.</p>
+<p>Since jq by default pretty-prints all output, this trivial
+program can be a useful way of formatting JSON output from,
+say, <code>curl</code>.</p>
<div>
@@ -257,14 +268,14 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.'</td></tr>
- <tr><th>Input</th><td>&quot;Hello, world!&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;Hello, world!&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;Hello, world!&quot;</td>
+ <td>&#34;Hello, world!&#34;</td>
</tr>
</table>
@@ -276,19 +287,16 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id=".foo,.foo.bar">
<h3>
-
-<code>.foo</code>, <code>.foo.bar</code>
-
+ <code>.foo</code>, <code>.foo.bar</code>
</h3>
-
-<p>The simplest <em>useful</em> filter is <code>.foo</code>. When given a JSON object (aka dictionary or hash) as input, it produces the value at the key “foo”, or null if there’s none present.</p>
-
-<p>If the key contains special characters, you need to surround it with double quotes like this: <code>.&quot;foo$&quot;</code>.</p>
-
+ <p>The simplest <em>useful</em> filter is <code>.foo</code>. When given a
+JSON object (aka dictionary or hash) as input, it produces
+the value at the key "foo", or null if there's none present.</p>
+<p>If the key contains special characters or starts with a digit,
+you need to surround it with double quotes like this: <code>."foo$"</code>.</p>
<p>A filter of the form <code>.foo.bar</code> is equivalent to <code>.foo|.bar</code>.</p>
-
<div>
@@ -300,7 +308,7 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.foo'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;less interesting data&quot;}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;less interesting data&#34;}</td></tr>
<tr>
@@ -314,7 +322,7 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.foo'</td></tr>
- <tr><th>Input</th><td>{&quot;notfoo&quot;: true, &quot;alsonotfoo&quot;: false}</td></tr>
+ <tr><th>Input</th><td>{&#34;notfoo&#34;: true, &#34;alsonotfoo&#34;: false}</td></tr>
<tr>
@@ -327,8 +335,8 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[&quot;foo&quot;]'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42}</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[&#34;foo&#34;]'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42}</td></tr>
<tr>
@@ -347,14 +355,11 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id=".foo?">
<h3>
-
-<code>.foo?</code>
-
+ <code>.foo?</code>
</h3>
-
-<p>Just like <code>.foo</code>, but does not output even an error when <code>.</code> is not an array or an object.</p>
-
+ <p>Just like <code>.foo</code>, but does not output even an error when <code>.</code>
+is not an array or an object.</p>
<div>
@@ -367,7 +372,7 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.foo?'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;less interesting data&quot;}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;less interesting data&#34;}</td></tr>
<tr>
@@ -381,7 +386,7 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.foo?'</td></tr>
- <tr><th>Input</th><td>{&quot;notfoo&quot;: true, &quot;alsonotfoo&quot;: false}</td></tr>
+ <tr><th>Input</th><td>{&#34;notfoo&#34;: true, &#34;alsonotfoo&#34;: false}</td></tr>
<tr>
@@ -394,8 +399,8 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[&quot;foo&quot;]?'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42}</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[&#34;foo&#34;]?'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42}</td></tr>
<tr>
@@ -426,20 +431,26 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
</section>
- <section id=".[<string>],.[2],.[10:15]">
+ <section id=".[&lt;string&gt;],.[2],.[10:15]">
<h3>
-
-<code>.[&lt;string&gt;]</code>, <code>.[2]</code>, <code>.[10:15]</code>
-
+ <code>.[&lt;string&gt;]</code>, <code>.[2]</code>, <code>.[10:15]</code>
</h3>
-
-<p>You can also look up fields of an object using syntax like <code>.[&quot;foo&quot;]</code> (.foo above is a shorthand version of this). This one works for arrays as well, if the key is an integer. Arrays are zero-based (like javascript), so <code>.[2]</code> returns the third element of the array.</p>
-
-<p>The <code>.[10:15]</code> syntax can be used to return a subarray of an array or substring of a string. The array returned by <code>.[10:15]</code> will be of length 5, containing the elements from index 10 (inclusive) to index 15 (exclusive). Either index may be negative (in which case it counts backwards from the end of the array), or omitted (in which case it refers to the start or end of the array).</p>
-
-<p>The <code>?</code> “operator” can also be used with the slice operator, as in <code>.[10:15]?</code>, which outputs values where the inputs are slice-able.</p>
-
+ <p>You can also look up fields of an object using syntax like
+<code>.["foo"]</code> (.foo above is a shorthand version of this). This
+one works for arrays as well, if the key is an
+integer. Arrays are zero-based (like javascript), so <code>.[2]</code>
+returns the third element of the array.</p>
+<p>The <code>.[10:15]</code> syntax can be used to return a subarray of an
+array or substring of a string. The array returned by
+<code>.[10:15]</code> will be of length 5, containing the elements from
+index 10 (inclusive) to index 15 (exclusive). Either index may
+be negative (in which case it counts backwards from the end of
+the array), or omitted (in which case it refers to the start
+or end of the array).</p>
+<p>The <code>?</code> "operator" can also be used with the slice operator,
+as in <code>.[10:15]?</code>, which outputs values where the inputs are
+slice-able.</p>
<div>
@@ -452,21 +463,21 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.[0]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}</td>
+ <td>{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[2]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
@@ -480,56 +491,56 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.[2:4]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;c&quot;, &quot;d&quot;]</td>
+ <td>[&#34;c&#34;, &#34;d&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[2:4]'</td></tr>
- <tr><th>Input</th><td>&quot;abcdefghi&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;abcdefghi&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;cd&quot;</td>
+ <td>&#34;cd&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[:3]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</td>
+ <td>[&#34;a&#34;, &#34;b&#34;, &#34;c&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[-2:]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;d&quot;, &quot;e&quot;]</td>
+ <td>[&#34;d&#34;, &#34;e&#34;]</td>
</tr>
</table>
@@ -541,16 +552,16 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id=".[]">
<h3>
-
-<code>.[]</code>
-
+ <code>.[]</code>
</h3>
-
-<p>If you use the <code>.[index]</code> syntax, but omit the index entirely, it will return <em>all</em> of the elements of an array. Running <code>.[]</code> with the input <code>[1,2,3]</code> will produce the numbers as three separate results, rather than as a single array.</p>
-
-<p>You can also use this on an object, and it will return all the values of the object.</p>
-
+ <p>If you use the <code>.[index]</code> syntax, but omit the index
+entirely, it will return <em>all</em> of the elements of an
+array. Running <code>.[]</code> with the input <code>[1,2,3]</code> will produce the
+numbers as three separate results, rather than as a single
+array.</p>
+<p>You can also use this on an object, and it will return all
+the values of the object.</p>
<div>
@@ -563,21 +574,21 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.[]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}</td>
+ <td>{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}</td>
+ <td>{&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}</td>
</tr>
</table>
@@ -596,7 +607,7 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.[]'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 1}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 1}</td></tr>
<tr>
@@ -622,28 +633,26 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id=".[]?">
<h3>
-
-<code>.[]?</code>
-
+ <code>.[]?</code>
</h3>
-
-<p>Like <code>.[]</code>, but no errors will be output if . is not an array or object.</p>
-
+ <p>Like <code>.[]</code>, but no errors will be output if . is not an array
+or object.</p>
</section>
<section id=",">
<h3>
-
-<code>,</code>
-
+ <code>,</code>
</h3>
-
-<p>If two filters are separated by a comma, then the input will be fed into both and there will be multiple outputs: first, all of the outputs produced by the left expression, and then all of the outputs produced by the right. For instance, filter <code>.foo, .bar</code>, produces both the “foo” fields and “bar” fields as separate outputs.</p>
-
+ <p>If two filters are separated by a comma, then the
+input will be fed into both and there will be multiple
+outputs: first, all of the outputs produced by the left
+expression, and then all of the outputs produced by the
+right. For instance, filter <code>.foo, .bar</code>, produces
+both the "foo" fields and "bar" fields as separate outputs.</p>
<div>
@@ -656,7 +665,7 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.foo, .bar'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;something else&quot;, &quot;baz&quot;: true}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;something else&#34;, &#34;baz&#34;: true}</td></tr>
<tr>
@@ -670,56 +679,56 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<th></th>
- <td>&quot;something else&quot;</td>
+ <td>&#34;something else&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.user, .projects[]'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;projects&quot;: [&quot;jq&quot;, &quot;wikiflow&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;projects&#34;: [&#34;jq&#34;, &#34;wikiflow&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>&quot;stedolan&quot;</td>
+ <td>&#34;stedolan&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;jq&quot;</td>
+ <td>&#34;jq&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;wikiflow&quot;</td>
+ <td>&#34;wikiflow&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[4,2]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;e&quot;</td>
+ <td>&#34;e&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;c&quot;</td>
+ <td>&#34;c&#34;</td>
</tr>
</table>
@@ -731,16 +740,17 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id="|">
<h3>
-
-<code>|</code>
-
+ <code>|</code>
</h3>
-
-<p>The | operator combines two filters by feeding the output(s) of the one on the left into the input of the one on the right. It’s pretty much the same as the Unix shell’s pipe, if you’re used to that.</p>
-
-<p>If the one on the left produces multiple results, the one on the right will be run for each of those results. So, the expression <code>.[] | .foo</code> retrieves the “foo” field of each element of the input array.</p>
-
+ <p>The | operator combines two filters by feeding the output(s) of
+the one on the left into the input of the one on the right. It's
+pretty much the same as the Unix shell's pipe, if you're used to
+that.</p>
+<p>If the one on the left produces multiple results, the one on
+the right will be run for each of those results. So, the
+expression <code>.[] | .foo</code> retrieves the "foo" field of each
+element of the input array.</p>
<div>
@@ -753,21 +763,21 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.[] | .name'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;JSON&quot;</td>
+ <td>&#34;JSON&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;XML&quot;</td>
+ <td>&#34;XML&#34;</td>
</tr>
</table>
@@ -781,26 +791,35 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id="TypesandValues">
<h2>Types and Values</h2>
-
-<p>jq supports the same set of datatypes as JSON - numbers, strings, booleans, arrays, objects (which in JSON-speak are hashes with only string keys), and “null”.</p>
-
-<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 - <code>42</code> is a valid jq expression that takes an input, ignores it, and returns 42 instead.</p>
-
+ <p>jq supports the same set of datatypes as JSON - numbers,
+strings, booleans, arrays, objects (which in JSON-speak are
+hashes with only string keys), and "null".</p>
+<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 - <code>42</code> is a valid jq
+expression that takes an input, ignores it, and returns 42
+instead.</p>
<section id="Arrayconstruction-[]">
<h3>
-
-Array construction - <code>[]</code>
-
+ Array construction - <code>[]</code>
</h3>
-
-<p>As in JSON, <code>[]</code> is used to construct arrays, as in <code>[1,2,3]</code>. The elements of the arrays can be any jq expression. 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 <code>[.foo, .bar, .baz]</code>) or to “collect” all the results of a filter into an array (as in <code>[.items[].name]</code>)</p>
-
-<p>Once you understand the “,” operator, you can look at jq’s array syntax in a different light: the expression <code>[1,2,3]</code> is not using a built-in syntax for comma-separated arrays, but is instead applying the <code>[]</code> operator (collect results) to the expression 1,2,3 (which produces three different results).</p>
-
-<p>If you have a filter <code>X</code> that produces four results, then the expression <code>[X]</code> will produce a single result, an array of four elements.</p>
-
+ <p>As in JSON, <code>[]</code> is used to construct arrays, as in
+<code>[1,2,3]</code>. The elements of the arrays can be any jq
+expression. 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 <code>[.foo, .bar, .baz]</code>) or to "collect" all the results of a
+filter into an array (as in <code>[.items[].name]</code>)</p>
+<p>Once you understand the "," operator, you can look at jq's array
+syntax in a different light: the expression <code>[1,2,3]</code> is not using a
+built-in syntax for comma-separated arrays, but is instead applying
+the <code>[]</code> operator (collect results) to the expression 1,2,3 (which
+produces three different results).</p>
+<p>If you have a filter <code>X</code> that produces four results,
+then the expression <code>[X]</code> will produce a single result, an
+array of four elements.</p>
<div>
@@ -813,14 +832,14 @@ Array construction - <code>[]</code>
<table>
<tr><th></th><td class="jqprogram">jq '[.user, .projects[]]'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;projects&quot;: [&quot;jq&quot;, &quot;wikiflow&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;projects&#34;: [&#34;jq&#34;, &#34;wikiflow&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;stedolan&quot;, &quot;jq&quot;, &quot;wikiflow&quot;]</td>
+ <td>[&#34;stedolan&#34;, &#34;jq&#34;, &#34;wikiflow&#34;]</td>
</tr>
</table>
@@ -832,45 +851,45 @@ Array construction - <code>[]</code>
<section id="Objects-{}">
<h3>
-
-Objects - <code>{}</code>
-
+ Objects - <code>{}</code>
</h3>
-
-<p>Like JSON, <code>{}</code> is for constructing objects (aka dictionaries or hashes), as in: <code>{&quot;a&quot;: 42, &quot;b&quot;: 17}</code>.</p>
-
-<p>If the keys are “sensible” (all alphabetic characters), then the quotes can be left off. 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).</p>
-
-<pre><code>{foo: .bar}</code></pre>
-
-<p>will produce the JSON object <code>{&quot;foo&quot;: 42}</code> if given the JSON object <code>{&quot;bar&quot;:42, &quot;baz&quot;:43}</code>. You can use this to select particular fields of an object: if the input is an object with “user”, “title”, “id”, and “content” fields and you just want “user” and “title”, you can write</p>
-
-<pre><code>{user: .user, title: .title}</code></pre>
-
-<p>Because that’s so common, there’s a shortcut syntax: <code>{user, title}</code>.</p>
-
-<p>If one of the expressions produces multiple results, multiple dictionaries will be produced. If the input’s</p>
-
-<pre><code>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</code></pre>
-
+ <p>Like JSON, <code>{}</code> is for constructing objects (aka
+dictionaries or hashes), as in: <code>{"a": 42, "b": 17}</code>.</p>
+<p>If the keys are "sensible" (all alphabetic characters), then
+the quotes can be left off. 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).</p>
+<pre><code>{foo: .bar}
+</code></pre>
+<p>will produce the JSON object <code>{"foo": 42}</code> if given the JSON
+object <code>{"bar":42, "baz":43}</code>. You can use this to select
+particular fields of an object: if the input is an object
+with "user", "title", "id", and "content" fields and you
+just want "user" and "title", you can write</p>
+<pre><code>{user: .user, title: .title}
+</code></pre>
+<p>Because that's so common, there's a shortcut syntax: <code>{user, title}</code>.</p>
+<p>If one of the expressions produces multiple results,
+multiple dictionaries will be produced. If the input's</p>
+<pre><code>{"user":"stedolan","titles":["JQ Primer", "More JQ"]}
+</code></pre>
<p>then the expression</p>
-
-<pre><code>{user, title: .titles[]}</code></pre>
-
+<pre><code>{user, title: .titles[]}
+</code></pre>
<p>will produce two outputs:</p>
-
-<pre><code>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;JQ Primer&quot;}
-{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;More JQ&quot;}</code></pre>
-
-<p>Putting parentheses around the key means it will be evaluated as an expression. With the same input as above,</p>
-
-<pre><code>{(.user): .titles}</code></pre>
-
+<pre><code>{"user":"stedolan", "title": "JQ Primer"}
+{"user":"stedolan", "title": "More JQ"}
+</code></pre>
+<p>Putting parentheses around the key means it will be evaluated as an
+expression. With the same input as above,</p>
+<pre><code>{(.user): .titles}
+</code></pre>
<p>produces</p>
-
-<pre><code>{&quot;stedolan&quot;: [&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</code></pre>
-
+<pre><code>{"stedolan": ["JQ Primer", "More JQ"]}
+</code></pre>
<div>
@@ -883,35 +902,35 @@ Objects - <code>{}</code>
<table>
<tr><th></th><td class="jqprogram">jq '{user, title: .titles[]}'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;,&#34;titles&#34;:[&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;JQ Primer&quot;}</td>
+ <td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;title&#34;: &#34;JQ Primer&#34;}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;More JQ&quot;}</td>
+ <td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;title&#34;: &#34;More JQ&#34;}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '{(.user): .titles}'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;,&#34;titles&#34;:[&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;stedolan&quot;: [&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td>
+ <td>{&#34;stedolan&#34;: [&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td>
</tr>
</table>
@@ -925,40 +944,40 @@ Objects - <code>{}</code>
<section id="Builtinoperatorsandfunctions">
<h2>Builtin operators and functions</h2>
-
-<p>Some jq operator (for instance, <code>+</code>) 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>
-
+ <p>Some jq operator (for instance, <code>+</code>) 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>
<section id="Addition-+">
<h3>
-
-Addition - <code>+</code>
-
+ Addition - <code>+</code>
</h3>
-
-<p>The operator <code>+</code> takes two filters, applies them both to the same input, and adds the results together. What “adding” means depends on the types involved:</p>
-
+ <p>The operator <code>+</code> takes two filters, applies them both
+to the same input, and adds the results together. What
+"adding" means depends on the types involved:</p>
<ul>
<li>
<p><strong>Numbers</strong> are added by normal arithmetic.</p>
</li>
-
<li>
<p><strong>Arrays</strong> are added by being concatenated into a larger array.</p>
</li>
-
<li>
<p><strong>Strings</strong> are added by being joined into a larger string.</p>
</li>
-
<li>
-<p><strong>Objects</strong> are added by merging, that is, inserting all the key-value pairs from both objects into a single combined object. If both objects contain a value for the same key, the object on the right of the <code>+</code> wins. (For recursive merge use the <code>*</code> operator.)</p>
+<p><strong>Objects</strong> are added by merging, that is, inserting all
+ the key-value pairs from both objects into a single
+ combined object. If both objects contain a value for the
+ same key, the object on the right of the <code>+</code> wins. (For
+ recursive merge use the <code>*</code> operator.)</p>
</li>
</ul>
-
-<p><code>null</code> can be added to any value, and returns the other value unchanged.</p>
-
+<p><code>null</code> can be added to any value, and returns the other
+value unchanged.</p>
<div>
@@ -971,7 +990,7 @@ Addition - <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + 1'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 7}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 7}</td></tr>
<tr>
@@ -985,7 +1004,7 @@ Addition - <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + .b'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: [1,2], &quot;b&quot;: [3,4]}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: [1,2], &#34;b&#34;: [3,4]}</td></tr>
<tr>
@@ -999,7 +1018,7 @@ Addition - <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + null'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1}</td></tr>
<tr>
@@ -1034,7 +1053,7 @@ Addition - <code>+</code>
<th>Output</th>
- <td>{&quot;a&quot;: 42, &quot;b&quot;: 2, &quot;c&quot;: 3}</td>
+ <td>{&#34;a&#34;: 42, &#34;b&#34;: 2, &#34;c&#34;: 3}</td>
</tr>
</table>
@@ -1046,14 +1065,12 @@ Addition - <code>+</code>
<section id="Subtraction--">
<h3>
-
-Subtraction - <code>-</code>
-
+ Subtraction - <code>-</code>
</h3>
-
-<p>As well as normal arithmetic subtraction on numbers, the <code>-</code> operator can be used on arrays to remove all occurences of the second array’s elements from the first array.</p>
-
+ <p>As well as normal arithmetic subtraction on numbers, the <code>-</code>
+operator can be used on arrays to remove all occurrences of
+the second array's elements from the first array.</p>
<div>
@@ -1066,7 +1083,7 @@ Subtraction - <code>-</code>
<table>
<tr><th></th><td class="jqprogram">jq '4 - .a'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:3}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:3}</td></tr>
<tr>
@@ -1079,15 +1096,15 @@ Subtraction - <code>-</code>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '. - [&quot;xml&quot;, &quot;yaml&quot;]'</td></tr>
- <tr><th>Input</th><td>[&quot;xml&quot;, &quot;yaml&quot;, &quot;json&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '. - [&#34;xml&#34;, &#34;yaml&#34;]'</td></tr>
+ <tr><th>Input</th><td>[&#34;xml&#34;, &#34;yaml&#34;, &#34;json&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;json&quot;]</td>
+ <td>[&#34;json&#34;]</td>
</tr>
</table>
@@ -1099,20 +1116,18 @@ Subtraction - <code>-</code>
<section id="Multiplication,division,modulo-*,/,and%">
<h3>
-
-Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</code>
-
+ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</code>
</h3>
-
-<p>These operators only work on numbers, and do the expected.</p>
-
-<p>Multiplying a string by a number produces the concatenation of that string that many times.</p>
-
-<p>Dividing a string by another splits the first using the second as separators.</p>
-
-<p>Multiplying two objects will merge them recursively: this works like addition but if both objects contain a value for the same key, and the values are objects, the two are merged with the same strategy.</p>
-
+ <p>These operators only work on numbers, and do the expected.</p>
+<p>Multiplying a string by a number produces the concatenation of
+that string that many times.</p>
+<p>Dividing a string by another splits the first using the second
+as separators.</p>
+<p>Multiplying two objects will merge them recursively: this works
+like addition but if both objects contain a value for the
+same key, and the values are objects, the two are merged with
+the same strategy.</p>
<div>
@@ -1138,21 +1153,21 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '. / &quot;, &quot;'</td></tr>
- <tr><th>Input</th><td>&quot;a, b,c,d, e&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq '. / &#34;, &#34;'</td></tr>
+ <tr><th>Input</th><td>&#34;a, b,c,d, e&#34;</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;a&quot;,&quot;b,c,d&quot;,&quot;e&quot;]</td>
+ <td>[&#34;a&#34;,&#34;b,c,d&#34;,&#34;e&#34;]</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '{&quot;k&quot;: {&quot;a&quot;: 1, &quot;b&quot;: 2}} * {&quot;k&quot;: {&quot;a&quot;: 0,&quot;c&quot;: 3}}'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '{&#34;k&#34;: {&#34;a&#34;: 1, &#34;b&#34;: 2}} * {&#34;k&#34;: {&#34;a&#34;: 0,&#34;c&#34;: 3}}'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -1160,7 +1175,7 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<th>Output</th>
- <td>{&quot;k&quot;: {&quot;a&quot;: 0, &quot;b&quot;: 2, &quot;c&quot;: 3}}</td>
+ <td>{&#34;k&#34;: {&#34;a&#34;: 0, &#34;b&#34;: 2, &#34;c&#34;: 3}}</td>
</tr>
</table>
@@ -1172,33 +1187,28 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<section id="length">
<h3>
-
-<code>length</code>
-
+ <code>length</code>
</h3>
-
-<p>The builtin function <code>length</code> gets the length of various different types of value:</p>
-
+ <p>The builtin function <code>length</code> gets the length of various
+different types of value:</p>
<ul>
<li>
-<p>The length of a <strong>string</strong> is the number of Unicode codepoints it contains (which will be the same as its JSON-encoded length in bytes if it’s pure ASCII).</p>
+<p>The length of a <strong>string</strong> is the number of Unicode
+ codepoints it contains (which will be the same as its
+ JSON-encoded length in bytes if it's pure ASCII).</p>
</li>
-
<li>
<p>The length of an <strong>array</strong> is the number of elements.</p>
</li>
-
<li>
<p>The length of an <strong>object</strong> is the number of key-value pairs.</p>
</li>
-
<li>
<p>The length of <strong>null</strong> is zero.</p>
</li>
</ul>
-
<div>
@@ -1210,7 +1220,7 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<table>
<tr><th></th><td class="jqprogram">jq '.[] | length'</td></tr>
- <tr><th>Input</th><td>[[1,2], &quot;string&quot;, {&quot;a&quot;:2}, null]</td></tr>
+ <tr><th>Input</th><td>[[1,2], &#34;string&#34;, {&#34;a&#34;:2}, null]</td></tr>
<tr>
@@ -1250,18 +1260,18 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<section id="keys">
<h3>
-
-<code>keys</code>
-
+ <code>keys</code>
</h3>
-
-<p>The builtin function <code>keys</code>, when given an object, returns its keys in an array.</p>
-
-<p>The keys are sorted “alphabetically”, by unicode codepoint order. This is not an order that makes particular sense in any particular language, but you can count on it being the same for any two objects with the same set of keys, regardless of locale settings.</p>
-
-<p>When <code>keys</code> is given an array, it returns the valid indices for that array: the integers from 0 to length-1.</p>
-
+ <p>The builtin function <code>keys</code>, when given an object, returns
+its keys in an array.</p>
+<p>The keys are sorted "alphabetically", by unicode codepoint
+order. This is not an order that makes particular sense in
+any particular language, but you can count on it being the
+same for any two objects with the same set of keys,
+regardless of locale settings.</p>
+<p>When <code>keys</code> is given an array, it returns the valid indices
+for that array: the integers from 0 to length-1.</p>
<div>
@@ -1274,14 +1284,14 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<table>
<tr><th></th><td class="jqprogram">jq 'keys'</td></tr>
- <tr><th>Input</th><td>{&quot;abc&quot;: 1, &quot;abcd&quot;: 2, &quot;Foo&quot;: 3}</td></tr>
+ <tr><th>Input</th><td>{&#34;abc&#34;: 1, &#34;abcd&#34;: 2, &#34;Foo&#34;: 3}</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;Foo&quot;, &quot;abc&quot;, &quot;abcd&quot;]</td>
+ <td>[&#34;Foo&#34;, &#34;abc&#34;, &#34;abcd&#34;]</td>
</tr>
</table>
@@ -1307,16 +1317,15 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<section id="has">
<h3>
-
-<code>has</code>
-
+ <code>has</code>
</h3>
-
-<p>The builtin function <code>has</code> returns whether the input object has the given key, or the input array has an element at the given index.</p>
-
-<p><code>has($key)</code> has the same effect as checking whether <code>$key</code> is a member of the array returned by <code>keys</code>, although <code>has</code> will be faster.</p>
-
+ <p>The builtin function <code>has</code> returns whether the input object
+has the given key, or the input array has an element at the
+given index.</p>
+<p><code>has($key)</code> has the same effect as checking whether <code>$key</code>
+is a member of the array returned by <code>keys</code>, although <code>has</code>
+will be faster.</p>
<div>
@@ -1328,8 +1337,8 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<div id="example15" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'map(has(&quot;foo&quot;))'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;: 42}, {}]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'map(has(&#34;foo&#34;))'</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;: 42}, {}]</td></tr>
<tr>
@@ -1343,7 +1352,7 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<table>
<tr><th></th><td class="jqprogram">jq 'map(has(2))'</td></tr>
- <tr><th>Input</th><td>[[0,1], [&quot;a&quot;,&quot;b&quot;,&quot;c&quot;]]</td></tr>
+ <tr><th>Input</th><td>[[0,1], [&#34;a&#34;,&#34;b&#34;,&#34;c&#34;]]</td></tr>
<tr>
@@ -1362,14 +1371,11 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<section id="del">
<h3>
-
-<code>del</code>
-
+ <code>del</code>
</h3>
-
-<p>The builtin function <code>del</code> removes a key and its corresponding value from an object.</p>
-
+ <p>The builtin function <code>del</code> removes a key and its corresponding
+value from an object.</p>
<div>
@@ -1382,28 +1388,28 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<table>
<tr><th></th><td class="jqprogram">jq 'del(.foo)'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: 9001, &quot;baz&quot;: 42}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: 9001, &#34;baz&#34;: 42}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;bar&quot;: 9001, &quot;baz&quot;: 42}</td>
+ <td>{&#34;bar&#34;: 9001, &#34;baz&#34;: 42}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'del(.[1, 2])'</td></tr>
- <tr><th>Input</th><td>[&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;foo&#34;, &#34;bar&#34;, &#34;baz&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;foo&quot;]</td>
+ <td>[&#34;foo&#34;]</td>
</tr>
</table>
@@ -1415,17 +1421,17 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<section id="to_entries,from_entries,with_entries">
<h3>
-
-<code>to_entries</code>, <code>from_entries</code>, <code>with_entries</code>
-
+ <code>to_entries</code>, <code>from_entries</code>, <code>with_entries</code>
</h3>
-
-<p>These functions convert between an object and an array of key-value pairs. If <code>to_entries</code> is passed an object, then for each <code>k: v</code> entry in the input, the output array includes <code>{&quot;key&quot;: k, &quot;value&quot;: v}</code>.</p>
-
-<p><code>from_entries</code> does the opposite conversion, and <code>with_entries(foo)</code> is a shorthand for <code>to_entries |
-map(foo) | from_entries</code>, useful for doing some operation to all keys and values of an object.</p>
-
+ <p>These functions convert between an object and an array of
+key-value pairs. If <code>to_entries</code> is passed an object, then
+for each <code>k: v</code> entry in the input, the output array
+includes <code>{"key": k, "value": v}</code>.</p>
+<p><code>from_entries</code> does the opposite conversion, and
+<code>with_entries(foo)</code> is a shorthand for <code>to_entries |
+map(foo) | from_entries</code>, useful for doing some operation to
+all keys and values of an object.</p>
<div>
@@ -1438,42 +1444,42 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'to_entries'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;key&quot;:&quot;a&quot;, &quot;value&quot;:1}, {&quot;key&quot;:&quot;b&quot;, &quot;value&quot;:2}]</td>
+ <td>[{&#34;key&#34;:&#34;a&#34;, &#34;value&#34;:1}, {&#34;key&#34;:&#34;b&#34;, &#34;value&#34;:2}]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'from_entries'</td></tr>
- <tr><th>Input</th><td>[{&quot;key&quot;:&quot;a&quot;, &quot;value&quot;:1}, {&quot;key&quot;:&quot;b&quot;, &quot;value&quot;:2}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;key&#34;:&#34;a&#34;, &#34;value&#34;:1}, {&#34;key&#34;:&#34;b&#34;, &#34;value&#34;:2}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td>
+ <td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'with_entries(.key |= &quot;KEY_&quot; + .)'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'with_entries(.key |= &#34;KEY_&#34; + .)'</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;KEY_a&quot;: 1, &quot;KEY_b&quot;: 2}</td>
+ <td>{&#34;KEY_a&#34;: 1, &#34;KEY_b&#34;: 2}</td>
</tr>
</table>
@@ -1485,16 +1491,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="select">
<h3>
-
-<code>select</code>
-
+ <code>select</code>
</h3>
-
-<p>The function <code>select(foo)</code> produces its input unchanged if <code>foo</code> returns true for that input, and produces no output otherwise.</p>
-
-<p>It’s useful for filtering lists: <code>[1,2,3] | map(select(. &gt;= 2))</code> will give you <code>[2,3]</code>.</p>
-
+ <p>The function <code>select(foo)</code> produces its input unchanged if
+<code>foo</code> returns true for that input, and produces no output
+otherwise.</p>
+<p>It's useful for filtering lists: <code>[1,2,3] | map(select(. &gt;= 2))</code>
+will give you <code>[2,3]</code>.</p>
<div>
@@ -1526,14 +1530,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="arrays,objects,iterables,booleans,numbers,strings,nulls,values,scalars">
<h3>
-
-<code>arrays</code>, <code>objects</code>, <code>iterables</code>, <code>booleans</code>, <code>numbers</code>, <code>strings</code>, <code>nulls</code>, <code>values</code>, <code>scalars</code>
-
+ <code>arrays</code>, <code>objects</code>, <code>iterables</code>, <code>booleans</code>, <code>numbers</code>, <code>strings</code>, <code>nulls</code>, <code>values</code>, <code>scalars</code>
</h3>
-
-<p>These built-ins select only inputs that are arrays, objects, iterables (arrays or objects), booleans, numbers, strings, null, non-null values, and non-iterables, respectively.</p>
-
+ <p>These built-ins select only inputs that are arrays, objects,
+iterables (arrays or objects), booleans, numbers, strings,
+null, non-null values, and non-iterables, respectively.</p>
<div>
@@ -1546,7 +1548,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[]|numbers'</td></tr>
- <tr><th>Input</th><td>[[],{},1,&quot;foo&quot;,null,true,false]</td></tr>
+ <tr><th>Input</th><td>[[],{},1,&#34;foo&#34;,null,true,false]</td></tr>
<tr>
@@ -1565,16 +1567,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="empty">
<h3>
-
-<code>empty</code>
-
+ <code>empty</code>
</h3>
-
-<p><code>empty</code> returns no results. None at all. Not even <code>null</code>.</p>
-
-<p>It’s useful on occasion. You’ll know if you need it :)</p>
-
+ <p><code>empty</code> returns no results. None at all. Not even <code>null</code>.</p>
+<p>It's useful on occasion. You'll know if you need it :)</p>
<div>
@@ -1627,16 +1624,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="map(x)">
<h3>
-
-<code>map(x)</code>
-
+ <code>map(x)</code>
</h3>
-
-<p>For any filter <code>x</code>, <code>map(x)</code> will run that filter for each element of the input array, and produce the outputs a new array. <code>map(.+1)</code> will increment each element of an array of numbers.</p>
-
-<p><code>map(x)</code> is equivalent to <code>[.[] | x]</code>. In fact, this is how it’s defined.</p>
-
+ <p>For any filter <code>x</code>, <code>map(x)</code> will run that filter for each
+element of the input array, and produce the outputs a new
+array. <code>map(.+1)</code> will increment each element of an array of numbers.</p>
+<p><code>map(x)</code> is equivalent to <code>[.[] | x]</code>. In fact, this is how
+it's defined.</p>
<div>
@@ -1668,18 +1663,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="paths">
<h3>
-
-<code>paths</code>
-
+ <code>paths</code>
</h3>
-
-<p>Outputs the paths to all the elements in its input (except it does not output the empty list, representing . itself).</p>
-
+ <p>Outputs the paths to all the elements in its input (except it
+does not output the empty list, representing . itself).</p>
<p><code>paths</code> is equivalent to</p>
-
-<pre><code>def paths: path(recurse(if (type|. == &quot;array&quot; or . == &quot;object&quot;) then .[] else empty end))|select(length &gt; 0);</code></pre>
-
+<pre><code>def paths: path(recurse(if (type|. == "array" or . == "object") then .[] else empty end))|select(length &gt; 0);
+</code></pre>
<div>
@@ -1692,14 +1683,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '[paths]'</td></tr>
- <tr><th>Input</th><td>[1,[[],{&quot;a&quot;:2}]]</td></tr>
+ <tr><th>Input</th><td>[1,[[],{&#34;a&#34;:2}]]</td></tr>
<tr>
<th>Output</th>
- <td>[[0],[1],[1,0],[1,1],[1,1,&quot;a&quot;]]</td>
+ <td>[[0],[1],[1,0],[1,1],[1,1,&#34;a&#34;]]</td>
</tr>
</table>
@@ -1711,14 +1702,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="leaf_paths">
<h3>
-
-<code>leaf_paths</code>
-
+ <code>leaf_paths</code>
</h3>
-
-<p>Outputs the paths to all the leaves (non-array, non-object elements) in its input.</p>
-
+ <p>Outputs the paths to all the leaves (non-array, non-object
+elements) in its input.</p>
<div>
@@ -1731,14 +1719,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '[leaf_paths]'</td></tr>
- <tr><th>Input</th><td>[1,[[],{&quot;a&quot;:2}]]</td></tr>
+ <tr><th>Input</th><td>[1,[[],{&#34;a&#34;:2}]]</td></tr>
<tr>
<th>Output</th>
- <td>[[0],[1,1,&quot;a&quot;]]</td>
+ <td>[[0],[1,1,&#34;a&#34;]]</td>
</tr>
</table>
@@ -1750,17 +1738,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="add">
<h3>
-
-<code>add</code>
-
+ <code>add</code>
</h3>
-
-<p>The filter <code>add</code> takes as input an array, and produces as output the elements of the array added together. This might mean summed, concatenated or merged depending on the types of the elements of the input array - the rules are the same as those for the <code>+</code> operator (described above).</p>
-
+ <p>The filter <code>add</code> takes as input an array, and produces as
+output the elements of the array added together. This might
+mean summed, concatenated or merged depending on the types
+of the elements of the input array - the rules are the same
+as those for the <code>+</code> operator (described above).</p>
<p>If the input is an empty array, <code>add</code> returns <code>null</code>.</p>
-
<div>
@@ -1772,14 +1759,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'add'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;abc&quot;</td>
+ <td>&#34;abc&#34;</td>
</tr>
</table>
@@ -1819,17 +1806,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="any">
<h3>
-
-<code>any</code>
-
+ <code>any</code>
</h3>
-
-<p>The filter <code>any</code> takes as input an array of boolean values, and produces <code>true</code> as output if any of the elements of the array are <code>true</code>.</p>
-
+ <p>The filter <code>any</code> takes as input an array of boolean values,
+and produces <code>true</code> as output if any of the elements of
+the array are <code>true</code>.</p>
<p>If the input is an empty array, <code>any</code> returns <code>false</code>.</p>
-
<div>
@@ -1888,17 +1872,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="all">
<h3>
-
-<code>all</code>
-
+ <code>all</code>
</h3>
-
-<p>The filter <code>all</code> takes as input an array of boolean values, and produces <code>true</code> as output if all of the elements of the array are <code>true</code>.</p>
-
+ <p>The filter <code>all</code> takes as input an array of boolean values,
+and produces <code>true</code> as output if all of the elements of
+the array are <code>true</code>.</p>
<p>If the input is an empty array, <code>all</code> returns <code>true</code>.</p>
-
<div>
@@ -1957,14 +1938,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="range">
<h3>
-
-<code>range</code>
-
+ <code>range</code>
</h3>
-
-<p>The <code>range</code> function produces a range of numbers. <code>range(4;10)</code> produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers are produced as separate outputs. Use <code>[range(4;10)]</code> to get a range as an array.</p>
-
+ <p>The <code>range</code> function produces a range of numbers. <code>range(4;10)</code>
+produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers
+are produced as separate outputs. Use <code>[range(4;10)]</code> to get a range as
+an array.</p>
<div>
@@ -2017,14 +1997,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="floor">
<h3>
-
-<code>floor</code>
-
+ <code>floor</code>
</h3>
-
-<p>The <code>floor</code> function returns the floor of its numeric input.</p>
-
+ <p>The <code>floor</code> function returns the floor of its numeric input.</p>
<div>
@@ -2056,14 +2032,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="sqrt">
<h3>
-
-<code>sqrt</code>
-
+ <code>sqrt</code>
</h3>
-
-<p>The <code>sqrt</code> function returns the square root of its numeric input.</p>
-
+ <p>The <code>sqrt</code> function returns the square root of its numeric input.</p>
<div>
@@ -2095,14 +2067,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="tonumber">
<h3>
-
-<code>tonumber</code>
-
+ <code>tonumber</code>
</h3>
-
-<p>The <code>tonumber</code> function parses its input as a number. It will convert correctly-formatted strings to their numeric equivalent, leave numbers alone, and give an error on all other input.</p>
-
+ <p>The <code>tonumber</code> function parses its input as a number. It
+will convert correctly-formatted strings to their numeric
+equivalent, leave numbers alone, and give an error on all other input.</p>
<div>
@@ -2115,7 +2085,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[] | tonumber'</td></tr>
- <tr><th>Input</th><td>[1, &quot;1&quot;]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;1&#34;]</td></tr>
<tr>
@@ -2141,14 +2111,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="tostring">
<h3>
-
-<code>tostring</code>
-
+ <code>tostring</code>
</h3>
-
-<p>The <code>tostring</code> function prints its input as a string. Strings are left unchanged, and all other values are JSON-encoded.</p>
-
+ <p>The <code>tostring</code> function prints its input as a
+string. Strings are left unchanged, and all other values are
+JSON-encoded.</p>
<div>
@@ -2161,28 +2129,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[] | tostring'</td></tr>
- <tr><th>Input</th><td>[1, &quot;1&quot;, [1]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;1&#34;, [1]]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;1&quot;</td>
+ <td>&#34;1&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;1&quot;</td>
+ <td>&#34;1&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;[1]&quot;</td>
+ <td>&#34;[1]&#34;</td>
</tr>
</table>
@@ -2194,14 +2162,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="type">
<h3>
-
-<code>type</code>
-
+ <code>type</code>
</h3>
-
-<p>The <code>type</code> function returns the type of its argument as a string, which is one of null, boolean, number, string, array or object.</p>
-
+ <p>The <code>type</code> function returns the type of its argument as a
+string, which is one of null, boolean, number, string, array
+or object.</p>
<div>
@@ -2214,14 +2180,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'map(type)'</td></tr>
- <tr><th>Input</th><td>[0, false, [], {}, null, &quot;hello&quot;]</td></tr>
+ <tr><th>Input</th><td>[0, false, [], {}, null, &#34;hello&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;number&quot;, &quot;boolean&quot;, &quot;array&quot;, &quot;object&quot;, &quot;null&quot;, &quot;string&quot;]</td>
+ <td>[&#34;number&#34;, &#34;boolean&#34;, &#34;array&#34;, &#34;object&#34;, &#34;null&#34;, &#34;string&#34;]</td>
</tr>
</table>
@@ -2233,34 +2199,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="sort,sort_by">
<h3>
-
-<code>sort, sort_by</code>
-
+ <code>sort, sort_by</code>
</h3>
-
-<p>The <code>sort</code> functions sorts its input, which must be an array. Values are sorted in the following order:</p>
-
+ <p>The <code>sort</code> functions sorts its input, which must be an
+array. Values are sorted in the following order:</p>
<ul>
<li><code>null</code></li>
-
<li><code>false</code></li>
-
<li><code>true</code></li>
-
<li>numbers</li>
-
<li>strings, in alphabetical order (by unicode codepoint value)</li>
-
<li>arrays, in lexical order</li>
-
<li>objects</li>
</ul>
-
-<p>The ordering for objects is a little complex: first they’re compared by comparing their sets of keys (as arrays in sorted order), and if their keys are equal then the values are compared key by key.</p>
-
-<p><code>sort_by</code> may be used to sort by a particular field of an object, or by applying any jq filter. <code>sort_by(foo)</code> compares two elements by comparing the result of <code>foo</code> on each element.</p>
-
+<p>The ordering for objects is a little complex: first they're
+compared by comparing their sets of keys (as arrays in
+sorted order), and if their keys are equal then the values
+are compared key by key.</p>
+<p><code>sort_by</code> may be used to sort by a particular field of an
+object, or by applying any jq filter. <code>sort_by(foo)</code>
+compares two elements by comparing the result of <code>foo</code> on
+each element.</p>
<div>
@@ -2287,14 +2247,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'sort_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:4, &quot;bar&quot;:10}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:2, &quot;bar&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:4, &#34;bar&#34;:10}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:2, &#34;bar&#34;:1}]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;foo&quot;:2, &quot;bar&quot;:1}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:4, &quot;bar&quot;:10}]</td>
+ <td>[{&#34;foo&#34;:2, &#34;bar&#34;:1}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:4, &#34;bar&#34;:10}]</td>
</tr>
</table>
@@ -2306,16 +2266,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="group_by">
<h3>
-
-<code>group_by</code>
-
+ <code>group_by</code>
</h3>
-
-<p><code>group_by(.foo)</code> takes as input an array, groups the elements having the same <code>.foo</code> field into separate arrays, and produces all of these arrays as elements of a larger array, sorted by the value of the <code>.foo</code> field.</p>
-
-<p>Any jq expression, not just a field access, may be used in place of <code>.foo</code>. The sorting order is the same as described in the <code>sort</code> function above.</p>
-
+ <p><code>group_by(.foo)</code> takes as input an array, groups the
+elements having the same <code>.foo</code> field into separate arrays,
+and produces all of these arrays as elements of a larger
+array, sorted by the value of the <code>.foo</code> field.</p>
+<p>Any jq expression, not just a field access, may be used in
+place of <code>.foo</code>. The sorting order is the same as described
+in the <code>sort</code> function above.</p>
<div>
@@ -2328,14 +2288,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'group_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:1, &quot;bar&quot;:10}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:1, &quot;bar&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:1, &#34;bar&#34;:10}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:1, &#34;bar&#34;:1}]</td></tr>
<tr>
<th>Output</th>
- <td>[[{&quot;foo&quot;:1, &quot;bar&quot;:10}, {&quot;foo&quot;:1, &quot;bar&quot;:1}], [{&quot;foo&quot;:3, &quot;bar&quot;:100}]]</td>
+ <td>[[{&#34;foo&#34;:1, &#34;bar&#34;:10}, {&#34;foo&#34;:1, &#34;bar&#34;:1}], [{&#34;foo&#34;:3, &#34;bar&#34;:100}]]</td>
</tr>
</table>
@@ -2347,14 +2307,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="min,max,min_by,max_by">
<h3>
-
-<code>min</code>, <code>max</code>, <code>min_by</code>, <code>max_by</code>
-
+ <code>min</code>, <code>max</code>, <code>min_by</code>, <code>max_by</code>
</h3>
-
-<p>Find the minimum or maximum element of the input array. The <code>_by</code> versions allow you to specify a particular field or property to examine, e.g. <code>min_by(.foo)</code> finds the object with the smallest <code>foo</code> field.</p>
-
+ <p>Find the minimum or maximum element of the input array. The
+<code>_by</code> versions allow you to specify a particular field or
+property to examine, e.g. <code>min_by(.foo)</code> finds the object
+with the smallest <code>foo</code> field.</p>
<div>
@@ -2381,14 +2340,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'max_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:1, &quot;bar&quot;:14}, {&quot;foo&quot;:2, &quot;bar&quot;:3}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:1, &#34;bar&#34;:14}, {&#34;foo&#34;:2, &#34;bar&#34;:3}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;:2, &quot;bar&quot;:3}</td>
+ <td>{&#34;foo&#34;:2, &#34;bar&#34;:3}</td>
</tr>
</table>
@@ -2400,14 +2359,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="unique">
<h3>
-
-<code>unique</code>
-
+ <code>unique</code>
</h3>
-
-<p>The <code>unique</code> function takes as input an array and produces an array of the same elements, in sorted order, with duplicates removed.</p>
-
+ <p>The <code>unique</code> function takes as input an array and produces
+an array of the same elements, in sorted order, with
+duplicates removed.</p>
<div>
@@ -2439,14 +2396,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="unique_by">
<h3>
-
-<code>unique_by</code>
-
+ <code>unique_by</code>
</h3>
-
-<p>The <code>unique_by(.foo)</code> function takes as input an array and produces an array of the same elements, in sorted order, with elqements with a duplicate <code>.foo</code> field removed. Think of it as making an array by taking one element out of every group produced by <code>group_by</code>.</p>
-
+ <p>The <code>unique_by(.foo)</code> function takes as input an array and produces
+an array of the same elements, in sorted order, with
+elqements with a duplicate <code>.foo</code> field removed. Think of it as making
+an array by taking one element out of every group produced by
+<code>group_by</code>.</p>
<div>
@@ -2459,28 +2416,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'unique_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;: 1, &quot;bar&quot;: 2}, {&quot;foo&quot;: 1, &quot;bar&quot;: 3}, {&quot;foo&quot;: 4, &quot;bar&quot;: 5}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;: 1, &#34;bar&#34;: 2}, {&#34;foo&#34;: 1, &#34;bar&#34;: 3}, {&#34;foo&#34;: 4, &#34;bar&#34;: 5}]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;foo&quot;: 1, &quot;bar&quot;: 2}, {&quot;foo&quot;: 4, &quot;bar&quot;: 5}]</td>
+ <td>[{&#34;foo&#34;: 1, &#34;bar&#34;: 2}, {&#34;foo&#34;: 4, &#34;bar&#34;: 5}]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'unique_by(length)'</td></tr>
- <tr><th>Input</th><td>[&quot;chunky&quot;, &quot;bacon&quot;, &quot;kitten&quot;, &quot;cicada&quot;, &quot;asparagus&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;chunky&#34;, &#34;bacon&#34;, &#34;kitten&#34;, &#34;cicada&#34;, &#34;asparagus&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;bacon&quot;, &quot;chunky&quot;, &quot;asparagus&quot;]</td>
+ <td>[&#34;bacon&#34;, &#34;chunky&#34;, &#34;asparagus&#34;]</td>
</tr>
</table>
@@ -2492,14 +2449,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="reverse">
<h3>
-
-<code>reverse</code>
-
+ <code>reverse</code>
</h3>
-
-<p>This function reverses an array.</p>
-
+ <p>This function reverses an array.</p>
<div>
@@ -2531,14 +2484,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="contains">
<h3>
-
-<code>contains</code>
-
+ <code>contains</code>
</h3>
-
-<p>The filter <code>contains(b)</code> will produce true if b is completely contained within the input. A string B is contained in a string A if B is a substring of A. An array B is contained in an array A is all elements in B are contained in any element in A. An object B is contained in object A if all of the values in B are contained in the value in A with the same key. All other types are assumed to be contained in each other if they are equal.</p>
-
+ <p>The filter <code>contains(b)</code> will produce true if b is
+completely contained within the input. A string B is
+contained in a string A if B is a substring of A. An array B
+is contained in an array A is all elements in B are
+contained in any element in A. An object B is contained in
+object A if all of the values in B are contained in the
+value in A with the same key. All other types are assumed to
+be contained in each other if they are equal.</p>
<div>
@@ -2550,8 +2506,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example39" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'contains(&quot;bar&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foobar&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains(&#34;bar&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foobar&#34;</td></tr>
<tr>
@@ -2564,8 +2520,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'contains([&quot;baz&quot;, &quot;bar&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains([&#34;baz&#34;, &#34;bar&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;]</td></tr>
<tr>
@@ -2578,8 +2534,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'contains([&quot;bazzzzz&quot;, &quot;bar&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains([&#34;bazzzzz&#34;, &#34;bar&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;]</td></tr>
<tr>
@@ -2593,7 +2549,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'contains({foo: 12, bar: [{barp: 12}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]}</td></tr>
<tr>
@@ -2607,7 +2563,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'contains({foo: 12, bar: [{barp: 15}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]}</td></tr>
<tr>
@@ -2626,14 +2582,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="indices(s)">
<h3>
-
-<code>indices(s)</code>
-
+ <code>indices(s)</code>
</h3>
-
-<p>Outputs an array containing the indices in <code>.</code> where <code>s</code> occurs. The input may be an array, in which case if <code>s</code> is an array then the indices output will be those where all elements in <code>.</code> match those of <code>s</code>.</p>
-
+ <p>Outputs an array containing the indices in <code>.</code> where <code>s</code>
+occurs. The input may be an array, in which case if <code>s</code> is an
+array then the indices output will be those where all elements
+in <code>.</code> match those of <code>s</code>.</p>
<div>
@@ -2645,8 +2600,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example40" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'indices(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a,b, cd, efg, hijk&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'indices(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a,b, cd, efg, hijk&#34;</td></tr>
<tr>
@@ -2693,14 +2648,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="index(s),rindex(s)">
<h3>
-
-<code>index(s)</code>, <code>rindex(s)</code>
-
+ <code>index(s)</code>, <code>rindex(s)</code>
</h3>
-
-<p>Outputs the index of the first (<code>index</code>) or last (<code>rindex</code>) occurrence of <code>s</code> in the input.</p>
-
+ <p>Outputs the index of the first (<code>index</code>) or last (<code>rindex</code>)
+occurrence of <code>s</code> in the input.</p>
<div>
@@ -2712,8 +2664,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example41" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'index(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a,b, cd, efg, hijk&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'index(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a,b, cd, efg, hijk&#34;</td></tr>
<tr>
@@ -2726,8 +2678,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'rindex(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a,b, cd, efg, hijk&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'rindex(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a,b, cd, efg, hijk&#34;</td></tr>
<tr>
@@ -2746,14 +2698,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="startswith">
<h3>
-
-<code>startswith</code>
-
+ <code>startswith</code>
</h3>
-
-<p>Outputs <code>true</code> if . starts with the given string argument.</p>
-
+ <p>Outputs <code>true</code> if . starts with the given string argument.</p>
<div>
@@ -2765,8 +2713,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example42" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|startswith(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;fo&quot;, &quot;foo&quot;, &quot;barfoo&quot;, &quot;foobar&quot;, &quot;barfoob&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|startswith(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;fo&#34;, &#34;foo&#34;, &#34;barfoo&#34;, &#34;foobar&#34;, &#34;barfoob&#34;]</td></tr>
<tr>
@@ -2785,14 +2733,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="endswith">
<h3>
-
-<code>endswith</code>
-
+ <code>endswith</code>
</h3>
-
-<p>Outputs <code>true</code> if . ends with the given string argument.</p>
-
+ <p>Outputs <code>true</code> if . ends with the given string argument.</p>
<div>
@@ -2804,8 +2748,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example43" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|endswith(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;barfoo&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|endswith(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;barfoo&#34;]</td></tr>
<tr>
@@ -2824,14 +2768,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="ltrimstr">
<h3>
-
-<code>ltrimstr</code>
-
+ <code>ltrimstr</code>
</h3>
-
-<p>Outputs its input with the given prefix string removed, if it starts with it.</p>
-
+ <p>Outputs its input with the given prefix string removed, if it
+starts with it.</p>
<div>
@@ -2843,15 +2784,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example44" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|ltrimstr(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;fo&quot;, &quot;foo&quot;, &quot;barfoo&quot;, &quot;foobar&quot;, &quot;afoo&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|ltrimstr(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;fo&#34;, &#34;foo&#34;, &#34;barfoo&#34;, &#34;foobar&#34;, &#34;afoo&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;fo&quot;,&quot;&quot;,&quot;barfoo&quot;,&quot;bar&quot;,&quot;afoo&quot;]</td>
+ <td>[&#34;fo&#34;,&#34;&#34;,&#34;barfoo&#34;,&#34;bar&#34;,&#34;afoo&#34;]</td>
</tr>
</table>
@@ -2863,14 +2804,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="rtrimstr">
<h3>
-
-<code>rtrimstr</code>
-
+ <code>rtrimstr</code>
</h3>
-
-<p>Outputs its input with the given suffix string removed, if it starts with it.</p>
-
+ <p>Outputs its input with the given suffix string removed, if it
+starts with it.</p>
<div>
@@ -2882,15 +2820,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example45" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|rtrimstr(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;fo&quot;, &quot;foo&quot;, &quot;barfoo&quot;, &quot;foobar&quot;, &quot;foob&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|rtrimstr(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;fo&#34;, &#34;foo&#34;, &#34;barfoo&#34;, &#34;foobar&#34;, &#34;foob&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;fo&quot;,&quot;&quot;,&quot;bar&quot;,&quot;foobar&quot;,&quot;foob&quot;]</td>
+ <td>[&#34;fo&#34;,&#34;&#34;,&#34;bar&#34;,&#34;foobar&#34;,&#34;foob&#34;]</td>
</tr>
</table>
@@ -2902,14 +2840,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="explode">
<h3>
-
-<code>explode</code>
-
+ <code>explode</code>
</h3>
-
-<p>Converts an input string into an array of the string’s codepoint numbers.</p>
-
+ <p>Converts an input string into an array of the string's
+codepoint numbers.</p>
<div>
@@ -2922,7 +2857,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'explode'</td></tr>
- <tr><th>Input</th><td>&quot;foobar&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;foobar&#34;</td></tr>
<tr>
@@ -2941,14 +2876,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="implode">
<h3>
-
-<code>implode</code>
-
+ <code>implode</code>
</h3>
-
-<p>The inverse of explode.</p>
-
+ <p>The inverse of explode.</p>
<div>
@@ -2968,7 +2899,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;ABC&quot;</td>
+ <td>&#34;ABC&#34;</td>
</tr>
</table>
@@ -2980,14 +2911,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="split">
<h3>
-
-<code>split</code>
-
+ <code>split</code>
</h3>
-
-<p>Splits an input string on the separator argument.</p>
-
+ <p>Splits an input string on the separator argument.</p>
<div>
@@ -2999,15 +2926,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example48" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'split(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a, b,c,d, e&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'split(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a, b,c,d, e&#34;</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;a&quot;,&quot;b,c,d&quot;,&quot;e&quot;]</td>
+ <td>[&#34;a&#34;,&#34;b,c,d&#34;,&#34;e&#34;]</td>
</tr>
</table>
@@ -3019,14 +2946,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="join">
<h3>
-
-<code>join</code>
-
+ <code>join</code>
</h3>
-
-<p>Joins the array of elements given as input, using the argument as separator. It is the inverse of <code>split</code>: that is, running <code>split(&quot;foo&quot;) | join(&quot;foo&quot;)</code> over any input string returns said input string.</p>
-
+ <p>Joins the array of elements given as input, using the
+argument as separator. It is the inverse of <code>split</code>: that is,
+running <code>split("foo") | join("foo")</code> over any input string
+returns said input string.</p>
<div>
@@ -3038,15 +2964,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example49" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'join(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b,c,d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'join(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b,c,d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;a, b,c,d, e&quot;</td>
+ <td>&#34;a, b,c,d, e&#34;</td>
</tr>
</table>
@@ -3058,26 +2984,26 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="recurse">
<h3>
-
-<code>recurse</code>
-
+ <code>recurse</code>
</h3>
-
-<p>The <code>recurse</code> function allows you to search through a recursive structure, and extract interesting data from all levels. Suppose your input represents a filesystem:</p>
-
-<pre><code>{&quot;name&quot;: &quot;/&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/bin&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/bin/ls&quot;, &quot;children&quot;: []},
- {&quot;name&quot;: &quot;/bin/sh&quot;, &quot;children&quot;: []}]},
- {&quot;name&quot;: &quot;/home&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/home/stephen&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/home/stephen/jq&quot;, &quot;children&quot;: []}]}]}]}</code></pre>
-
-<p>Now suppose you want to extract all of the filenames present. You need to retrieve <code>.name</code>, <code>.children[].name</code>, <code>.children[].children[].name</code>, and so on. You can do this with:</p>
-
-<pre><code>recurse(.children[]) | .name</code></pre>
-
+ <p>The <code>recurse</code> function allows you to search through a
+recursive structure, and extract interesting data from all
+levels. Suppose your input represents a filesystem:</p>
+<pre><code>{"name": "/", "children": [
+ {"name": "/bin", "children": [
+ {"name": "/bin/ls", "children": []},
+ {"name": "/bin/sh", "children": []}]},
+ {"name": "/home", "children": [
+ {"name": "/home/stephen", "children": [
+ {"name": "/home/stephen/jq", "children": []}]}]}]}
+</code></pre>
+<p>Now suppose you want to extract all of the filenames
+present. You need to retrieve <code>.name</code>, <code>.children[].name</code>,
+<code>.children[].children[].name</code>, and so on. You can do this
+with:</p>
+<pre><code>recurse(.children[]) | .name
+</code></pre>
<div>
@@ -3090,35 +3016,35 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'recurse(.foo[])'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;:[{&quot;foo&quot;: []}, {&quot;foo&quot;:[{&quot;foo&quot;:[]}]}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;:[{&#34;foo&#34;: []}, {&#34;foo&#34;:[{&#34;foo&#34;:[]}]}]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;:[{&quot;foo&quot;:[]},{&quot;foo&quot;:[{&quot;foo&quot;:[]}]}]}</td>
+ <td>{&#34;foo&#34;:[{&#34;foo&#34;:[]},{&#34;foo&#34;:[{&#34;foo&#34;:[]}]}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[]}</td>
+ <td>{&#34;foo&#34;:[]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[{&quot;foo&quot;:[]}]}</td>
+ <td>{&#34;foo&#34;:[{&#34;foo&#34;:[]}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[]}</td>
+ <td>{&#34;foo&#34;:[]}</td>
</tr>
</table>
@@ -3130,30 +3056,24 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="recurse_down">
<h3>
-
-<code>recurse_down</code>
-
+ <code>recurse_down</code>
</h3>
-
-<p>A quieter version of <code>recurse(.[])</code>, equivalent to:</p>
-
-<pre><code>def recurse_down: recurse(.[]?);</code></pre>
-
+ <p>A quieter version of <code>recurse(.[])</code>, equivalent to:</p>
+<pre><code>def recurse_down: recurse(.[]?);
+</code></pre>
</section>
<section id="..">
<h3>
-
-<code>..</code>
-
+ <code>..</code>
</h3>
-
-<p>Short-hand for <code>recurse_down</code>. This is intended to resemble the XPath <code>//</code> operator. Note that <code>..a</code> does not work; use <code>..|a</code> instead.</p>
-
+ <p>Short-hand for <code>recurse_down</code>. This is intended to resemble
+the XPath <code>//</code> operator. Note that <code>..a</code> does not work; use
+<code>..|a</code> instead.</p>
<div>
@@ -3166,7 +3086,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '..|.a?'</td></tr>
- <tr><th>Input</th><td>[[{&quot;a&quot;:1}]]</td></tr>
+ <tr><th>Input</th><td>[[{&#34;a&#34;:1}]]</td></tr>
<tr>
@@ -3185,14 +3105,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="Stringinterpolation-\(foo)">
<h3>
-
-String interpolation - <code>\(foo)</code>
-
+ String interpolation - <code>\(foo)</code>
</h3>
-
-<p>Inside a string, you can put an expression inside parens after a backslash. Whatever the expression returns will be interpolated into the string.</p>
-
+ <p>Inside a string, you can put an expression inside parens
+after a backslash. Whatever the expression returns will be
+interpolated into the string.</p>
<div>
@@ -3204,7 +3122,7 @@ String interpolation - <code>\(foo)</code>
<div id="example52" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '&quot;The input was \(.), which is one less than \(.+1)&quot;'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '&#34;The input was \(.), which is one less than \(.+1)&#34;'</td></tr>
<tr><th>Input</th><td>42</td></tr>
@@ -3212,7 +3130,7 @@ String interpolation - <code>\(foo)</code>
<th>Output</th>
- <td>&quot;The input was 42, which is one less than 43&quot;</td>
+ <td>&#34;The input was 42, which is one less than 43&#34;</td>
</tr>
</table>
@@ -3224,14 +3142,13 @@ String interpolation - <code>\(foo)</code>
<section id="Convertto/fromJSON">
<h3>
-
-Convert to/from JSON
-
+ Convert to/from JSON
</h3>
-
-<p>The <code>tojson</code> and <code>fromjson</code> 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.</p>
-
+ <p>The <code>tojson</code> and <code>fromjson</code> 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.</p>
<div>
@@ -3244,42 +3161,42 @@ Convert to/from JSON
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|tostring]'</td></tr>
- <tr><th>Input</th><td>[1, &quot;foo&quot;, [&quot;foo&quot;]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;foo&#34;, [&#34;foo&#34;]]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;1&quot;,&quot;foo&quot;,&quot;[\&quot;foo\&quot;]&quot;]</td>
+ <td>[&#34;1&#34;,&#34;foo&#34;,&#34;[\&#34;foo\&#34;]&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|tojson]'</td></tr>
- <tr><th>Input</th><td>[1, &quot;foo&quot;, [&quot;foo&quot;]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;foo&#34;, [&#34;foo&#34;]]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;1&quot;,&quot;\&quot;foo\&quot;&quot;,&quot;[\&quot;foo\&quot;]&quot;]</td>
+ <td>[&#34;1&#34;,&#34;\&#34;foo\&#34;&#34;,&#34;[\&#34;foo\&#34;]&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|tojson|fromjson]'</td></tr>
- <tr><th>Input</th><td>[1, &quot;foo&quot;, [&quot;foo&quot;]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;foo&#34;, [&#34;foo&#34;]]</td></tr>
<tr>
<th>Output</th>
- <td>[1,&quot;foo&quot;,[&quot;foo&quot;]]</td>
+ <td>[1,&#34;foo&#34;,[&#34;foo&#34;]]</td>
</tr>
</table>
@@ -3291,68 +3208,61 @@ Convert to/from JSON
<section id="Formatstringsandescaping">
<h3>
-
-Format strings and escaping
-
+ Format strings and escaping
</h3>
-
-<p>The <code>@foo</code> syntax is used to format and escape strings, which is useful for building URLs, documents in a language like HTML or XML, and so forth. <code>@foo</code> can be used as a filter on its own, the possible escapings are:</p>
-
+ <p>The <code>@foo</code> syntax is used to format and escape strings,
+which is useful for building URLs, documents in a language
+like HTML or XML, and so forth. <code>@foo</code> can be used as a
+filter on its own, the possible escapings are:</p>
<ul>
-<li>
-<p><code>@text</code>:</p>
-
+<li><code>@text</code>:</li>
+</ul>
<p>Calls <code>tostring</code>, see that function for details.</p>
-</li>
-
-<li>
-<p><code>@json</code>:</p>
-
+<ul>
+<li><code>@json</code>:</li>
+</ul>
<p>Serialises the input as JSON.</p>
-</li>
-
-<li>
-<p><code>@html</code>:</p>
-
-<p>Applies HTML/XML escaping, by mapping the characters <code>&lt;&gt;&amp;'&quot;</code> to their entity equivalents <code>&amp;lt;</code>, <code>&amp;gt;</code>, <code>&amp;amp;</code>, <code>&amp;apos;</code>, <code>&amp;quot;</code>.</p>
-</li>
-
-<li>
-<p><code>@uri</code>:</p>
-
-<p>Applies percent-encoding, by mapping all reserved URI characters to a <code>%xx</code> sequence.</p>
-</li>
-
-<li>
-<p><code>@csv</code>:</p>
-
-<p>The input must be an array, and it is rendered as CSV with double quotes for strings, and quotes escaped by repetition.</p>
-</li>
-
-<li>
-<p><code>@sh</code>:</p>
-
-<p>The input is escaped suitable for use in a command-line for a POSIX shell. If the input is an array, the output will be a series of space-separated strings.</p>
-</li>
-
-<li>
-<p><code>@base64</code>:</p>
-
-<p>The input is converted to base64 as specified by RFC 4648.</p>
-</li>
+<ul>
+<li><code>@html</code>:</li>
</ul>
-
-<p>This syntax can be combined with string interpolation in a useful way. You can follow a <code>@foo</code> token with a string literal. The contents of the string literal will <em>not</em> be escaped. However, all interpolations made inside that string literal will be escaped. For instance,</p>
-
-<pre><code>@uri &quot;https://www.google.com/search?q=\(.search)&quot;</code></pre>
-
-<p>will produce the following output for the input <code>{&quot;search&quot;:&quot;what is jq?&quot;}</code>:</p>
-
-<pre><code>&quot;https://www.google.com/search?q=what%20is%20jq%3f&quot;</code></pre>
-
-<p>Note that the slashes, question mark, etc. in the URL are not escaped, as they were part of the string literal.</p>
-
+<p>Applies HTML/XML escaping, by mapping the characters
+ <code>&lt;&gt;&amp;'"</code> to their entity equivalents <code>&amp;lt;</code>, <code>&amp;gt;</code>,
+ <code>&amp;amp;</code>, <code>&amp;apos;</code>, <code>&amp;quot;</code>.</p>
+<ul>
+<li><code>@uri</code>:</li>
+</ul>
+<p>Applies percent-encoding, by mapping all reserved URI
+ characters to a <code>%xx</code> sequence.</p>
+<ul>
+<li><code>@csv</code>:</li>
+</ul>
+<p>The input must be an array, and it is rendered as CSV
+ with double quotes for strings, and quotes escaped by
+ repetition.</p>
+<ul>
+<li><code>@sh</code>:</li>
+</ul>
+<p>The input is escaped suitable for use in a command-line
+ for a POSIX shell. If the input is an array, the output
+ will be a series of space-separated strings.</p>
+<ul>
+<li><code>@base64</code>:</li>
+</ul>
+<p>The input is converted to base64 as specified by RFC 4648.</p>
+<p>This syntax can be combined with string interpolation in a
+useful way. You can follow a <code>@foo</code> token with a string
+literal. The contents of the string literal will <em>not</em> be
+escaped. However, all interpolations made inside that string
+literal will be escaped. For instance,</p>
+<pre><code>@uri "https://www.google.com/search?q=\(.search)"
+</code></pre>
+<p>will produce the following output for the input
+<code>{"search":"what is jq?"}</code>:</p>
+<pre><code>"https://www.google.com/search?q=what%20is%20jq%3f"
+</code></pre>
+<p>Note that the slashes, question mark, etc. in the URL are
+not escaped, as they were part of the string literal.</p>
<div>
@@ -3365,28 +3275,28 @@ Format strings and escaping
<table>
<tr><th></th><td class="jqprogram">jq '@html'</td></tr>
- <tr><th>Input</th><td>&quot;This works if x &lt; y&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;This works if x &lt; y&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;This works if x &amp;lt; y&quot;</td>
+ <td>&#34;This works if x &amp;lt; y&#34;</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '@sh &quot;echo \(.)&quot;'</td></tr>
- <tr><th>Input</th><td>&quot;O'Hara's Ale&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq '@sh &#34;echo \(.)&#34;'</td></tr>
+ <tr><th>Input</th><td>&#34;O&#39;Hara&#39;s Ale&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;echo 'O'\\''Hara'\\''s Ale'&quot;</td>
+ <td>&#34;echo &#39;O&#39;\\&#39;&#39;Hara&#39;\\&#39;&#39;s Ale&#39;&#34;</td>
</tr>
</table>
@@ -3404,16 +3314,16 @@ Format strings and escaping
<section id="==,!=">
<h3>
-
-<code>==</code>, <code>!=</code>
-
+ <code>==</code>, <code>!=</code>
</h3>
-
-<p>The expression ‘a == b’ will produce ‘true’ if the result of a and b are equal (that is, if they represent equivalent JSON documents) and ‘false’ otherwise. In particular, strings are never considered equal to numbers. If you’re coming from Javascript, jq’s == is like Javascript’s === - considering values equal only when they have the same type as well as the same value.</p>
-
-<p>!= is “not equal”, and ‘a != b’ returns the opposite value of ‘a == b’</p>
-
+ <p>The expression 'a == b' will produce 'true' if the result of a and b
+are equal (that is, if they represent equivalent JSON documents) and
+'false' otherwise. In particular, strings are never considered equal
+to numbers. If you're coming from Javascript, jq's == is like
+Javascript's === - considering values equal only when they have the
+same type as well as the same value.</p>
+<p>!= is "not equal", and 'a != b' returns the opposite value of 'a == b'</p>
<div>
@@ -3426,7 +3336,7 @@ Format strings and escaping
<table>
<tr><th></th><td class="jqprogram">jq '.[] == 1'</td></tr>
- <tr><th>Input</th><td>[1, 1.0, &quot;1&quot;, &quot;banana&quot;]</td></tr>
+ <tr><th>Input</th><td>[1, 1.0, &#34;1&#34;, &#34;banana&#34;]</td></tr>
<tr>
@@ -3466,22 +3376,24 @@ Format strings and escaping
<section id="if-then-else">
<h3>
-
-if-then-else
-
+ if-then-else
</h3>
-
-<p><code>if A then B else C end</code> will act the same as <code>B</code> if <code>A</code> produces a value other than false or null, but act the same as <code>C</code> otherwise.</p>
-
-<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 <code>if .name then A else B end</code>, you’ll need something more like <code>if (.name | length) &gt; 0 then A else
+ <p><code>if A then B else C end</code> will act the same as <code>B</code> if <code>A</code>
+produces a value other than false or null, but act the same
+as <code>C</code> otherwise.</p>
+<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 <code>if .name then A else B end</code>, you'll
+need something more like <code>if (.name | length) &gt; 0 then A else
B end</code> instead.</p>
-
-<p>If the condition <code>A</code> produces multiple results, then <code>B</code> is evaluated once for each result that is not false or null, and <code>C</code> is evaluated once for each false or null.</p>
-
+<p>If the condition <code>A</code> produces multiple results, then <code>B</code> is evaluated
+once for each result that is not false or null, and <code>C</code> is evaluated
+once for each false or null.</p>
<p>More cases can be added to an if using <code>elif A then B</code> syntax.</p>
-
<div>
@@ -3493,11 +3405,11 @@ B end</code> instead.</p>
<table>
<tr><th></th><td class="jqprogram">jq 'if . == 0 then
- &quot;zero&quot;
+ &#34;zero&#34;
elif . == 1 then
- &quot;one&quot;
+ &#34;one&#34;
else
- &quot;many&quot;
+ &#34;many&#34;
end'</td></tr>
<tr><th>Input</th><td>2</td></tr>
@@ -3506,7 +3418,7 @@ end'</td></tr>
<th>Output</th>
- <td>&quot;many&quot;</td>
+ <td>&#34;many&#34;</td>
</tr>
</table>
@@ -3516,19 +3428,17 @@ end'</td></tr>
</section>
- <section id=">,>=,<=,<">
+ <section id="&gt;,&gt;=,&lt;=,&lt;">
<h3>
-
-<code>&gt;, &gt;=, &lt;=, &lt;</code>
-
+ <code>&gt;, &gt;=, &lt;=, &lt;</code>
</h3>
-
-<p>The comparison operators <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;=</code>, <code>&lt;</code> 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).</p>
-
+ <p>The comparison operators <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;=</code>, <code>&lt;</code> 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).</p>
<p>The ordering is the same as that described for <code>sort</code>, above.</p>
-
<div>
@@ -3559,21 +3469,24 @@ end'</td></tr>
<section id="and/or/not">
<h3>
-
-and/or/not
-
+ and/or/not
</h3>
-
-<p>jq supports the normal Boolean operators and/or/not. They have the same standard of truth as if expressions - false and null are considered “false values”, and anything else is a “true value”.</p>
-
-<p>If an operand of one of these operators produces multiple results, the operator itself will produce a result for each input.</p>
-
-<p><code>not</code> is in fact a builtin function rather than an operator, so it is called as a filter to which things can be piped rather than with special syntax, as in <code>.foo and .bar |
+ <p>jq supports the normal Boolean operators and/or/not. They have the
+same standard of truth as if expressions - false and null are
+considered "false values", and anything else is a "true value".</p>
+<p>If an operand of one of these operators produces multiple
+results, the operator itself will produce a result for each input.</p>
+<p><code>not</code> is in fact a builtin function rather than an operator,
+so it is called as a filter to which things can be piped
+rather than with special syntax, as in <code>.foo and .bar |
not</code>.</p>
-
-<p>These three only produce the values “true” and “false”, and so are only useful for genuine Boolean operations, rather than the common Perl/Python/Ruby idiom of “value_that_may_be_null or default”. If you want to use this form of “or”, picking between two values rather than evaluating a condition, see the “//” operator below.</p>
-
+<p>These three only produce the values "true" and "false", and
+so are only useful for genuine Boolean operations, rather
+than the common Perl/Python/Ruby idiom of
+"value_that_may_be_null or default". If you want to use this
+form of "or", picking between two values rather than
+evaluating a condition, see the "//" operator below.</p>
<div>
@@ -3585,7 +3498,7 @@ not</code>.</p>
<div id="example58" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '42 and &quot;a string&quot;'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '42 and &#34;a string&#34;'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -3675,16 +3588,17 @@ not</code>.</p>
<section id="Alternativeoperator-//">
<h3>
-
-Alternative operator - <code>//</code>
-
+ Alternative operator - <code>//</code>
</h3>
-
-<p>A filter of the form <code>a // b</code> produces the same results as <code>a</code>, if <code>a</code> produces results other than <code>false</code> and <code>null</code>. Otherwise, <code>a // b</code> produces the same results as <code>b</code>.</p>
-
-<p>This is useful for providing defaults: <code>.foo // 1</code> will evaluate to <code>1</code> if there’s no <code>.foo</code> element in the input. It’s similar to how <code>or</code> is sometimes used in Python (jq’s <code>or</code> operator is reserved for strictly Boolean operations).</p>
-
+ <p>A filter of the form <code>a // b</code> produces the same
+results as <code>a</code>, if <code>a</code> produces results other than <code>false</code>
+and <code>null</code>. Otherwise, <code>a // b</code> produces the same results as <code>b</code>.</p>
+<p>This is useful for providing defaults: <code>.foo // 1</code> will
+evaluate to <code>1</code> if there's no <code>.foo</code> element in the
+input. It's similar to how <code>or</code> is sometimes used in Python
+(jq's <code>or</code> operator is reserved for strictly Boolean
+operations).</p>
<div>
@@ -3697,7 +3611,7 @@ Alternative operator - <code>//</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo // 42'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 19}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 19}</td></tr>
<tr>
@@ -3732,62 +3646,77 @@ Alternative operator - <code>//</code>
<section id="Advancedfeatures">
<h2>Advanced features</h2>
-
-<p>Variables are an absolute necessity in most programming languages, but they’re relegated to an “advanced feature” in jq.</p>
-
-<p>In most languages, variables are the only means of passing around data. If you calculate a value, and you want to use it more than once, you’ll need to store it in a variable. To pass a value to another part of the program, you’ll need that part of the program to define a variable (as a function parameter, object member, or whatever) in which to place the data.</p>
-
-<p>It is also possible to define functions in jq, although this is is a feature whose biggest use is defining jq’s standard library (many jq functions such as <code>map</code> and <code>find</code> are in fact written in jq).</p>
-
-<p>Finally, jq has a <code>reduce</code> operation, which is very powerful but a bit tricky. Again, it’s mostly used internally, to define some useful bits of jq’s standard library.</p>
-
+ <p>Variables are an absolute necessity in most programming languages, but
+they're relegated to an "advanced feature" in jq.</p>
+<p>In most languages, variables are the only means of passing around
+data. If you calculate a value, and you want to use it more than once,
+you'll need to store it in a variable. To pass a value to another part
+of the program, you'll need that part of the program to define a
+variable (as a function parameter, object member, or whatever) in
+which to place the data.</p>
+<p>It is also possible to define functions in jq, although this is
+is a feature whose biggest use is defining jq's standard library
+(many jq functions such as <code>map</code> and <code>find</code> are in fact written
+in jq).</p>
+<p>Finally, jq has a <code>reduce</code> operation, which is very powerful but a
+bit tricky. Again, it's mostly used internally, to define some
+useful bits of jq's standard library.</p>
<section id="Variables">
<h3>
-
-Variables
-
+ Variables
</h3>
-
-<p>In jq, all filters have an input and an output, so manual plumbing is not necessary to pass a value from one part of a program to the next. Many expressions, for instance <code>a + b</code>, pass their input to two distinct subexpressions (here <code>a</code> and <code>b</code> are both passed the same input), so variables aren’t usually necessary in order to use a value twice.</p>
-
-<p>For instance, calculating the average value of an array of numbers requires a few variables in most languages - at least one to hold the array, perhaps one for each element or for a loop counter. In jq, it’s simply <code>add / length</code> - the <code>add</code> expression is given the array and produces its sum, and the <code>length</code> expression is given the array and produces its length.</p>
-
-<p>So, there’s generally a cleaner way to solve most problems in jq than defining variables. Still, sometimes they do make things easier, so jq lets you define variables using <code>expression as $variable</code>. All variable names start with <code>$</code>. Here’s a slightly uglier version of the array-averaging example:</p>
-
-<pre><code>length as $array_length | add / $array_length</code></pre>
-
-<p>We’ll need a more complicated problem to find a situation where using variables actually makes our lives easier.</p>
-
-<p>Suppose we have an array of blog posts, with “author” and “title” fields, and another object which is used to map author usernames to real names. Our input looks like:</p>
-
-<pre><code>{&quot;posts&quot;: [{&quot;title&quot;: &quot;Frist psot&quot;, &quot;author&quot;: &quot;anon&quot;},
- {&quot;title&quot;: &quot;A well-written article&quot;, &quot;author&quot;: &quot;person1&quot;}],
- &quot;realnames&quot;: {&quot;anon&quot;: &quot;Anonymous Coward&quot;,
- &quot;person1&quot;: &quot;Person McPherson&quot;}}</code></pre>
-
-<p>We want to produce the posts with the author field containing a real name, as in:</p>
-
-<pre><code>{&quot;title&quot;: &quot;Frist psot&quot;, &quot;author&quot;: &quot;Anonymous Coward&quot;}
-{&quot;title&quot;: &quot;A well-written article&quot;, &quot;author&quot;: &quot;Person McPherson&quot;}</code></pre>
-
-<p>We use a variable, $names, to store the realnames object, so that we can refer to it later when looking up author usernames:</p>
-
-<pre><code>.realnames as $names | .posts[] | {title, author: $names[.author]}</code></pre>
-
-<p>The expression <code>exp as $x | ...</code> means: for each value of expression <code>exp</code>, run the rest of the pipeline with the entire original input, and with <code>$x</code> set to that value. Thus <code>as</code> functions as something of a foreach loop.</p>
-
-<p>Variables are scoped over the rest of the expression that defines them, so</p>
-
-<pre><code>.realnames as $names | (.posts[] | {title, author: $names[.author]})</code></pre>
-
+ <p>In jq, all filters have an input and an output, so manual
+plumbing is not necessary to pass a value from one part of a program
+to the next. Many expressions, for instance <code>a + b</code>, pass their input
+to two distinct subexpressions (here <code>a</code> and <code>b</code> are both passed the
+same input), so variables aren't usually necessary in order to use a
+value twice.</p>
+<p>For instance, calculating the average value of an array of numbers
+requires a few variables in most languages - at least one to hold the
+array, perhaps one for each element or for a loop counter. In jq, it's
+simply <code>add / length</code> - the <code>add</code> expression is given the array and
+produces its sum, and the <code>length</code> expression is given the array and
+produces its length.</p>
+<p>So, there's generally a cleaner way to solve most problems in jq than
+defining variables. Still, sometimes they do make things easier, so jq
+lets you define variables using <code>expression as $variable</code>. All
+variable names start with <code>$</code>. Here's a slightly uglier version of the
+array-averaging example:</p>
+<pre><code>length as $array_length | add / $array_length
+</code></pre>
+<p>We'll need a more complicated problem to find a situation where using
+variables actually makes our lives easier.</p>
+<p>Suppose we have an array of blog posts, with "author" and "title"
+fields, and another object which is used to map author usernames to
+real names. Our input looks like:</p>
+<pre><code>{"posts": [{"title": "Frist psot", "author": "anon"},
+ {"title": "A well-written article", "author": "person1"}],
+ "realnames": {"anon": "Anonymous Coward",
+ "person1": "Person McPherson"}}
+</code></pre>
+<p>We want to produce the posts with the author field containing a real
+name, as in:</p>
+<pre><code>{"title": "Frist psot", "author": "Anonymous Coward"}
+{"title": "A well-written article", "author": "Person McPherson"}
+</code></pre>
+<p>We use a variable, $names, to store the realnames object, so that we
+can refer to it later when looking up author usernames:</p>
+<pre><code>.realnames as $names | .posts[] | {title, author: $names[.author]}
+</code></pre>
+<p>The expression <code>exp as $x | ...</code> means: for each value of expression
+<code>exp</code>, run the rest of the pipeline with the entire original input, and
+with <code>$x</code> set to that value. Thus <code>as</code> functions as something of a
+foreach loop.</p>
+<p>Variables are scoped over the rest of the expression that defines
+them, so</p>
+<pre><code>.realnames as $names | (.posts[] | {title, author: $names[.author]})
+</code></pre>
<p>will work, but</p>
-
-<pre><code>(.realnames as $names | .posts[]) | {title, author: $names[.author]}</code></pre>
-
-<p>won’t.</p>
-
+<pre><code>(.realnames as $names | .posts[]) | {title, author: $names[.author]}
+</code></pre>
+<p>won't.</p>
<div>
@@ -3800,7 +3729,7 @@ Variables
<table>
<tr><th></th><td class="jqprogram">jq '.bar as $x | .foo | . + $x'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;:10, &quot;bar&quot;:200}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;:10, &#34;bar&#34;:200}</td></tr>
<tr>
@@ -3819,28 +3748,28 @@ Variables
<section id="DefiningFunctions">
<h3>
-
-Defining Functions
-
+ Defining Functions
</h3>
-
-<p>You can give a filter a name using “def” syntax:</p>
-
-<pre><code>def increment: . + 1;</code></pre>
-
-<p>From then on, <code>increment</code> is usable as a filter just like a builtin function (in fact, this is how some of the builtins are defined). A function may take arguments:</p>
-
-<pre><code>def map(f): [.[] | f];</code></pre>
-
-<p>Arguments are passed as filters, not as values. The same argument may be referenced multiple times with different inputs (here <code>f</code> is run for each element of the input array). Arguments to a function work more like callbacks than like value arguments.</p>
-
-<p>If you want the value-argument behaviour for defining simple functions, you can just use a variable:</p>
-
-<pre><code>def addvalue(f): f as $value | map(. + $value);</code></pre>
-
-<p>With that definition, <code>addvalue(.foo)</code> will add the current input’s <code>.foo</code> field to each element of the array.</p>
-
+ <p>You can give a filter a name using "def" syntax:</p>
+<pre><code>def increment: . + 1;
+</code></pre>
+<p>From then on, <code>increment</code> is usable as a filter just like a
+builtin function (in fact, this is how some of the builtins
+are defined). A function may take arguments:</p>
+<pre><code>def map(f): [.[] | f];
+</code></pre>
+<p>Arguments are passed as filters, not as values. The
+same argument may be referenced multiple times with
+different inputs (here <code>f</code> is run for each element of the
+input array). Arguments to a function work more like
+callbacks than like value arguments.</p>
+<p>If you want the value-argument behaviour for defining simple
+functions, you can just use a variable:</p>
+<pre><code>def addvalue(f): f as $value | map(. + $value);
+</code></pre>
+<p>With that definition, <code>addvalue(.foo)</code> will add the current
+input's <code>.foo</code> field to each element of the array.</p>
<div>
@@ -3886,22 +3815,22 @@ Defining Functions
<section id="Reduce">
<h3>
-
-Reduce
-
+ Reduce
</h3>
-
-<p>The <code>reduce</code> syntax in jq allows you to combine all of the results of an expression by accumulating them into a single answer. As an example, we’ll pass <code>[3,2,1]</code> to this expression:</p>
-
-<pre><code>reduce .[] as $item (0; . + $item)</code></pre>
-
-<p>For each result that <code>.[]</code> produces, <code>. + $item</code> is run to accumulate a running total, starting from 0. In this example, <code>.[]</code> produces the results 3, 2, and 1, so the effect is similar to running something like this:</p>
-
+ <p>The <code>reduce</code> syntax in jq allows you to combine all of the
+results of an expression by accumulating them into a single
+answer. As an example, we'll pass <code>[3,2,1]</code> to this expression:</p>
+<pre><code>reduce .[] as $item (0; . + $item)
+</code></pre>
+<p>For each result that <code>.[]</code> produces, <code>. + $item</code> is run to
+accumulate a running total, starting from 0. In this
+example, <code>.[]</code> produces the results 3, 2, and 1, so the
+effect is similar to running something like this:</p>
<pre><code>0 | (3 as $item | . + $item) |
(2 as $item | . + $item) |
- (1 as $item | . + $item)</code></pre>
-
+ (1 as $item | . + $item)
+</code></pre>
<div>
@@ -3935,64 +3864,73 @@ Reduce
<section id="Assignment">
<h2>Assignment</h2>
-
-<p>Assignment works a little differently in jq than in most programming languages. jq doesn’t distinguish between references to and copies of something - two objects or arrays are either equal or not equal, without any further notion of being “the same object” or “not the same object”.</p>
-
-<p>If an object has two fields which are arrays, <code>.foo</code> and <code>.bar</code>, and you append something to <code>.foo</code>, then <code>.bar</code> will not get bigger. Even if you’ve just set <code>.bar = .foo</code>. If you’re used to programming in languages like Python, Java, Ruby, Javascript, etc. then you can think of it as though jq does a full deep copy of every object before it does the assignment (for performance, it doesn’t actually do that, but that’s the general idea).</p>
-
+ <p>Assignment works a little differently in jq than in most
+programming languages. jq doesn't distinguish between references
+to and copies of something - two objects or arrays are either
+equal or not equal, without any further notion of being "the
+same object" or "not the same object".</p>
+<p>If an object has two fields which are arrays, <code>.foo</code> and <code>.bar</code>,
+and you append something to <code>.foo</code>, then <code>.bar</code> will not get
+bigger. Even if you've just set <code>.bar = .foo</code>. If you're used to
+programming in languages like Python, Java, Ruby, Javascript,
+etc. then you can think of it as though jq does a full deep copy
+of every object before it does the assignment (for performance,
+it doesn't actually do that, but that's the general idea).</p>
<section id="=">
<h3>
-
-<code>=</code>
-
+ <code>=</code>
</h3>
-
-<p>The filter <code>.foo = 1</code> will take as input an object and produce as output an object with the “foo” field set to 1. There is no notion of “modifying” or “changing” something in jq - all jq values are immutable. For instance,</p>
-
+ <p>The filter <code>.foo = 1</code> will take as input an object
+and produce as output an object with the "foo" field set to
+1. There is no notion of "modifying" or "changing" something
+in jq - all jq values are immutable. For instance,</p>
<p>.foo = .bar | .foo.baz = 1</p>
-
-<p>will not have the side-effect of setting .bar.baz to be set to 1, as the similar-looking program in Javascript, Python, Ruby or other languages would. Unlike these languages (but like Haskell and some other functional languages), there is no notion of two arrays or objects being “the same array” or “the same object”. They can be equal, or not equal, but if we change one of them in no circumstances will the other change behind our backs.</p>
-
-<p>This means that it’s impossible to build circular values in jq (such as an array whose first element is itself). This is quite intentional, and ensures that anything a jq program can produce can be represented in JSON.</p>
-
+<p>will not have the side-effect of setting .bar.baz to be set
+to 1, as the similar-looking program in Javascript, Python,
+Ruby or other languages would. Unlike these languages (but
+like Haskell and some other functional languages), there is
+no notion of two arrays or objects being "the same array" or
+"the same object". They can be equal, or not equal, but if
+we change one of them in no circumstances will the other
+change behind our backs.</p>
+<p>This means that it's impossible to build circular values in
+jq (such as an array whose first element is itself). This is
+quite intentional, and ensures that anything a jq program
+can produce can be represented in JSON.</p>
</section>
<section id="|=">
<h3>
-
-<code>|=</code>
-
+ <code>|=</code>
</h3>
-
-<p>As well as the assignment operator ‘=’, jq provides the “update” operator ‘|=’, which takes a filter on the right-hand side and works out the new value for the property being assigned to by running the old value through this expression. For instance, .foo |= .+1 will build an object with the “foo” field set to the input’s “foo” plus 1.</p>
-
-<p>This example should show the difference between ‘=’ and ‘|=’:</p>
-
-<p>Provide input ‘{“a”: {“b”: 10}, “b”: 20}’ to the programs:</p>
-
-<p>.a = .b .a |= .b</p>
-
-<p>The former will set the “a” field of the input to the “b” field of the input, and produce the output {“a”: 20}. The latter will set the “a” field of the input to the “a” field’s “b” field, producing {“a”: 10}.</p>
-
+ <p>As well as the assignment operator '=', jq provides the "update"
+operator '|=', which takes a filter on the right-hand side and
+works out the new value for the property being assigned to by running
+the old value through this expression. For instance, .foo |= .+1 will
+build an object with the "foo" field set to the input's "foo" plus 1.</p>
+<p>This example should show the difference between '=' and '|=':</p>
+<p>Provide input '{"a": {"b": 10}, "b": 20}' to the programs:</p>
+<p>.a = .b
+.a |= .b</p>
+<p>The former will set the "a" field of the input to the "b" field of the
+input, and produce the output {"a": 20}. The latter will set the "a"
+field of the input to the "a" field's "b" field, producing {"a": 10}.</p>
</section>
<section id="+=,-=,*=,/=,%=,//=">
<h3>
-
-<code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>, <code>%=</code>, <code>//=</code>
-
+ <code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>, <code>%=</code>, <code>//=</code>
</h3>
-
-<p>jq has a few operators of the form <code>a op= b</code>, which are all equivalent to <code>a |= . op b</code>. So, <code>+= 1</code> can be used to increment values.</p>
-
+ <p>jq has a few operators of the form <code>a op= b</code>, which are all
+equivalent to <code>a |= . op b</code>. So, <code>+= 1</code> can be used to increment values.</p>
<div>
@@ -4005,14 +3943,14 @@ Reduce
<table>
<tr><th></th><td class="jqprogram">jq '.foo += 1'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;: 43}</td>
+ <td>{&#34;foo&#34;: 43}</td>
</tr>
</table>
@@ -4024,33 +3962,41 @@ Reduce
<section id="Complexassignments">
<h3>
-
-Complex assignments
-
+ Complex assignments
</h3>
-
-<p>Lots more things are allowed on the left-hand side of a jq assignment than in most langauges. We’ve already seen simple field accesses on the left hand side, and it’s no surprise that array accesses work just as well:</p>
-
-<pre><code>.posts[0].title = &quot;JQ Manual&quot;</code></pre>
-
-<p>What may come as a surprise is that the expression on the left may produce multiple results, referring to different points in the input document:</p>
-
-<pre><code>.posts[].comments |= . + [&quot;this is great&quot;]</code></pre>
-
-<p>That example appends the string “this is great” to the “comments” array of each post in the input (where the input is an object with a field “posts” which is an array of posts).</p>
-
-<p>When jq encounters an assignment like ‘a = b’, it records the “path” taken to select a part of the input document while executing a. This path is then used to find which part of the input to change while executing the assignment. Any filter may be used on the left-hand side of an equals - whichever paths it selects from the input will be where the assignment is performed.</p>
-
-<p>This is a very powerful operation. Suppose we wanted to add a comment to blog posts, using the same “blog” input above. This time, we only want to comment on the posts written by “stedolan”. We can find those posts using the “select” function described earlier:</p>
-
-<pre><code>.posts[] | select(.author == &quot;stedolan&quot;)</code></pre>
-
-<p>The paths provided by this operation point to each of the posts that “stedolan” wrote, and we can comment on each of them in the same way that we did before:</p>
-
-<pre><code>(.posts[] | select(.author == &quot;stedolan&quot;) | .comments) |=
- . + [&quot;terrible.&quot;]</code></pre>
-
+ <p>Lots more things are allowed on the left-hand side of a jq assignment
+than in most languages. We've already seen simple field accesses on
+the left hand side, and it's no surprise that array accesses work just
+as well:</p>
+<pre><code>.posts[0].title = "JQ Manual"
+</code></pre>
+<p>What may come as a surprise is that the expression on the left may
+produce multiple results, referring to different points in the input
+document:</p>
+<pre><code>.posts[].comments |= . + ["this is great"]
+</code></pre>
+<p>That example appends the string "this is great" to the "comments"
+array of each post in the input (where the input is an object with a
+field "posts" which is an array of posts).</p>
+<p>When jq encounters an assignment like 'a = b', it records the "path"
+taken to select a part of the input document while executing a. This
+path is then used to find which part of the input to change while
+executing the assignment. Any filter may be used on the
+left-hand side of an equals - whichever paths it selects from the
+input will be where the assignment is performed.</p>
+<p>This is a very powerful operation. Suppose we wanted to add a comment
+to blog posts, using the same "blog" input above. This time, we only
+want to comment on the posts written by "stedolan". We can find those
+posts using the "select" function described earlier:</p>
+<pre><code>.posts[] | select(.author == "stedolan")
+</code></pre>
+<p>The paths provided by this operation point to each of the posts that
+"stedolan" wrote, and we can comment on each of them in the same way
+that we did before:</p>
+<pre><code>(.posts[] | select(.author == "stedolan") | .comments) |=
+ . + ["terrible."]
+</code></pre>
</section>
@@ -4063,7 +4009,7 @@ Complex assignments
<footer>
<div class="container">
- <p>This website is made with <a href="http://www.tinytree.info">Bonsai</a> and <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
+ <p>This website is made with <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
<p>jq is licensed under the MIT license (code) and the <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a> license (docs).</p>
</div>
</footer>
@@ -4071,7 +4017,6 @@ Complex assignments
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<script src="https://twitter.github.io/typeahead.js/releases/0.11.1/typeahead.bundle.js"></script>
-
<script>
var section_map = {
@@ -4086,7 +4031,7 @@ Complex assignments
".foo?" : ".foo?",
- ".[<string>], .[2], .[10:15]" : ".[<string>],.[2],.[10:15]",
+ ".[\u003cstring\u003e], .[2], .[10:15]" : ".[\u003cstring\u003e],.[2],.[10:15]",
".[]" : ".[]",
@@ -4208,7 +4153,7 @@ Complex assignments
"if-then-else" : "if-then-else",
- ">, >=, <=, <" : ">,>=,<=,<",
+ "\u003e, \u003e=, \u003c=, \u003c" : "\u003e,\u003e=,\u003c=,\u003c",
"and/or/not" : "and/or/not",
@@ -4243,4 +4188,4 @@ Complex assignments
</script>
<script src="/jq/js/manual-search.js"></script>
</body>
-</html>
+</html> \ No newline at end of file
diff --git a/manual/v1.5/index.html b/manual/v1.5/index.html
index 20606bb..7f61582 100644
--- a/manual/v1.5/index.html
+++ b/manual/v1.5/index.html
@@ -18,7 +18,6 @@
<![endif]-->
</head>
-
<body id="v1.5" data-spy="scroll" data-target="#navcolumn" data-offset="100">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
@@ -56,7 +55,6 @@
</div>
</div>
-
<div class="container">
<div class="row">
<div class="affix" id="navcolumn">
@@ -124,182 +122,203 @@
<div id="manualcontent">
<h1>jq 1.5 Manual</h1>
<p><em>The manual for the development version of jq can be found
-<a href='/jq/manual'>here</a>.</em></p>
- <p>A jq program is a &ldquo;filter&rdquo;: it takes an input, and produces an
+<a href="/jq/manual">here</a>.</em></p>
+ <p>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.</p><p>Filters can be combined in various ways - you can pipe the output of
+or various other standard tasks.</p>
+<p>Filters can be combined in various ways - you can pipe the output of
one filter into another filter, or collect the output of a filter
-into an array.</p><p>Some filters produce multiple results, for instance there&rsquo;s one that
+into an array.</p>
+<p>Some filters produce multiple results, for instance there's one that
produces all the elements of its input array. Piping that filter
into a second runs the second filter for each element of the
array. Generally, things that would be done with loops and iteration
-in other languages are just done by gluing filters together in jq.</p><p>It&rsquo;s important to remember that every filter has an input and an
-output. Even literals like &ldquo;hello&rdquo; or 42 are filters - they take an
+in other languages are just done by gluing filters together in jq.</p>
+<p>It's important to remember that every filter has an input and an
+output. Even literals like "hello" or 42 are filters - they take an
input but always produce the same literal as output. Operations that
combine two filters, like addition, generally feed the same input to
both and combine the results. So, you can implement an averaging
filter as <code>add / length</code> - feeding the input array both to the <code>add</code>
-filter and the <code>length</code> filter and then performing the division.</p><p>But that&rsquo;s getting ahead of ourselves. :) Let&rsquo;s start with something
+filter and the <code>length</code> filter and then performing the division.</p>
+<p>But that's getting ahead of ourselves. :) Let's start with something
simpler:</p>
<section id="Invokingjq">
<h2>Invoking jq</h2>
-
-<p>jq filters run on a stream of JSON data. The input to jq is parsed as a sequence of whitespace-separated JSON values which are passed through the provided filter one at a time. The output(s) of the filter are written to standard out, again as a sequence of whitespace-separated JSON data.</p>
-
-<p>Note: it is important to mind the shell’s quoting rules. As a general rule it’s best to always quote (with single-quote characters) the jq program, as too many characters with special meaning to jq are also shell meta-characters. For example, <code>jq
-&quot;foo&quot;</code> will fail on most Unix shells because that will be the same as <code>jq foo</code>, which will generally fail because <code>foo is not
-defined</code>. When using the Windows command shell (cmd.exe) it’s best to use double quotes around your jq program when given on the command-line (instead of the <code>-f program-file</code> option), but then double-quotes in the jq program need backslash escaping.</p>
-
-<p>You can affect how jq reads and writes its input and output using some command-line options:</p>
-
+ <p>jq filters run on a stream of JSON data. The input to jq is
+parsed as a sequence of whitespace-separated JSON values which
+are passed through the provided filter one at a time. The
+output(s) of the filter are written to standard out, again as a
+sequence of whitespace-separated JSON data.</p>
+<p>Note: it is important to mind the shell's quoting rules. As a
+general rule it's best to always quote (with single-quote
+characters) the jq program, as too many characters with special
+meaning to jq are also shell meta-characters. For example, <code>jq
+"foo"</code> will fail on most Unix shells because that will be the same
+as <code>jq foo</code>, which will generally fail because <code>foo is not
+defined</code>. When using the Windows command shell (cmd.exe) it's
+best to use double quotes around your jq program when given on the
+command-line (instead of the <code>-f program-file</code> option), but then
+double-quotes in the jq program need backslash escaping.</p>
+<p>You can affect how jq reads and writes its input and output
+using some command-line options:</p>
<ul>
-<li>
-<p><code>--version</code>:</p>
-
+<li><code>--version</code>:</li>
+</ul>
<p>Output the jq version and exit with zero.</p>
-</li>
-
-<li>
-<p><code>--seq</code>:</p>
-
-<p>Use the <code>application/json-seq</code> 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 more also parses the output of jq without the <code>--seq</code> option.</p>
-</li>
-
-<li>
-<p><code>--stream</code>:</p>
-
-<p>Parse the input in streaming fashion, outputing arrays of path and leaf values (scalars and empty arrays or empty objects). For example, <code>&quot;a&quot;</code> becomes <code>[[],&quot;a&quot;]</code>, and <code>[[],&quot;a&quot;,[&quot;b&quot;]]</code> becomes <code>[[0],[]]</code>, <code>[[1],&quot;a&quot;]</code>, and <code>[[1,0],&quot;b&quot;]</code>.</p>
-
-<p>This is useful for processing very large inputs. Use this in conjunction with filtering and the <code>reduce</code> and <code>foreach</code> syntax to reduce large inputs incrementally.</p>
-</li>
-
-<li>
-<p><code>--slurp</code>/<code>-s</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--raw-input</code>/<code>-R</code>:</p>
-
-<p>Don’t parse the input as JSON. Instead, each line of text is passed to the filter as a string. If combined with <code>--slurp</code>, then the entire input is passed to the filter as a single long string.</p>
-</li>
-
-<li>
-<p><code>--null-input</code>/<code>-n</code>:</p>
-
-<p>Don’t read any input at all! Instead, the filter is run once using <code>null</code> as the input. This is useful when using jq as a simple calculator or to construct JSON data from scratch.</p>
-</li>
-
-<li>
-<p><code>--compact-output</code> / <code>-c</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--tab</code>:</p>
-
+<ul>
+<li><code>--seq</code>:</li>
+</ul>
+<p>Use the <code>application/json-seq</code> 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 more also parses the output of jq without the <code>--seq</code>
+ option.</p>
+<ul>
+<li><code>--stream</code>:</li>
+</ul>
+<p>Parse the input in streaming fashion, outputting arrays of path
+ and leaf values (scalars and empty arrays or empty objects).
+ For example, <code>"a"</code> becomes <code>[[],"a"]</code>, and <code>[[],"a",["b"]]</code>
+ becomes <code>[[0],[]]</code>, <code>[[1],"a"]</code>, and <code>[[1,0],"b"]</code>.</p>
+<p>This is useful for processing very large inputs. Use this in
+ conjunction with filtering and the <code>reduce</code> and <code>foreach</code> syntax
+ to reduce large inputs incrementally.</p>
+<ul>
+<li><code>--slurp</code>/<code>-s</code>:</li>
+</ul>
+<p>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.</p>
+<ul>
+<li><code>--raw-input</code>/<code>-R</code>:</li>
+</ul>
+<p>Don't parse the input as JSON. Instead, each line of text is
+ passed to the filter as a string. If combined with <code>--slurp</code>,
+ then the entire input is passed to the filter as a single long
+ string.</p>
+<ul>
+<li><code>--null-input</code>/<code>-n</code>:</li>
+</ul>
+<p>Don't read any input at all! Instead, the filter is run once
+ using <code>null</code> as the input. This is useful when using jq as a
+ simple calculator or to construct JSON data from scratch.</p>
+<ul>
+<li><code>--compact-output</code> / <code>-c</code>:</li>
+</ul>
+<p>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.</p>
+<ul>
+<li><code>--tab</code>:</li>
+</ul>
<p>Use a tab for each indentation level instead of two spaces.</p>
-</li>
-
-<li>
-<p><code>--indent n</code>:</p>
-
-<p>Use the given number of spaces (no more than 8) for indentation.</p>
-</li>
-
-<li>
-<p><code>--color-output</code> / <code>-C</code> and <code>--monochrome-output</code> / <code>-M</code>:</p>
-
-<p>By default, jq outputs colored JSON if writing to a terminal. You can force it to produce color even if writing to a pipe or a file using <code>-C</code>, and disable color with <code>-M</code>.</p>
-</li>
-
-<li>
-<p><code>--ascii-output</code> / <code>-a</code>:</p>
-
-<p>jq usually outputs non-ASCII Unicode codepoints as UTF-8, even if the input specified them as escape sequences (like “\u03bc”). Using this option, you can force jq to produce pure ASCII output with every non-ASCII character replaced with the equivalent escape sequence.</p>
-</li>
-
-<li>
-<p><code>--unbuffered</code></p>
-
-<p>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).</p>
-</li>
-
-<li>
-<p><code>--sort-keys</code> / <code>-S</code>:</p>
-
+<ul>
+<li><code>--indent n</code>:</li>
+</ul>
+<p>Use the given number of spaces (no more than 7) for indentation.</p>
+<ul>
+<li><code>--color-output</code> / <code>-C</code> and <code>--monochrome-output</code> / <code>-M</code>:</li>
+</ul>
+<p>By default, jq outputs colored JSON if writing to a
+ terminal. You can force it to produce color even if writing to
+ a pipe or a file using <code>-C</code>, and disable color with <code>-M</code>.</p>
+<ul>
+<li><code>--ascii-output</code> / <code>-a</code>:</li>
+</ul>
+<p>jq usually outputs non-ASCII Unicode codepoints as UTF-8, even
+ if the input specified them as escape sequences (like
+ "\u03bc"). Using this option, you can force jq to produce pure
+ ASCII output with every non-ASCII character replaced with the
+ equivalent escape sequence.</p>
+<ul>
+<li><code>--unbuffered</code></li>
+</ul>
+<p>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).</p>
+<ul>
+<li><code>--sort-keys</code> / <code>-S</code>:</li>
+</ul>
<p>Output the fields of each object with the keys in sorted order.</p>
-</li>
-
-<li>
-<p><code>--raw-output</code> / <code>-r</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--join-output</code> / <code>-j</code>:</p>
-
-<p>Like <code>-r</code> but jq won’t print a newline after each output.</p>
-</li>
-
-<li>
-<p><code>-f filename</code> / <code>--from-file filename</code>:</p>
-
-<p>Read filter from the file rather than from a command line, like awk’s -f option. You can also use ‘#’ to make comments.</p>
-</li>
-
-<li>
-<p><code>-Ldirectory</code> / <code>-L directory</code>:</p>
-
-<p>Prepend <code>directory</code> to the search list for modules. If this option is used then no builtin search list is used. See the section on modules below.</p>
-</li>
-
-<li>
-<p><code>-e</code> / <code>--exit-status</code>:</p>
-
-<p>Sets the exit status of jq to 0 if the last output values was neither <code>false</code> nor <code>null</code>, 1 if the last output value was either <code>false</code> or <code>null</code>, or 4 if no valid result was ever produced. Normally jq exits with 2 if there was any usage problem or system error, 3 if there was a jq program compile error, or 0 if the jq program ran.</p>
-</li>
-
-<li>
-<p><code>--arg name value</code>:</p>
-
-<p>This option passes a value to the jq program as a predefined variable. If you run jq with <code>--arg foo bar</code>, then <code>$foo</code> is available in the program and has the value <code>&quot;bar&quot;</code>. Note that <code>value</code> will be treated as a string, so <code>--arg foo 123</code> will bind <code>$foo</code> to <code>&quot;123&quot;</code>.</p>
-</li>
-
-<li>
-<p><code>--argjson name JSON-text</code>:</p>
-
-<p>This option passes a JSON-encoded value to the jq program as a predefined variable. If you run jq with <code>--argjson foo 123</code>, then <code>$foo</code> is available in the program and has the value <code>123</code>.</p>
-</li>
-
-<li>
-<p><code>--slurpfile variable-name filename</code>:</p>
-
-<p>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 <code>--argfile foo bar</code>, then <code>$foo</code> is available in the program and has an array whose elements correspond to the texts in the file named <code>bar</code>.</p>
-</li>
-
-<li>
-<p><code>--argfile variable-name filename</code>:</p>
-
-<p>Do not use. Use <code>--slurpfile</code> instead.</p>
-
-<p>(This option is like <code>--slurpfile</code>, but when the file has just one text, then that is used, else an array of texts is used as in <code>--slurpfile</code>.)</p>
-</li>
-
-<li>
-<p><code>--run-tests [filename]</code>:</p>
-
-<p>Runs the tests in the given file or standard input. This must be the last option given and does not honor all preceding options. The input consists of comment lines, empty lines, and program lines followed by one input line, as many lines of output as are expected (one per output), and a terminating empty line. Compilation failure tests start with a line containing only “%%FAIL”, then a line containing the program to compile, then a line containing an error message to compare to the actual.</p>
-
-<p>Be warned that this option can change backwards-incompatibly.</p>
-</li>
+<ul>
+<li><code>--raw-output</code> / <code>-r</code>:</li>
</ul>
-
+<p>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.</p>
+<ul>
+<li><code>--join-output</code> / <code>-j</code>:</li>
+</ul>
+<p>Like <code>-r</code> but jq won't print a newline after each output.</p>
+<ul>
+<li><code>-f filename</code> / <code>--from-file filename</code>:</li>
+</ul>
+<p>Read filter from the file rather than from a command line, like
+ awk's -f option. You can also use '#' to make comments.</p>
+<ul>
+<li><code>-Ldirectory</code> / <code>-L directory</code>:</li>
+</ul>
+<p>Prepend <code>directory</code> to the search list for modules. If this
+ option is used then no builtin search list is used. See the
+ section on modules below.</p>
+<ul>
+<li><code>-e</code> / <code>--exit-status</code>:</li>
+</ul>
+<p>Sets the exit status of jq to 0 if the last output values was
+ neither <code>false</code> nor <code>null</code>, 1 if the last output value was
+ either <code>false</code> or <code>null</code>, or 4 if no valid result was ever
+ produced. Normally jq exits with 2 if there was any usage
+ problem or system error, 3 if there was a jq program compile
+ error, or 0 if the jq program ran.</p>
+<ul>
+<li><code>--arg name value</code>:</li>
+</ul>
+<p>This option passes a value to the jq program as a predefined
+ variable. If you run jq with <code>--arg foo bar</code>, then <code>$foo</code> is
+ available in the program and has the value <code>"bar"</code>. Note that
+ <code>value</code> will be treated as a string, so <code>--arg foo 123</code> will
+ bind <code>$foo</code> to <code>"123"</code>.</p>
+<ul>
+<li><code>--argjson name JSON-text</code>:</li>
+</ul>
+<p>This option passes a JSON-encoded value to the jq program as a
+ predefined variable. If you run jq with <code>--argjson foo 123</code>, then
+ <code>$foo</code> is available in the program and has the value <code>123</code>.</p>
+<ul>
+<li><code>--slurpfile variable-name filename</code>:</li>
+</ul>
+<p>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 <code>--argfile foo bar</code>, then <code>$foo</code> is available
+ in the program and has an array whose elements correspond to the
+ texts in the file named <code>bar</code>.</p>
+<ul>
+<li><code>--argfile variable-name filename</code>:</li>
+</ul>
+<p>Do not use. Use <code>--slurpfile</code> instead.</p>
+<p>(This option is like <code>--slurpfile</code>, but when the file has just
+ one text, then that is used, else an array of texts is used as
+ in <code>--slurpfile</code>.)</p>
+<ul>
+<li><code>--run-tests [filename]</code>:</li>
+</ul>
+<p>Runs the tests in the given file or standard input. This must
+ be the last option given and does not honor all preceding
+ options. The input consists of comment lines, empty lines, and
+ program lines followed by one input line, as many lines of
+ output as are expected (one per output), and a terminating empty
+ line. Compilation failure tests start with a line containing
+ only "%%FAIL", then a line containing the program to compile,
+ then a line containing an error message to compare to the
+ actual.</p>
+<p>Be warned that this option can change backwards-incompatibly.</p>
</section>
@@ -309,16 +328,15 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id=".">
<h3>
-
-<code>.</code>
-
+ <code>.</code>
</h3>
-
-<p>The absolute simplest (and least interesting) filter is <code>.</code>. This is a filter that takes its input and produces it unchanged as output.</p>
-
-<p>Since jq by default pretty-prints all output, this trivial program can be a useful way of formatting JSON output from, say, <code>curl</code>.</p>
-
+ <p>The absolute simplest (and least interesting) filter
+is <code>.</code>. This is a filter that takes its input and
+produces it unchanged as output.</p>
+<p>Since jq by default pretty-prints all output, this trivial
+program can be a useful way of formatting JSON output from,
+say, <code>curl</code>.</p>
<div>
@@ -331,14 +349,14 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.'</td></tr>
- <tr><th>Input</th><td>&quot;Hello, world!&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;Hello, world!&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;Hello, world!&quot;</td>
+ <td>&#34;Hello, world!&#34;</td>
</tr>
</table>
@@ -350,19 +368,16 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id=".foo,.foo.bar">
<h3>
-
-<code>.foo</code>, <code>.foo.bar</code>
-
+ <code>.foo</code>, <code>.foo.bar</code>
</h3>
-
-<p>The simplest <em>useful</em> filter is <code>.foo</code>. When given a JSON object (aka dictionary or hash) as input, it produces the value at the key “foo”, or null if there’s none present.</p>
-
-<p>If the key contains special characters, you need to surround it with double quotes like this: <code>.&quot;foo$&quot;</code>.</p>
-
+ <p>The simplest <em>useful</em> filter is <code>.foo</code>. When given a
+JSON object (aka dictionary or hash) as input, it produces
+the value at the key "foo", or null if there's none present.</p>
+<p>If the key contains special characters or starts with a digit,
+you need to surround it with double quotes like this: <code>."foo$"</code>.</p>
<p>A filter of the form <code>.foo.bar</code> is equivalent to <code>.foo|.bar</code>.</p>
-
<div>
@@ -374,7 +389,7 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.foo'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;less interesting data&quot;}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;less interesting data&#34;}</td></tr>
<tr>
@@ -388,7 +403,7 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.foo'</td></tr>
- <tr><th>Input</th><td>{&quot;notfoo&quot;: true, &quot;alsonotfoo&quot;: false}</td></tr>
+ <tr><th>Input</th><td>{&#34;notfoo&#34;: true, &#34;alsonotfoo&#34;: false}</td></tr>
<tr>
@@ -401,8 +416,8 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[&quot;foo&quot;]'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42}</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[&#34;foo&#34;]'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42}</td></tr>
<tr>
@@ -421,14 +436,11 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id=".foo?">
<h3>
-
-<code>.foo?</code>
-
+ <code>.foo?</code>
</h3>
-
-<p>Just like <code>.foo</code>, but does not output even an error when <code>.</code> is not an array or an object.</p>
-
+ <p>Just like <code>.foo</code>, but does not output even an error when <code>.</code>
+is not an array or an object.</p>
<div>
@@ -441,7 +453,7 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.foo?'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;less interesting data&quot;}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;less interesting data&#34;}</td></tr>
<tr>
@@ -455,7 +467,7 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.foo?'</td></tr>
- <tr><th>Input</th><td>{&quot;notfoo&quot;: true, &quot;alsonotfoo&quot;: false}</td></tr>
+ <tr><th>Input</th><td>{&#34;notfoo&#34;: true, &#34;alsonotfoo&#34;: false}</td></tr>
<tr>
@@ -468,8 +480,8 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[&quot;foo&quot;]?'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42}</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[&#34;foo&#34;]?'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42}</td></tr>
<tr>
@@ -500,24 +512,35 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
</section>
- <section id=".[<string>],.[2],.[10:15]">
+ <section id=".[&lt;string&gt;],.[2],.[10:15]">
<h3>
-
-<code>.[&lt;string&gt;]</code>, <code>.[2]</code>, <code>.[10:15]</code>
-
+ <code>.[&lt;string&gt;]</code>, <code>.[2]</code>, <code>.[10:15]</code>
</h3>
-
-<p>You can also look up fields of an object using syntax like <code>.[&quot;foo&quot;]</code> (.foo above is a shorthand version of this). This one works for arrays as well, if the key is an integer. Arrays are zero-based (like javascript), so <code>.[2]</code> returns the third element of the array.</p>
-
-<p>The <code>.[10:15]</code> syntax can be used to return a subarray of an array or substring of a string. The array returned by <code>.[10:15]</code> will be of length 5, containing the elements from index 10 (inclusive) to index 15 (exclusive). Either index may be negative (in which case it counts backwards from the end of the array), or omitted (in which case it refers to the start or end of the array).</p>
-
-<p>The <code>.[2]</code> syntax can be used to return the element at the given index. Negative indices are allowed, with -1 referring to the last element, -2 referring to the next to last element, and so on.</p>
-
-<p>The <code>.foo</code> syntax only works for simple keys i.e. keys that are all alphanumeric characters. <code>.[&lt;string&gt;]</code> works with keys that contain special characters such as colons and dots. For example <code>.[&quot;foo::bar&quot;]</code> and <code>.[&quot;foo.bar&quot;]</code> work while <code>.foo::bar</code> and <code>.foo.bar</code> would not.</p>
-
-<p>The <code>?</code> “operator” can also be used with the slice operator, as in <code>.[10:15]?</code>, which outputs values where the inputs are slice-able.</p>
-
+ <p>You can also look up fields of an object using syntax like
+<code>.["foo"]</code> (.foo above is a shorthand version of this). This
+one works for arrays as well, if the key is an
+integer. Arrays are zero-based (like javascript), so <code>.[2]</code>
+returns the third element of the array.</p>
+<p>The <code>.[10:15]</code> syntax can be used to return a subarray of an
+array or substring of a string. The array returned by
+<code>.[10:15]</code> will be of length 5, containing the elements from
+index 10 (inclusive) to index 15 (exclusive). Either index may
+be negative (in which case it counts backwards from the end of
+the array), or omitted (in which case it refers to the start
+or end of the array).</p>
+<p>The <code>.[2]</code> syntax can be used to return the element at the
+given index. Negative indices are allowed, with -1 referring
+to the last element, -2 referring to the next to last element,
+and so on.</p>
+<p>The <code>.foo</code> syntax only works for simple keys i.e. keys that
+are all alphanumeric characters. <code>.[&lt;string&gt;]</code> works with
+keys that contain special characters such as colons and dots.
+For example <code>.["foo::bar"]</code> and <code>.["foo.bar"]</code> work while
+<code>.foo::bar</code> and <code>.foo.bar</code> would not.</p>
+<p>The <code>?</code> "operator" can also be used with the slice operator,
+as in <code>.[10:15]?</code>, which outputs values where the inputs are
+slice-able.</p>
<div>
@@ -530,21 +553,21 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.[0]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}</td>
+ <td>{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[2]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
@@ -558,56 +581,56 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.[2:4]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;c&quot;, &quot;d&quot;]</td>
+ <td>[&#34;c&#34;, &#34;d&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[2:4]'</td></tr>
- <tr><th>Input</th><td>&quot;abcdefghi&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;abcdefghi&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;cd&quot;</td>
+ <td>&#34;cd&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[:3]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</td>
+ <td>[&#34;a&#34;, &#34;b&#34;, &#34;c&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[-2:]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;d&quot;, &quot;e&quot;]</td>
+ <td>[&#34;d&#34;, &#34;e&#34;]</td>
</tr>
</table>
@@ -633,16 +656,16 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id=".[]">
<h3>
-
-<code>.[]</code>
-
+ <code>.[]</code>
</h3>
-
-<p>If you use the <code>.[index]</code> syntax, but omit the index entirely, it will return <em>all</em> of the elements of an array. Running <code>.[]</code> with the input <code>[1,2,3]</code> will produce the numbers as three separate results, rather than as a single array.</p>
-
-<p>You can also use this on an object, and it will return all the values of the object.</p>
-
+ <p>If you use the <code>.[index]</code> syntax, but omit the index
+entirely, it will return <em>all</em> of the elements of an
+array. Running <code>.[]</code> with the input <code>[1,2,3]</code> will produce the
+numbers as three separate results, rather than as a single
+array.</p>
+<p>You can also use this on an object, and it will return all
+the values of the object.</p>
<div>
@@ -655,21 +678,21 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.[]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}</td>
+ <td>{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}</td>
+ <td>{&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}</td>
</tr>
</table>
@@ -688,7 +711,7 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.[]'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 1}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 1}</td></tr>
<tr>
@@ -714,28 +737,26 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id=".[]?">
<h3>
-
-<code>.[]?</code>
-
+ <code>.[]?</code>
</h3>
-
-<p>Like <code>.[]</code>, but no errors will be output if . is not an array or object.</p>
-
+ <p>Like <code>.[]</code>, but no errors will be output if . is not an array
+or object.</p>
</section>
<section id=",">
<h3>
-
-<code>,</code>
-
+ <code>,</code>
</h3>
-
-<p>If two filters are separated by a comma, then the input will be fed into both and there will be multiple outputs: first, all of the outputs produced by the left expression, and then all of the outputs produced by the right. For instance, filter <code>.foo, .bar</code>, produces both the “foo” fields and “bar” fields as separate outputs.</p>
-
+ <p>If two filters are separated by a comma, then the
+input will be fed into both and there will be multiple
+outputs: first, all of the outputs produced by the left
+expression, and then all of the outputs produced by the
+right. For instance, filter <code>.foo, .bar</code>, produces
+both the "foo" fields and "bar" fields as separate outputs.</p>
<div>
@@ -748,7 +769,7 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.foo, .bar'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;something else&quot;, &quot;baz&quot;: true}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;something else&#34;, &#34;baz&#34;: true}</td></tr>
<tr>
@@ -762,56 +783,56 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<th></th>
- <td>&quot;something else&quot;</td>
+ <td>&#34;something else&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.user, .projects[]'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;projects&quot;: [&quot;jq&quot;, &quot;wikiflow&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;projects&#34;: [&#34;jq&#34;, &#34;wikiflow&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>&quot;stedolan&quot;</td>
+ <td>&#34;stedolan&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;jq&quot;</td>
+ <td>&#34;jq&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;wikiflow&quot;</td>
+ <td>&#34;wikiflow&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[4,2]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;e&quot;</td>
+ <td>&#34;e&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;c&quot;</td>
+ <td>&#34;c&#34;</td>
</tr>
</table>
@@ -823,16 +844,17 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id="|">
<h3>
-
-<code>|</code>
-
+ <code>|</code>
</h3>
-
-<p>The | operator combines two filters by feeding the output(s) of the one on the left into the input of the one on the right. It’s pretty much the same as the Unix shell’s pipe, if you’re used to that.</p>
-
-<p>If the one on the left produces multiple results, the one on the right will be run for each of those results. So, the expression <code>.[] | .foo</code> retrieves the “foo” field of each element of the input array.</p>
-
+ <p>The | operator combines two filters by feeding the output(s) of
+the one on the left into the input of the one on the right. It's
+pretty much the same as the Unix shell's pipe, if you're used to
+that.</p>
+<p>If the one on the left produces multiple results, the one on
+the right will be run for each of those results. So, the
+expression <code>.[] | .foo</code> retrieves the "foo" field of each
+element of the input array.</p>
<div>
@@ -845,21 +867,21 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<table>
<tr><th></th><td class="jqprogram">jq '.[] | .name'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;JSON&quot;</td>
+ <td>&#34;JSON&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;XML&quot;</td>
+ <td>&#34;XML&#34;</td>
</tr>
</table>
@@ -873,26 +895,35 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id="TypesandValues">
<h2>Types and Values</h2>
-
-<p>jq supports the same set of datatypes as JSON - numbers, strings, booleans, arrays, objects (which in JSON-speak are hashes with only string keys), and “null”.</p>
-
-<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 - <code>42</code> is a valid jq expression that takes an input, ignores it, and returns 42 instead.</p>
-
+ <p>jq supports the same set of datatypes as JSON - numbers,
+strings, booleans, arrays, objects (which in JSON-speak are
+hashes with only string keys), and "null".</p>
+<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 - <code>42</code> is a valid jq
+expression that takes an input, ignores it, and returns 42
+instead.</p>
<section id="Arrayconstruction-[]">
<h3>
-
-Array construction - <code>[]</code>
-
+ Array construction - <code>[]</code>
</h3>
-
-<p>As in JSON, <code>[]</code> is used to construct arrays, as in <code>[1,2,3]</code>. The elements of the arrays can be any jq expression. 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 <code>[.foo, .bar, .baz]</code>) or to “collect” all the results of a filter into an array (as in <code>[.items[].name]</code>)</p>
-
-<p>Once you understand the “,” operator, you can look at jq’s array syntax in a different light: the expression <code>[1,2,3]</code> is not using a built-in syntax for comma-separated arrays, but is instead applying the <code>[]</code> operator (collect results) to the expression 1,2,3 (which produces three different results).</p>
-
-<p>If you have a filter <code>X</code> that produces four results, then the expression <code>[X]</code> will produce a single result, an array of four elements.</p>
-
+ <p>As in JSON, <code>[]</code> is used to construct arrays, as in
+<code>[1,2,3]</code>. The elements of the arrays can be any jq
+expression. 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 <code>[.foo, .bar, .baz]</code>) or to "collect" all the results of a
+filter into an array (as in <code>[.items[].name]</code>)</p>
+<p>Once you understand the "," operator, you can look at jq's array
+syntax in a different light: the expression <code>[1,2,3]</code> is not using a
+built-in syntax for comma-separated arrays, but is instead applying
+the <code>[]</code> operator (collect results) to the expression 1,2,3 (which
+produces three different results).</p>
+<p>If you have a filter <code>X</code> that produces four results,
+then the expression <code>[X]</code> will produce a single result, an
+array of four elements.</p>
<div>
@@ -905,14 +936,14 @@ Array construction - <code>[]</code>
<table>
<tr><th></th><td class="jqprogram">jq '[.user, .projects[]]'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;projects&quot;: [&quot;jq&quot;, &quot;wikiflow&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;projects&#34;: [&#34;jq&#34;, &#34;wikiflow&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;stedolan&quot;, &quot;jq&quot;, &quot;wikiflow&quot;]</td>
+ <td>[&#34;stedolan&#34;, &#34;jq&#34;, &#34;wikiflow&#34;]</td>
</tr>
</table>
@@ -924,45 +955,45 @@ Array construction - <code>[]</code>
<section id="Objects-{}">
<h3>
-
-Objects - <code>{}</code>
-
+ Objects - <code>{}</code>
</h3>
-
-<p>Like JSON, <code>{}</code> is for constructing objects (aka dictionaries or hashes), as in: <code>{&quot;a&quot;: 42, &quot;b&quot;: 17}</code>.</p>
-
-<p>If the keys are “sensible” (all alphabetic characters), then the quotes can be left off. 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).</p>
-
-<pre><code>{foo: .bar}</code></pre>
-
-<p>will produce the JSON object <code>{&quot;foo&quot;: 42}</code> if given the JSON object <code>{&quot;bar&quot;:42, &quot;baz&quot;:43}</code>. You can use this to select particular fields of an object: if the input is an object with “user”, “title”, “id”, and “content” fields and you just want “user” and “title”, you can write</p>
-
-<pre><code>{user: .user, title: .title}</code></pre>
-
-<p>Because that’s so common, there’s a shortcut syntax: <code>{user, title}</code>.</p>
-
-<p>If one of the expressions produces multiple results, multiple dictionaries will be produced. If the input’s</p>
-
-<pre><code>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</code></pre>
-
+ <p>Like JSON, <code>{}</code> is for constructing objects (aka
+dictionaries or hashes), as in: <code>{"a": 42, "b": 17}</code>.</p>
+<p>If the keys are "sensible" (all alphabetic characters), then
+the quotes can be left off. 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).</p>
+<pre><code>{foo: .bar}
+</code></pre>
+<p>will produce the JSON object <code>{"foo": 42}</code> if given the JSON
+object <code>{"bar":42, "baz":43}</code>. You can use this to select
+particular fields of an object: if the input is an object
+with "user", "title", "id", and "content" fields and you
+just want "user" and "title", you can write</p>
+<pre><code>{user: .user, title: .title}
+</code></pre>
+<p>Because that's so common, there's a shortcut syntax: <code>{user, title}</code>.</p>
+<p>If one of the expressions produces multiple results,
+multiple dictionaries will be produced. If the input's</p>
+<pre><code>{"user":"stedolan","titles":["JQ Primer", "More JQ"]}
+</code></pre>
<p>then the expression</p>
-
-<pre><code>{user, title: .titles[]}</code></pre>
-
+<pre><code>{user, title: .titles[]}
+</code></pre>
<p>will produce two outputs:</p>
-
-<pre><code>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;JQ Primer&quot;}
-{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;More JQ&quot;}</code></pre>
-
-<p>Putting parentheses around the key means it will be evaluated as an expression. With the same input as above,</p>
-
-<pre><code>{(.user): .titles}</code></pre>
-
+<pre><code>{"user":"stedolan", "title": "JQ Primer"}
+{"user":"stedolan", "title": "More JQ"}
+</code></pre>
+<p>Putting parentheses around the key means it will be evaluated as an
+expression. With the same input as above,</p>
+<pre><code>{(.user): .titles}
+</code></pre>
<p>produces</p>
-
-<pre><code>{&quot;stedolan&quot;: [&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</code></pre>
-
+<pre><code>{"stedolan": ["JQ Primer", "More JQ"]}
+</code></pre>
<div>
@@ -975,35 +1006,35 @@ Objects - <code>{}</code>
<table>
<tr><th></th><td class="jqprogram">jq '{user, title: .titles[]}'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;,&#34;titles&#34;:[&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;JQ Primer&quot;}</td>
+ <td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;title&#34;: &#34;JQ Primer&#34;}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;More JQ&quot;}</td>
+ <td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;title&#34;: &#34;More JQ&#34;}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '{(.user): .titles}'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;,&#34;titles&#34;:[&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;stedolan&quot;: [&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td>
+ <td>{&#34;stedolan&#34;: [&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td>
</tr>
</table>
@@ -1017,40 +1048,40 @@ Objects - <code>{}</code>
<section id="Builtinoperatorsandfunctions">
<h2>Builtin operators and functions</h2>
-
-<p>Some jq operator (for instance, <code>+</code>) 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>
-
+ <p>Some jq operator (for instance, <code>+</code>) 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>
<section id="Addition-+">
<h3>
-
-Addition - <code>+</code>
-
+ Addition - <code>+</code>
</h3>
-
-<p>The operator <code>+</code> takes two filters, applies them both to the same input, and adds the results together. What “adding” means depends on the types involved:</p>
-
+ <p>The operator <code>+</code> takes two filters, applies them both
+to the same input, and adds the results together. What
+"adding" means depends on the types involved:</p>
<ul>
<li>
<p><strong>Numbers</strong> are added by normal arithmetic.</p>
</li>
-
<li>
<p><strong>Arrays</strong> are added by being concatenated into a larger array.</p>
</li>
-
<li>
<p><strong>Strings</strong> are added by being joined into a larger string.</p>
</li>
-
<li>
-<p><strong>Objects</strong> are added by merging, that is, inserting all the key-value pairs from both objects into a single combined object. If both objects contain a value for the same key, the object on the right of the <code>+</code> wins. (For recursive merge use the <code>*</code> operator.)</p>
+<p><strong>Objects</strong> are added by merging, that is, inserting all
+ the key-value pairs from both objects into a single
+ combined object. If both objects contain a value for the
+ same key, the object on the right of the <code>+</code> wins. (For
+ recursive merge use the <code>*</code> operator.)</p>
</li>
</ul>
-
-<p><code>null</code> can be added to any value, and returns the other value unchanged.</p>
-
+<p><code>null</code> can be added to any value, and returns the other
+value unchanged.</p>
<div>
@@ -1063,7 +1094,7 @@ Addition - <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + 1'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 7}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 7}</td></tr>
<tr>
@@ -1077,7 +1108,7 @@ Addition - <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + .b'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: [1,2], &quot;b&quot;: [3,4]}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: [1,2], &#34;b&#34;: [3,4]}</td></tr>
<tr>
@@ -1091,7 +1122,7 @@ Addition - <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + null'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1}</td></tr>
<tr>
@@ -1126,7 +1157,7 @@ Addition - <code>+</code>
<th>Output</th>
- <td>{&quot;a&quot;: 42, &quot;b&quot;: 2, &quot;c&quot;: 3}</td>
+ <td>{&#34;a&#34;: 42, &#34;b&#34;: 2, &#34;c&#34;: 3}</td>
</tr>
</table>
@@ -1138,14 +1169,12 @@ Addition - <code>+</code>
<section id="Subtraction--">
<h3>
-
-Subtraction - <code>-</code>
-
+ Subtraction - <code>-</code>
</h3>
-
-<p>As well as normal arithmetic subtraction on numbers, the <code>-</code> operator can be used on arrays to remove all occurrences of the second array’s elements from the first array.</p>
-
+ <p>As well as normal arithmetic subtraction on numbers, the <code>-</code>
+operator can be used on arrays to remove all occurrences of
+the second array's elements from the first array.</p>
<div>
@@ -1158,7 +1187,7 @@ Subtraction - <code>-</code>
<table>
<tr><th></th><td class="jqprogram">jq '4 - .a'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:3}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:3}</td></tr>
<tr>
@@ -1171,15 +1200,15 @@ Subtraction - <code>-</code>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '. - [&quot;xml&quot;, &quot;yaml&quot;]'</td></tr>
- <tr><th>Input</th><td>[&quot;xml&quot;, &quot;yaml&quot;, &quot;json&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '. - [&#34;xml&#34;, &#34;yaml&#34;]'</td></tr>
+ <tr><th>Input</th><td>[&#34;xml&#34;, &#34;yaml&#34;, &#34;json&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;json&quot;]</td>
+ <td>[&#34;json&#34;]</td>
</tr>
</table>
@@ -1191,20 +1220,19 @@ Subtraction - <code>-</code>
<section id="Multiplication,division,modulo-*,/,and%">
<h3>
-
-Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</code>
-
+ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</code>
</h3>
-
-<p>These infix operators behave as expected when given two numbers. Division by zero raises an error. <code>x % y</code> computes x modulo y.</p>
-
-<p>Multiplying a string by a number produces the concatenation of that string that many times. <code>&quot;x&quot; * 0</code> produces <strong>null</strong>.</p>
-
-<p>Dividing a string by another splits the first using the second as separators.</p>
-
-<p>Multiplying two objects will merge them recursively: this works like addition but if both objects contain a value for the same key, and the values are objects, the two are merged with the same strategy.</p>
-
+ <p>These infix operators behave as expected when given two numbers.
+Division by zero raises an error. <code>x % y</code> computes x modulo y.</p>
+<p>Multiplying a string by a number produces the concatenation of
+that string that many times. <code>"x" * 0</code> produces <strong>null</strong>.</p>
+<p>Dividing a string by another splits the first using the second
+as separators.</p>
+<p>Multiplying two objects will merge them recursively: this works
+like addition but if both objects contain a value for the
+same key, and the values are objects, the two are merged with
+the same strategy.</p>
<div>
@@ -1230,21 +1258,21 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '. / &quot;, &quot;'</td></tr>
- <tr><th>Input</th><td>&quot;a, b,c,d, e&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq '. / &#34;, &#34;'</td></tr>
+ <tr><th>Input</th><td>&#34;a, b,c,d, e&#34;</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;a&quot;,&quot;b,c,d&quot;,&quot;e&quot;]</td>
+ <td>[&#34;a&#34;,&#34;b,c,d&#34;,&#34;e&#34;]</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '{&quot;k&quot;: {&quot;a&quot;: 1, &quot;b&quot;: 2}} * {&quot;k&quot;: {&quot;a&quot;: 0,&quot;c&quot;: 3}}'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '{&#34;k&#34;: {&#34;a&#34;: 1, &#34;b&#34;: 2}} * {&#34;k&#34;: {&#34;a&#34;: 0,&#34;c&#34;: 3}}'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -1252,7 +1280,7 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<th>Output</th>
- <td>{&quot;k&quot;: {&quot;a&quot;: 0, &quot;b&quot;: 2, &quot;c&quot;: 3}}</td>
+ <td>{&#34;k&#34;: {&#34;a&#34;: 0, &#34;b&#34;: 2, &#34;c&#34;: 3}}</td>
</tr>
</table>
@@ -1285,33 +1313,28 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<section id="length">
<h3>
-
-<code>length</code>
-
+ <code>length</code>
</h3>
-
-<p>The builtin function <code>length</code> gets the length of various different types of value:</p>
-
+ <p>The builtin function <code>length</code> gets the length of various
+different types of value:</p>
<ul>
<li>
-<p>The length of a <strong>string</strong> is the number of Unicode codepoints it contains (which will be the same as its JSON-encoded length in bytes if it’s pure ASCII).</p>
+<p>The length of a <strong>string</strong> is the number of Unicode
+ codepoints it contains (which will be the same as its
+ JSON-encoded length in bytes if it's pure ASCII).</p>
</li>
-
<li>
<p>The length of an <strong>array</strong> is the number of elements.</p>
</li>
-
<li>
<p>The length of an <strong>object</strong> is the number of key-value pairs.</p>
</li>
-
<li>
<p>The length of <strong>null</strong> is zero.</p>
</li>
</ul>
-
<div>
@@ -1323,7 +1346,7 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<table>
<tr><th></th><td class="jqprogram">jq '.[] | length'</td></tr>
- <tr><th>Input</th><td>[[1,2], &quot;string&quot;, {&quot;a&quot;:2}, null]</td></tr>
+ <tr><th>Input</th><td>[[1,2], &#34;string&#34;, {&#34;a&#34;:2}, null]</td></tr>
<tr>
@@ -1363,20 +1386,21 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<section id="keys,keys_unsorted">
<h3>
-
-<code>keys</code>, <code>keys_unsorted</code>
-
+ <code>keys</code>, <code>keys_unsorted</code>
</h3>
-
-<p>The builtin function <code>keys</code>, when given an object, returns its keys in an array.</p>
-
-<p>The keys are sorted “alphabetically”, by unicode codepoint order. This is not an order that makes particular sense in any particular language, but you can count on it being the same for any two objects with the same set of keys, regardless of locale settings.</p>
-
-<p>When <code>keys</code> is given an array, it returns the valid indices for that array: the integers from 0 to length-1.</p>
-
-<p>The <code>keys_unsorted</code> function is just like <code>keys</code>, but if the input is an object then the keys will not be sorted, instead the keys will roughly be in insertion order.</p>
-
+ <p>The builtin function <code>keys</code>, when given an object, returns
+its keys in an array.</p>
+<p>The keys are sorted "alphabetically", by unicode codepoint
+order. This is not an order that makes particular sense in
+any particular language, but you can count on it being the
+same for any two objects with the same set of keys,
+regardless of locale settings.</p>
+<p>When <code>keys</code> is given an array, it returns the valid indices
+for that array: the integers from 0 to length-1.</p>
+<p>The <code>keys_unsorted</code> function is just like <code>keys</code>, but if
+the input is an object then the keys will not be sorted,
+instead the keys will roughly be in insertion order.</p>
<div>
@@ -1389,14 +1413,14 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<table>
<tr><th></th><td class="jqprogram">jq 'keys'</td></tr>
- <tr><th>Input</th><td>{&quot;abc&quot;: 1, &quot;abcd&quot;: 2, &quot;Foo&quot;: 3}</td></tr>
+ <tr><th>Input</th><td>{&#34;abc&#34;: 1, &#34;abcd&#34;: 2, &#34;Foo&#34;: 3}</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;Foo&quot;, &quot;abc&quot;, &quot;abcd&quot;]</td>
+ <td>[&#34;Foo&#34;, &#34;abc&#34;, &#34;abcd&#34;]</td>
</tr>
</table>
@@ -1422,16 +1446,15 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<section id="has(key)">
<h3>
-
-<code>has(key)</code>
-
+ <code>has(key)</code>
</h3>
-
-<p>The builtin function <code>has</code> returns whether the input object has the given key, or the input array has an element at the given index.</p>
-
-<p><code>has($key)</code> has the same effect as checking whether <code>$key</code> is a member of the array returned by <code>keys</code>, although <code>has</code> will be faster.</p>
-
+ <p>The builtin function <code>has</code> returns whether the input object
+has the given key, or the input array has an element at the
+given index.</p>
+<p><code>has($key)</code> has the same effect as checking whether <code>$key</code>
+is a member of the array returned by <code>keys</code>, although <code>has</code>
+will be faster.</p>
<div>
@@ -1443,8 +1466,8 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<div id="example15" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'map(has(&quot;foo&quot;))'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;: 42}, {}]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'map(has(&#34;foo&#34;))'</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;: 42}, {}]</td></tr>
<tr>
@@ -1458,7 +1481,7 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<table>
<tr><th></th><td class="jqprogram">jq 'map(has(2))'</td></tr>
- <tr><th>Input</th><td>[[0,1], [&quot;a&quot;,&quot;b&quot;,&quot;c&quot;]]</td></tr>
+ <tr><th>Input</th><td>[[0,1], [&#34;a&#34;,&#34;b&#34;,&#34;c&#34;]]</td></tr>
<tr>
@@ -1477,14 +1500,13 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<section id="in">
<h3>
-
-<code>in</code>
-
+ <code>in</code>
</h3>
-
-<p>The builtin function <code>in</code> returns whether or not the input key is in the given object, or the input index corresponds to an element in the given array. It is, essentially, an inversed version of <code>has</code>.</p>
-
+ <p>The builtin function <code>in</code> returns whether or not the input key is in the
+given object, or the input index corresponds to an element
+in the given array. It is, essentially, an inversed version
+of <code>has</code>.</p>
<div>
@@ -1496,8 +1518,8 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<div id="example16" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '.[] | in({&quot;foo&quot;: 42})'</td></tr>
- <tr><th>Input</th><td>[&quot;foo&quot;, &quot;bar&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[] | in({&#34;foo&#34;: 42})'</td></tr>
+ <tr><th>Input</th><td>[&#34;foo&#34;, &#34;bar&#34;]</td></tr>
<tr>
@@ -1537,22 +1559,25 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<section id="path(path_expression)">
<h3>
-
-<code>path(path_expression)</code>
-
+ <code>path(path_expression)</code>
</h3>
-
-<p>Outputs array representations of the given path expression in <code>.</code>. The outputs are arrays of strings (object keys) and/or numbers (array indices).</p>
-
-<p>Path expressions are jq expressions like <code>.a</code>, but also <code>.[]</code>. There are two types of path expressions: ones that can match exactly, and ones that cannot. For example, <code>.a.b.c</code> is an exact match path expression, while <code>.a[].b</code> is not.</p>
-
-<p><code>path(exact_path_expression)</code> will produce the array representation of the path expression even if it does not exist in <code>.</code>, if <code>.</code> is <code>null</code> or an array or an object.</p>
-
-<p><code>path(pattern)</code> will produce array representations of the paths matching <code>pattern</code> if the paths exist in <code>.</code>.</p>
-
-<p>Note that the path expressions are not different from normal expressions. The expression <code>path(..|select(type==&quot;boolean&quot;))</code> outputs all the paths to boolean values in <code>.</code>, and only those paths.</p>
-
+ <p>Outputs array representations of the given path expression
+in <code>.</code>. The outputs are arrays of strings (object keys)
+and/or numbers (array indices).</p>
+<p>Path expressions are jq expressions like <code>.a</code>, but also <code>.[]</code>.
+There are two types of path expressions: ones that can match
+exactly, and ones that cannot. For example, <code>.a.b.c</code> is an
+exact match path expression, while <code>.a[].b</code> is not.</p>
+<p><code>path(exact_path_expression)</code> will produce the array
+representation of the path expression even if it does not
+exist in <code>.</code>, if <code>.</code> is <code>null</code> or an array or an object.</p>
+<p><code>path(pattern)</code> will produce array representations of the
+paths matching <code>pattern</code> if the paths exist in <code>.</code>.</p>
+<p>Note that the path expressions are not different from normal
+expressions. The expression
+<code>path(..|select(type=="boolean"))</code> outputs all the paths to
+boolean values in <code>.</code>, and only those paths.</p>
<div>
@@ -1572,21 +1597,21 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<th>Output</th>
- <td>[&quot;a&quot;,0,&quot;b&quot;]</td>
+ <td>[&#34;a&#34;,0,&#34;b&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[path(..)]'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:[{&quot;b&quot;:1}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:[{&#34;b&#34;:1}]}</td></tr>
<tr>
<th>Output</th>
- <td>[[],[&quot;a&quot;],[&quot;a&quot;,0],[&quot;a&quot;,0,&quot;b&quot;]]</td>
+ <td>[[],[&#34;a&#34;],[&#34;a&#34;,0],[&#34;a&#34;,0,&#34;b&#34;]]</td>
</tr>
</table>
@@ -1598,14 +1623,11 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<section id="del(path_expression)">
<h3>
-
-<code>del(path_expression)</code>
-
+ <code>del(path_expression)</code>
</h3>
-
-<p>The builtin function <code>del</code> removes a key and its corresponding value from an object.</p>
-
+ <p>The builtin function <code>del</code> removes a key and its corresponding
+value from an object.</p>
<div>
@@ -1618,28 +1640,28 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<table>
<tr><th></th><td class="jqprogram">jq 'del(.foo)'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: 9001, &quot;baz&quot;: 42}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: 9001, &#34;baz&#34;: 42}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;bar&quot;: 9001, &quot;baz&quot;: 42}</td>
+ <td>{&#34;bar&#34;: 9001, &#34;baz&#34;: 42}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'del(.[1, 2])'</td></tr>
- <tr><th>Input</th><td>[&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;foo&#34;, &#34;bar&#34;, &#34;baz&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;foo&quot;]</td>
+ <td>[&#34;foo&#34;]</td>
</tr>
</table>
@@ -1651,17 +1673,18 @@ Multiplication, division, modulo - <code>*</code>, <code>/</code>, and <code>%</
<section id="to_entries,from_entries,with_entries">
<h3>
-
-<code>to_entries</code>, <code>from_entries</code>, <code>with_entries</code>
-
+ <code>to_entries</code>, <code>from_entries</code>, <code>with_entries</code>
</h3>
-
-<p>These functions convert between an object and an array of key-value pairs. If <code>to_entries</code> is passed an object, then for each <code>k: v</code> entry in the input, the output array includes <code>{&quot;key&quot;: k, &quot;value&quot;: v}</code>.</p>
-
-<p><code>from_entries</code> does the opposite conversion, and <code>with_entries(foo)</code> is a shorthand for <code>to_entries |
-map(foo) | from_entries</code>, useful for doing some operation to all keys and values of an object. <code>from_entries</code> accepts key, Key, Name, value and Value as keys.</p>
-
+ <p>These functions convert between an object and an array of
+key-value pairs. If <code>to_entries</code> is passed an object, then
+for each <code>k: v</code> entry in the input, the output array
+includes <code>{"key": k, "value": v}</code>.</p>
+<p><code>from_entries</code> does the opposite conversion, and
+<code>with_entries(foo)</code> is a shorthand for <code>to_entries |
+map(foo) | from_entries</code>, useful for doing some operation to
+all keys and values of an object. <code>from_entries</code> accepts key, Key,
+Name, value and Value as keys.</p>
<div>
@@ -1674,42 +1697,42 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'to_entries'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;key&quot;:&quot;a&quot;, &quot;value&quot;:1}, {&quot;key&quot;:&quot;b&quot;, &quot;value&quot;:2}]</td>
+ <td>[{&#34;key&#34;:&#34;a&#34;, &#34;value&#34;:1}, {&#34;key&#34;:&#34;b&#34;, &#34;value&#34;:2}]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'from_entries'</td></tr>
- <tr><th>Input</th><td>[{&quot;key&quot;:&quot;a&quot;, &quot;value&quot;:1}, {&quot;key&quot;:&quot;b&quot;, &quot;value&quot;:2}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;key&#34;:&#34;a&#34;, &#34;value&#34;:1}, {&#34;key&#34;:&#34;b&#34;, &#34;value&#34;:2}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td>
+ <td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'with_entries(.key |= &quot;KEY_&quot; + .)'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'with_entries(.key |= &#34;KEY_&#34; + .)'</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;KEY_a&quot;: 1, &quot;KEY_b&quot;: 2}</td>
+ <td>{&#34;KEY_a&#34;: 1, &#34;KEY_b&#34;: 2}</td>
</tr>
</table>
@@ -1721,16 +1744,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="select(boolean_expression)">
<h3>
-
-<code>select(boolean_expression)</code>
-
+ <code>select(boolean_expression)</code>
</h3>
-
-<p>The function <code>select(foo)</code> produces its input unchanged if <code>foo</code> returns true for that input, and produces no output otherwise.</p>
-
-<p>It’s useful for filtering lists: <code>[1,2,3] | map(select(. &gt;= 2))</code> will give you <code>[2,3]</code>.</p>
-
+ <p>The function <code>select(foo)</code> produces its input unchanged if
+<code>foo</code> returns true for that input, and produces no output
+otherwise.</p>
+<p>It's useful for filtering lists: <code>[1,2,3] | map(select(. &gt;= 2))</code>
+will give you <code>[2,3]</code>.</p>
<div>
@@ -1756,15 +1777,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[] | select(.id == &quot;second&quot;)'</td></tr>
- <tr><th>Input</th><td>[{&quot;id&quot;: &quot;first&quot;, &quot;val&quot;: 1}, {&quot;id&quot;: &quot;second&quot;, &quot;val&quot;: 2}]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[] | select(.id == &#34;second&#34;)'</td></tr>
+ <tr><th>Input</th><td>[{&#34;id&#34;: &#34;first&#34;, &#34;val&#34;: 1}, {&#34;id&#34;: &#34;second&#34;, &#34;val&#34;: 2}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;id&quot;: &quot;second&quot;, &quot;val&quot;: 2}</td>
+ <td>{&#34;id&#34;: &#34;second&#34;, &#34;val&#34;: 2}</td>
</tr>
</table>
@@ -1776,14 +1797,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="arrays,objects,iterables,booleans,numbers,normals,finites,strings,nulls,values,scalars">
<h3>
-
-<code>arrays</code>, <code>objects</code>, <code>iterables</code>, <code>booleans</code>, <code>numbers</code>, <code>normals</code>, <code>finites</code>, <code>strings</code>, <code>nulls</code>, <code>values</code>, <code>scalars</code>
-
+ <code>arrays</code>, <code>objects</code>, <code>iterables</code>, <code>booleans</code>, <code>numbers</code>, <code>normals</code>, <code>finites</code>, <code>strings</code>, <code>nulls</code>, <code>values</code>, <code>scalars</code>
</h3>
-
-<p>These built-ins select only inputs that are arrays, objects, iterables (arrays or objects), booleans, numbers, normal numbers, finite numbers, strings, null, non-null values, and non-iterables, respectively.</p>
-
+ <p>These built-ins select only inputs that are arrays, objects,
+iterables (arrays or objects), booleans, numbers, normal
+numbers, finite numbers, strings, null, non-null values, and
+non-iterables, respectively.</p>
<div>
@@ -1796,7 +1816,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[]|numbers'</td></tr>
- <tr><th>Input</th><td>[[],{},1,&quot;foo&quot;,null,true,false]</td></tr>
+ <tr><th>Input</th><td>[[],{},1,&#34;foo&#34;,null,true,false]</td></tr>
<tr>
@@ -1815,16 +1835,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="empty">
<h3>
-
-<code>empty</code>
-
+ <code>empty</code>
</h3>
-
-<p><code>empty</code> returns no results. None at all. Not even <code>null</code>.</p>
-
-<p>It’s useful on occasion. You’ll know if you need it :)</p>
-
+ <p><code>empty</code> returns no results. None at all. Not even <code>null</code>.</p>
+<p>It's useful on occasion. You'll know if you need it :)</p>
<div>
@@ -1877,28 +1892,24 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="error(message)">
<h3>
-
-<code>error(message)</code>
-
+ <code>error(message)</code>
</h3>
-
-<p>Produces an error, just like <code>.a</code> applied to values other than null and objects would, but with the given message as the error’s value.</p>
-
+ <p>Produces an error, just like <code>.a</code> applied to values other than
+null and objects would, but with the given message as the
+error's value.</p>
</section>
<section id="$__loc__">
<h3>
-
-<code>$__loc__</code>
-
+ <code>$__loc__</code>
</h3>
-
-<p>Produces an object with a “file” key and a “line” key, with the filename and line number where <code>$__loc__</code> occurs, as values.</p>
-
+ <p>Produces an object with a "file" key and a "line" key, with
+the filename and line number where <code>$__loc__</code> occurs, as
+values.</p>
<div>
@@ -1910,7 +1921,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example23" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'try error(&quot;\($__loc__)&quot;) catch .'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'try error(&#34;\($__loc__)&#34;) catch .'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -1918,7 +1929,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;{\&quot;file\&quot;:\&quot;&lt;top-level&gt;\&quot;,\&quot;line\&quot;:1}&quot;</td>
+ <td>&#34;{\&#34;file\&#34;:\&#34;&lt;top-level&gt;\&#34;,\&#34;line\&#34;:1}&#34;</td>
</tr>
</table>
@@ -1930,18 +1941,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="map(x),map_values(x)">
<h3>
-
-<code>map(x)</code>, <code>map_values(x)</code>
-
+ <code>map(x)</code>, <code>map_values(x)</code>
</h3>
-
-<p>For any filter <code>x</code>, <code>map(x)</code> will run that filter for each element of the input array, and return the outputs in a new array. <code>map(.+1)</code> will increment each element of an array of numbers.</p>
-
-<p>Similarly, <code>map_values(x)</code> will run that filter for each element, but it will return an object when an object is passed.</p>
-
-<p><code>map(x)</code> is equivalent to <code>[.[] | x]</code>. In fact, this is how it’s defined. Similarly, <code>map_values(x)</code> is defined as <code>.[] |= x</code>.</p>
-
+ <p>For any filter <code>x</code>, <code>map(x)</code> will run that filter for each
+element of the input array, and return the outputs in a new
+array. <code>map(.+1)</code> will increment each element of an array of numbers.</p>
+<p>Similarly, <code>map_values(x)</code> will run that filter for each element,
+but it will return an object when an object is passed.</p>
+<p><code>map(x)</code> is equivalent to <code>[.[] | x]</code>. In fact, this is how
+it's defined. Similarly, <code>map_values(x)</code> is defined as <code>.[] |= x</code>.</p>
<div>
@@ -1968,14 +1977,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'map_values(.+1)'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: 3}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 2, &#34;c&#34;: 3}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;: 2, &quot;b&quot;: 3, &quot;c&quot;: 4}</td>
+ <td>{&#34;a&#34;: 2, &#34;b&#34;: 3, &#34;c&#34;: 4}</td>
</tr>
</table>
@@ -1987,18 +1996,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="paths,paths(node_filter),leaf_paths">
<h3>
-
-<code>paths</code>, <code>paths(node_filter)</code>, <code>leaf_paths</code>
-
+ <code>paths</code>, <code>paths(node_filter)</code>, <code>leaf_paths</code>
</h3>
-
-<p><code>paths</code> outputs the paths to all the elements in its input (except it does not output the empty list, representing . itself).</p>
-
-<p><code>paths(f)</code> outputs the paths to any values for which <code>f</code> is true. That is, <code>paths(numbers)</code> outputs the paths to all numeric values.</p>
-
-<p><code>leaf_paths</code> is an alias of <code>paths(scalars)</code>; <code>leaf_paths</code> is <em>deprecated</em> and will be removed in the next major release.</p>
-
+ <p><code>paths</code> outputs the paths to all the elements in its input
+(except it does not output the empty list, representing .
+itself).</p>
+<p><code>paths(f)</code> outputs the paths to any values for which <code>f</code> is true.
+That is, <code>paths(numbers)</code> outputs the paths to all numeric
+values.</p>
+<p><code>leaf_paths</code> is an alias of <code>paths(scalars)</code>; <code>leaf_paths</code> is
+<em>deprecated</em> and will be removed in the next major release.</p>
<div>
@@ -2011,28 +2019,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '[paths]'</td></tr>
- <tr><th>Input</th><td>[1,[[],{&quot;a&quot;:2}]]</td></tr>
+ <tr><th>Input</th><td>[1,[[],{&#34;a&#34;:2}]]</td></tr>
<tr>
<th>Output</th>
- <td>[[0],[1],[1,0],[1,1],[1,1,&quot;a&quot;]]</td>
+ <td>[[0],[1],[1,0],[1,1],[1,1,&#34;a&#34;]]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[paths(scalars)]'</td></tr>
- <tr><th>Input</th><td>[1,[[],{&quot;a&quot;:2}]]</td></tr>
+ <tr><th>Input</th><td>[1,[[],{&#34;a&#34;:2}]]</td></tr>
<tr>
<th>Output</th>
- <td>[[0],[1,1,&quot;a&quot;]]</td>
+ <td>[[0],[1,1,&#34;a&#34;]]</td>
</tr>
</table>
@@ -2044,17 +2052,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="add">
<h3>
-
-<code>add</code>
-
+ <code>add</code>
</h3>
-
-<p>The filter <code>add</code> takes as input an array, and produces as output the elements of the array added together. This might mean summed, concatenated or merged depending on the types of the elements of the input array - the rules are the same as those for the <code>+</code> operator (described above).</p>
-
+ <p>The filter <code>add</code> takes as input an array, and produces as
+output the elements of the array added together. This might
+mean summed, concatenated or merged depending on the types
+of the elements of the input array - the rules are the same
+as those for the <code>+</code> operator (described above).</p>
<p>If the input is an empty array, <code>add</code> returns <code>null</code>.</p>
-
<div>
@@ -2066,14 +2073,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'add'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;abc&quot;</td>
+ <td>&#34;abc&#34;</td>
</tr>
</table>
@@ -2113,20 +2120,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="any,any(condition),any(generator;condition)">
<h3>
-
-<code>any</code>, <code>any(condition)</code>, <code>any(generator; condition)</code>
-
+ <code>any</code>, <code>any(condition)</code>, <code>any(generator; condition)</code>
</h3>
-
-<p>The filter <code>any</code> takes as input an array of boolean values, and produces <code>true</code> as output if any of the elements of the array are <code>true</code>.</p>
-
+ <p>The filter <code>any</code> takes as input an array of boolean values,
+and produces <code>true</code> as output if any of the elements of
+the array are <code>true</code>.</p>
<p>If the input is an empty array, <code>any</code> returns <code>false</code>.</p>
-
-<p>The <code>any(condition)</code> form applies the given condition to the elements of the input array.</p>
-
-<p>The <code>any(generator; condition)</code> form applies the given condition to all the outputs of the given generator.</p>
-
+<p>The <code>any(condition)</code> form applies the given condition to the
+elements of the input array.</p>
+<p>The <code>any(generator; condition)</code> form applies the given
+condition to all the outputs of the given generator.</p>
<div>
@@ -2186,21 +2190,18 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="all,all(condition),all(generator;condition)">
<h3>
-
-<code>all</code>, <code>all(condition)</code>, <code>all(generator; condition)</code>
-
+ <code>all</code>, <code>all(condition)</code>, <code>all(generator; condition)</code>
</h3>
-
-<p>The filter <code>all</code> takes as input an array of boolean values, and produces <code>true</code> as output if all of the elements of the array are <code>true</code>.</p>
-
-<p>The <code>all(condition)</code> form applies the given condition to the elements of the input array.</p>
-
-<p>The <code>all(generator; condition)</code> form applies the given condition to all the outputs of the given generator.</p>
-
+ <p>The filter <code>all</code> takes as input an array of boolean values,
+and produces <code>true</code> as output if all of the elements of
+the array are <code>true</code>.</p>
+<p>The <code>all(condition)</code> form applies the given condition to the
+elements of the input array.</p>
+<p>The <code>all(generator; condition)</code> form applies the given
+condition to all the outputs of the given generator.</p>
<p>If the input is an empty array, <code>all</code> returns <code>true</code>.</p>
-
<div>
@@ -2259,16 +2260,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="flatten,flatten(depth)">
<h3>
-
-<code>flatten</code>, <code>flatten(depth)</code>
-
+ <code>flatten</code>, <code>flatten(depth)</code>
</h3>
-
-<p>The filter <code>flatten</code> takes as input an array of nested arrays, and produces a flat array in which all arrays inside the original array have been recursively replaced by their values. You can pass an argument to it to specify how many levels of nesting to flatten.</p>
-
-<p><code>flatten(2)</code> is like <code>flatten</code>, but going only up to two levels deep.</p>
-
+ <p>The filter <code>flatten</code> takes as input an array of nested arrays,
+and produces a flat array in which all arrays inside the original
+array have been recursively replaced by their values. You can pass
+an argument to it to specify how many levels of nesting to flatten.</p>
+<p><code>flatten(2)</code> is like <code>flatten</code>, but going only up to two
+levels deep.</p>
<div>
@@ -2323,14 +2323,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'flatten'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;: &quot;bar&quot;}, [{&quot;foo&quot;: &quot;baz&quot;}]]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;: &#34;bar&#34;}, [{&#34;foo&#34;: &#34;baz&#34;}]]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;foo&quot;: &quot;bar&quot;}, {&quot;foo&quot;: &quot;baz&quot;}]</td>
+ <td>[{&#34;foo&#34;: &#34;bar&#34;}, {&#34;foo&#34;: &#34;baz&#34;}]</td>
</tr>
</table>
@@ -2342,20 +2342,19 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="range(upto),range(from;upto)range(from;upto;by)">
<h3>
-
-<code>range(upto)</code>, <code>range(from;upto)</code> <code>range(from;upto;by)</code>
-
+ <code>range(upto)</code>, <code>range(from;upto)</code> <code>range(from;upto;by)</code>
</h3>
-
-<p>The <code>range</code> function produces a range of numbers. <code>range(4;10)</code> produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers are produced as separate outputs. Use <code>[range(4;10)]</code> to get a range as an array.</p>
-
-<p>The one argument form generates numbers from 0 to the given number, with an increment of 1.</p>
-
-<p>The two argument form generates numbers from <code>from</code> to <code>upto</code> with an increment of 1.</p>
-
-<p>The three argument form generates numbers <code>from</code> to <code>upto</code> with an increment of <code>by</code>.</p>
-
+ <p>The <code>range</code> function produces a range of numbers. <code>range(4;10)</code>
+produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers
+are produced as separate outputs. Use <code>[range(4;10)]</code> to get a range as
+an array.</p>
+<p>The one argument form generates numbers from 0 to the given
+number, with an increment of 1.</p>
+<p>The two argument form generates numbers from <code>from</code> to <code>upto</code>
+with an increment of 1.</p>
+<p>The three argument form generates numbers <code>from</code> to <code>upto</code>
+with an increment of <code>by</code>.</p>
<div>
@@ -2464,14 +2463,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="floor">
<h3>
-
-<code>floor</code>
-
+ <code>floor</code>
</h3>
-
-<p>The <code>floor</code> function returns the floor of its numeric input.</p>
-
+ <p>The <code>floor</code> function returns the floor of its numeric input.</p>
<div>
@@ -2503,14 +2498,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="sqrt">
<h3>
-
-<code>sqrt</code>
-
+ <code>sqrt</code>
</h3>
-
-<p>The <code>sqrt</code> function returns the square root of its numeric input.</p>
-
+ <p>The <code>sqrt</code> function returns the square root of its numeric input.</p>
<div>
@@ -2542,14 +2533,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="tonumber">
<h3>
-
-<code>tonumber</code>
-
+ <code>tonumber</code>
</h3>
-
-<p>The <code>tonumber</code> function parses its input as a number. It will convert correctly-formatted strings to their numeric equivalent, leave numbers alone, and give an error on all other input.</p>
-
+ <p>The <code>tonumber</code> function parses its input as a number. It
+will convert correctly-formatted strings to their numeric
+equivalent, leave numbers alone, and give an error on all other input.</p>
<div>
@@ -2562,7 +2551,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[] | tonumber'</td></tr>
- <tr><th>Input</th><td>[1, &quot;1&quot;]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;1&#34;]</td></tr>
<tr>
@@ -2588,14 +2577,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="tostring">
<h3>
-
-<code>tostring</code>
-
+ <code>tostring</code>
</h3>
-
-<p>The <code>tostring</code> function prints its input as a string. Strings are left unchanged, and all other values are JSON-encoded.</p>
-
+ <p>The <code>tostring</code> function prints its input as a
+string. Strings are left unchanged, and all other values are
+JSON-encoded.</p>
<div>
@@ -2608,28 +2595,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[] | tostring'</td></tr>
- <tr><th>Input</th><td>[1, &quot;1&quot;, [1]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;1&#34;, [1]]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;1&quot;</td>
+ <td>&#34;1&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;1&quot;</td>
+ <td>&#34;1&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;[1]&quot;</td>
+ <td>&#34;[1]&#34;</td>
</tr>
</table>
@@ -2641,14 +2628,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="type">
<h3>
-
-<code>type</code>
-
+ <code>type</code>
</h3>
-
-<p>The <code>type</code> function returns the type of its argument as a string, which is one of null, boolean, number, string, array or object.</p>
-
+ <p>The <code>type</code> function returns the type of its argument as a
+string, which is one of null, boolean, number, string, array
+or object.</p>
<div>
@@ -2661,14 +2646,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'map(type)'</td></tr>
- <tr><th>Input</th><td>[0, false, [], {}, null, &quot;hello&quot;]</td></tr>
+ <tr><th>Input</th><td>[0, false, [], {}, null, &#34;hello&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;number&quot;, &quot;boolean&quot;, &quot;array&quot;, &quot;object&quot;, &quot;null&quot;, &quot;string&quot;]</td>
+ <td>[&#34;number&#34;, &#34;boolean&#34;, &#34;array&#34;, &#34;object&#34;, &#34;null&#34;, &#34;string&#34;]</td>
</tr>
</table>
@@ -2680,18 +2665,19 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="infinite,nan,isinfinite,isnan,isfinite,isnormal">
<h3>
-
-<code>infinite</code>, <code>nan</code>, <code>isinfinite</code>, <code>isnan</code>, <code>isfinite</code>, <code>isnormal</code>
-
+ <code>infinite</code>, <code>nan</code>, <code>isinfinite</code>, <code>isnan</code>, <code>isfinite</code>, <code>isnormal</code>
</h3>
-
-<p>Some arithmetic operations can yield infinities and “not a number” (NaN) values. The <code>isinfinite</code> builtin returns <code>true</code> if its input is infinite. The <code>isnan</code> builtin returns <code>true</code> if its input is a NaN. The <code>infinite</code> builtin returns a positive infinite value. The <code>nan</code> builtin returns a NaN. The <code>isnormal</code> builtin returns true if its input is a normal number.</p>
-
+ <p>Some arithmetic operations can yield infinities and "not a
+number" (NaN) values. The <code>isinfinite</code> builtin returns <code>true</code>
+if its input is infinite. The <code>isnan</code> builtin returns <code>true</code>
+if its input is a NaN. The <code>infinite</code> builtin returns a
+positive infinite value. The <code>nan</code> builtin returns a NaN.
+The <code>isnormal</code> builtin returns true if its input is a normal
+number.</p>
<p>Note that division by zero raises an error.</p>
-
-<p>Currently most arithmetic operations operating on infinities, NaNs, and sub-normals do not raise errors.</p>
-
+<p>Currently most arithmetic operations operating on infinities,
+NaNs, and sub-normals do not raise errors.</p>
<div>
@@ -2732,14 +2718,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;number&quot;</td>
+ <td>&#34;number&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;number&quot;</td>
+ <td>&#34;number&#34;</td>
</tr>
</table>
@@ -2751,36 +2737,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="sort,sort_by(path_expression)">
<h3>
-
-<code>sort, sort_by(path_expression)</code>
-
+ <code>sort, sort_by(path_expression)</code>
</h3>
-
-<p>The <code>sort</code> functions sorts its input, which must be an array. Values are sorted in the following order:</p>
-
+ <p>The <code>sort</code> functions sorts its input, which must be an
+array. Values are sorted in the following order:</p>
<ul>
<li><code>null</code></li>
-
<li><code>false</code></li>
-
<li><code>true</code></li>
-
<li>numbers</li>
-
<li>strings, in alphabetical order (by unicode codepoint value)</li>
-
<li>arrays, in lexical order</li>
-
<li>objects</li>
</ul>
-
-<p>The ordering for objects is a little complex: first they’re compared by comparing their sets of keys (as arrays in sorted order), and if their keys are equal then the values are compared key by key.</p>
-
-<p><code>sort</code> may be used to sort by a particular field of an object, or by applying any jq filter.</p>
-
-<p><code>sort_by(foo)</code> compares two elements by comparing the result of <code>foo</code> on each element.</p>
-
+<p>The ordering for objects is a little complex: first they're
+compared by comparing their sets of keys (as arrays in
+sorted order), and if their keys are equal then the values
+are compared key by key.</p>
+<p><code>sort</code> may be used to sort by a particular field of an
+object, or by applying any jq filter.</p>
+<p><code>sort_by(foo)</code> compares two elements by comparing the result of
+<code>foo</code> on each element.</p>
<div>
@@ -2807,14 +2785,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'sort_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:4, &quot;bar&quot;:10}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:2, &quot;bar&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:4, &#34;bar&#34;:10}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:2, &#34;bar&#34;:1}]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;foo&quot;:2, &quot;bar&quot;:1}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:4, &quot;bar&quot;:10}]</td>
+ <td>[{&#34;foo&#34;:2, &#34;bar&#34;:1}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:4, &#34;bar&#34;:10}]</td>
</tr>
</table>
@@ -2826,16 +2804,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="group_by(path_expression)">
<h3>
-
-<code>group_by(path_expression)</code>
-
+ <code>group_by(path_expression)</code>
</h3>
-
-<p><code>group_by(.foo)</code> takes as input an array, groups the elements having the same <code>.foo</code> field into separate arrays, and produces all of these arrays as elements of a larger array, sorted by the value of the <code>.foo</code> field.</p>
-
-<p>Any jq expression, not just a field access, may be used in place of <code>.foo</code>. The sorting order is the same as described in the <code>sort</code> function above.</p>
-
+ <p><code>group_by(.foo)</code> takes as input an array, groups the
+elements having the same <code>.foo</code> field into separate arrays,
+and produces all of these arrays as elements of a larger
+array, sorted by the value of the <code>.foo</code> field.</p>
+<p>Any jq expression, not just a field access, may be used in
+place of <code>.foo</code>. The sorting order is the same as described
+in the <code>sort</code> function above.</p>
<div>
@@ -2848,14 +2826,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'group_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:1, &quot;bar&quot;:10}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:1, &quot;bar&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:1, &#34;bar&#34;:10}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:1, &#34;bar&#34;:1}]</td></tr>
<tr>
<th>Output</th>
- <td>[[{&quot;foo&quot;:1, &quot;bar&quot;:10}, {&quot;foo&quot;:1, &quot;bar&quot;:1}], [{&quot;foo&quot;:3, &quot;bar&quot;:100}]]</td>
+ <td>[[{&#34;foo&#34;:1, &#34;bar&#34;:10}, {&#34;foo&#34;:1, &#34;bar&#34;:1}], [{&#34;foo&#34;:3, &#34;bar&#34;:100}]]</td>
</tr>
</table>
@@ -2867,16 +2845,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="min,max,min_by(path_exp),max_by(path_exp)">
<h3>
-
-<code>min</code>, <code>max</code>, <code>min_by(path_exp)</code>, <code>max_by(path_exp)</code>
-
+ <code>min</code>, <code>max</code>, <code>min_by(path_exp)</code>, <code>max_by(path_exp)</code>
</h3>
-
-<p>Find the minimum or maximum element of the input array.</p>
-
-<p>The <code>min_by(path_exp)</code> and <code>max_by(path_exp)</code> functions allow you to specify a particular field or property to examine, e.g. <code>min_by(.foo)</code> finds the object with the smallest <code>foo</code> field.</p>
-
+ <p>Find the minimum or maximum element of the input array.</p>
+<p>The <code>min_by(path_exp)</code> and <code>max_by(path_exp)</code> functions allow
+you to specify a particular field or property to examine, e.g.
+<code>min_by(.foo)</code> finds the object with the smallest <code>foo</code> field.</p>
<div>
@@ -2903,14 +2878,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'max_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:1, &quot;bar&quot;:14}, {&quot;foo&quot;:2, &quot;bar&quot;:3}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:1, &#34;bar&#34;:14}, {&#34;foo&#34;:2, &#34;bar&#34;:3}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;:2, &quot;bar&quot;:3}</td>
+ <td>{&#34;foo&#34;:2, &#34;bar&#34;:3}</td>
</tr>
</table>
@@ -2922,16 +2897,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="unique,unique_by(path_exp)">
<h3>
-
-<code>unique</code>, <code>unique_by(path_exp)</code>
-
+ <code>unique</code>, <code>unique_by(path_exp)</code>
</h3>
-
-<p>The <code>unique</code> function takes as input an array and produces an array of the same elements, in sorted order, with duplicates removed.</p>
-
-<p>The <code>unique_by(path_exp)</code> function will keep only one element for each value obtained by applying the argument. Think of it as making an array by taking one element out of every group produced by <code>group</code>.</p>
-
+ <p>The <code>unique</code> function takes as input an array and produces
+an array of the same elements, in sorted order, with
+duplicates removed.</p>
+<p>The <code>unique_by(path_exp)</code> function will keep only one element
+for each value obtained by applying the argument. Think of it
+as making an array by taking one element out of every group
+produced by <code>group</code>.</p>
<div>
@@ -2958,28 +2933,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'unique_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;: 1, &quot;bar&quot;: 2}, {&quot;foo&quot;: 1, &quot;bar&quot;: 3}, {&quot;foo&quot;: 4, &quot;bar&quot;: 5}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;: 1, &#34;bar&#34;: 2}, {&#34;foo&#34;: 1, &#34;bar&#34;: 3}, {&#34;foo&#34;: 4, &#34;bar&#34;: 5}]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;foo&quot;: 1, &quot;bar&quot;: 2}, {&quot;foo&quot;: 4, &quot;bar&quot;: 5}]</td>
+ <td>[{&#34;foo&#34;: 1, &#34;bar&#34;: 2}, {&#34;foo&#34;: 4, &#34;bar&#34;: 5}]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'unique_by(length)'</td></tr>
- <tr><th>Input</th><td>[&quot;chunky&quot;, &quot;bacon&quot;, &quot;kitten&quot;, &quot;cicada&quot;, &quot;asparagus&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;chunky&#34;, &#34;bacon&#34;, &#34;kitten&#34;, &#34;cicada&#34;, &#34;asparagus&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;bacon&quot;, &quot;chunky&quot;, &quot;asparagus&quot;]</td>
+ <td>[&#34;bacon&#34;, &#34;chunky&#34;, &#34;asparagus&#34;]</td>
</tr>
</table>
@@ -2991,14 +2966,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="reverse">
<h3>
-
-<code>reverse</code>
-
+ <code>reverse</code>
</h3>
-
-<p>This function reverses an array.</p>
-
+ <p>This function reverses an array.</p>
<div>
@@ -3030,14 +3001,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="contains(element)">
<h3>
-
-<code>contains(element)</code>
-
+ <code>contains(element)</code>
</h3>
-
-<p>The filter <code>contains(b)</code> will produce true if b is completely contained within the input. A string B is contained in a string A if B is a substring of A. An array B is contained in an array A if all elements in B are contained in any element in A. An object B is contained in object A if all of the values in B are contained in the value in A with the same key. All other types are assumed to be contained in each other if they are equal.</p>
-
+ <p>The filter <code>contains(b)</code> will produce true if b is
+completely contained within the input. A string B is
+contained in a string A if B is a substring of A. An array B
+is contained in an array A if all elements in B are
+contained in any element in A. An object B is contained in
+object A if all of the values in B are contained in the
+value in A with the same key. All other types are assumed to
+be contained in each other if they are equal.</p>
<div>
@@ -3049,8 +3023,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example42" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'contains(&quot;bar&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foobar&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains(&#34;bar&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foobar&#34;</td></tr>
<tr>
@@ -3063,8 +3037,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'contains([&quot;baz&quot;, &quot;bar&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains([&#34;baz&#34;, &#34;bar&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;]</td></tr>
<tr>
@@ -3077,8 +3051,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'contains([&quot;bazzzzz&quot;, &quot;bar&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains([&#34;bazzzzz&#34;, &#34;bar&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;]</td></tr>
<tr>
@@ -3092,7 +3066,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'contains({foo: 12, bar: [{barp: 12}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]}</td></tr>
<tr>
@@ -3106,7 +3080,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'contains({foo: 12, bar: [{barp: 15}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]}</td></tr>
<tr>
@@ -3125,14 +3099,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="indices(s)">
<h3>
-
-<code>indices(s)</code>
-
+ <code>indices(s)</code>
</h3>
-
-<p>Outputs an array containing the indices in <code>.</code> where <code>s</code> occurs. The input may be an array, in which case if <code>s</code> is an array then the indices output will be those where all elements in <code>.</code> match those of <code>s</code>.</p>
-
+ <p>Outputs an array containing the indices in <code>.</code> where <code>s</code>
+occurs. The input may be an array, in which case if <code>s</code> is an
+array then the indices output will be those where all elements
+in <code>.</code> match those of <code>s</code>.</p>
<div>
@@ -3144,8 +3117,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example43" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'indices(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a,b, cd, efg, hijk&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'indices(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a,b, cd, efg, hijk&#34;</td></tr>
<tr>
@@ -3192,14 +3165,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="index(s),rindex(s)">
<h3>
-
-<code>index(s)</code>, <code>rindex(s)</code>
-
+ <code>index(s)</code>, <code>rindex(s)</code>
</h3>
-
-<p>Outputs the index of the first (<code>index</code>) or last (<code>rindex</code>) occurrence of <code>s</code> in the input.</p>
-
+ <p>Outputs the index of the first (<code>index</code>) or last (<code>rindex</code>)
+occurrence of <code>s</code> in the input.</p>
<div>
@@ -3211,8 +3181,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example44" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'index(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a,b, cd, efg, hijk&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'index(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a,b, cd, efg, hijk&#34;</td></tr>
<tr>
@@ -3225,8 +3195,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'rindex(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a,b, cd, efg, hijk&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'rindex(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a,b, cd, efg, hijk&#34;</td></tr>
<tr>
@@ -3245,14 +3215,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="inside">
<h3>
-
-<code>inside</code>
-
+ <code>inside</code>
</h3>
-
-<p>The filter <code>inside(b)</code> will produce true if the input is completely contained within b. It is, essentially, an inversed version of <code>contains</code>.</p>
-
+ <p>The filter <code>inside(b)</code> will produce true if the input is
+completely contained within b. It is, essentially, an
+inversed version of <code>contains</code>.</p>
<div>
@@ -3264,8 +3232,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example45" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'inside(&quot;foobar&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;bar&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside(&#34;foobar&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;bar&#34;</td></tr>
<tr>
@@ -3278,8 +3246,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'inside([&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;baz&quot;, &quot;bar&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside([&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;baz&#34;, &#34;bar&#34;]</td></tr>
<tr>
@@ -3292,8 +3260,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'inside([&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;bazzzzz&quot;, &quot;bar&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside([&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;bazzzzz&#34;, &#34;bar&#34;]</td></tr>
<tr>
@@ -3306,8 +3274,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'inside({&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;: [{&quot;barp&quot;: 12}]}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside({&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]})'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;: [{&#34;barp&#34;: 12}]}</td></tr>
<tr>
@@ -3320,8 +3288,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'inside({&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;: [{&quot;barp&quot;: 15}]}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside({&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]})'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;: [{&#34;barp&#34;: 15}]}</td></tr>
<tr>
@@ -3340,14 +3308,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="startswith(str)">
<h3>
-
-<code>startswith(str)</code>
-
+ <code>startswith(str)</code>
</h3>
-
-<p>Outputs <code>true</code> if . starts with the given string argument.</p>
-
+ <p>Outputs <code>true</code> if . starts with the given string argument.</p>
<div>
@@ -3359,8 +3323,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example46" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|startswith(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;fo&quot;, &quot;foo&quot;, &quot;barfoo&quot;, &quot;foobar&quot;, &quot;barfoob&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|startswith(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;fo&#34;, &#34;foo&#34;, &#34;barfoo&#34;, &#34;foobar&#34;, &#34;barfoob&#34;]</td></tr>
<tr>
@@ -3379,14 +3343,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="endswith(str)">
<h3>
-
-<code>endswith(str)</code>
-
+ <code>endswith(str)</code>
</h3>
-
-<p>Outputs <code>true</code> if . ends with the given string argument.</p>
-
+ <p>Outputs <code>true</code> if . ends with the given string argument.</p>
<div>
@@ -3398,8 +3358,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example47" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|endswith(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;barfoo&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|endswith(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;barfoo&#34;]</td></tr>
<tr>
@@ -3418,14 +3378,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="combinations,combinations(n)">
<h3>
-
-<code>combinations</code>, <code>combinations(n)</code>
-
+ <code>combinations</code>, <code>combinations(n)</code>
</h3>
-
-<p>Outputs all combinations of the elements of the arrays in the input array. If given an argument <code>n</code>, it outputs all combinations of <code>n</code> repetitions of the input array.</p>
-
+ <p>Outputs all combinations of the elements of the arrays in the
+input array. If given an argument <code>n</code>, it outputs all combinations
+of <code>n</code> repetitions of the input array.</p>
<div>
@@ -3513,14 +3471,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="ltrimstr(str)">
<h3>
-
-<code>ltrimstr(str)</code>
-
+ <code>ltrimstr(str)</code>
</h3>
-
-<p>Outputs its input with the given prefix string removed, if it starts with it.</p>
-
+ <p>Outputs its input with the given prefix string removed, if it
+starts with it.</p>
<div>
@@ -3532,15 +3487,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example49" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|ltrimstr(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;fo&quot;, &quot;foo&quot;, &quot;barfoo&quot;, &quot;foobar&quot;, &quot;afoo&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|ltrimstr(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;fo&#34;, &#34;foo&#34;, &#34;barfoo&#34;, &#34;foobar&#34;, &#34;afoo&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;fo&quot;,&quot;&quot;,&quot;barfoo&quot;,&quot;bar&quot;,&quot;afoo&quot;]</td>
+ <td>[&#34;fo&#34;,&#34;&#34;,&#34;barfoo&#34;,&#34;bar&#34;,&#34;afoo&#34;]</td>
</tr>
</table>
@@ -3552,14 +3507,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="rtrimstr(str)">
<h3>
-
-<code>rtrimstr(str)</code>
-
+ <code>rtrimstr(str)</code>
</h3>
-
-<p>Outputs its input with the given suffix string removed, if it ends with it.</p>
-
+ <p>Outputs its input with the given suffix string removed, if it
+ends with it.</p>
<div>
@@ -3571,15 +3523,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example50" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|rtrimstr(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;fo&quot;, &quot;foo&quot;, &quot;barfoo&quot;, &quot;foobar&quot;, &quot;foob&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|rtrimstr(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;fo&#34;, &#34;foo&#34;, &#34;barfoo&#34;, &#34;foobar&#34;, &#34;foob&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;fo&quot;,&quot;&quot;,&quot;bar&quot;,&quot;foobar&quot;,&quot;foob&quot;]</td>
+ <td>[&#34;fo&#34;,&#34;&#34;,&#34;bar&#34;,&#34;foobar&#34;,&#34;foob&#34;]</td>
</tr>
</table>
@@ -3591,14 +3543,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="explode">
<h3>
-
-<code>explode</code>
-
+ <code>explode</code>
</h3>
-
-<p>Converts an input string into an array of the string’s codepoint numbers.</p>
-
+ <p>Converts an input string into an array of the string's
+codepoint numbers.</p>
<div>
@@ -3611,7 +3560,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'explode'</td></tr>
- <tr><th>Input</th><td>&quot;foobar&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;foobar&#34;</td></tr>
<tr>
@@ -3630,14 +3579,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="implode">
<h3>
-
-<code>implode</code>
-
+ <code>implode</code>
</h3>
-
-<p>The inverse of explode.</p>
-
+ <p>The inverse of explode.</p>
<div>
@@ -3657,7 +3602,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;ABC&quot;</td>
+ <td>&#34;ABC&#34;</td>
</tr>
</table>
@@ -3669,14 +3614,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="split">
<h3>
-
-<code>split</code>
-
+ <code>split</code>
</h3>
-
-<p>Splits an input string on the separator argument.</p>
-
+ <p>Splits an input string on the separator argument.</p>
<div>
@@ -3688,15 +3629,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example53" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'split(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a, b,c,d, e, &quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'split(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a, b,c,d, e, &#34;</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;a&quot;,&quot;b,c,d&quot;,&quot;e&quot;,&quot;&quot;]</td>
+ <td>[&#34;a&#34;,&#34;b,c,d&#34;,&#34;e&#34;,&#34;&#34;]</td>
</tr>
</table>
@@ -3708,14 +3649,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="join(str)">
<h3>
-
-<code>join(str)</code>
-
+ <code>join(str)</code>
</h3>
-
-<p>Joins the array of elements given as input, using the argument as separator. It is the inverse of <code>split</code>: that is, running <code>split(&quot;foo&quot;) | join(&quot;foo&quot;)</code> over any input string returns said input string.</p>
-
+ <p>Joins the array of elements given as input, using the
+argument as separator. It is the inverse of <code>split</code>: that is,
+running <code>split("foo") | join("foo")</code> over any input string
+returns said input string.</p>
<div>
@@ -3727,15 +3667,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example54" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'join(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b,c,d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'join(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b,c,d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;a, b,c,d, e&quot;</td>
+ <td>&#34;a, b,c,d, e&#34;</td>
</tr>
</table>
@@ -3747,30 +3687,26 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="ascii_downcase,ascii_upcase">
<h3>
-
-<code>ascii_downcase</code>, <code>ascii_upcase</code>
-
+ <code>ascii_downcase</code>, <code>ascii_upcase</code>
</h3>
-
-<p>Emit a copy of the input string with its alphabetic characters (a-z and A-Z) converted to the specified case.</p>
-
+ <p>Emit a copy of the input string with its alphabetic characters (a-z and A-Z)
+converted to the specified case.</p>
</section>
<section id="while(cond;update)">
<h3>
-
-<code>while(cond; update)</code>
-
+ <code>while(cond; update)</code>
</h3>
-
-<p>The <code>while(cond; update)</code> function allows you to repeatedly apply an update to <code>.</code> until <code>cond</code> is false.</p>
-
-<p>Note that <code>while(cond; update)</code> is internally defined as a recursive jq function. Recursive calls within <code>while</code> will not consume additional memory if <code>update</code> produces at most one output for each input. See advanced topics below.</p>
-
+ <p>The <code>while(cond; update)</code> function allows you to repeatedly
+apply an update to <code>.</code> until <code>cond</code> is false.</p>
+<p>Note that <code>while(cond; update)</code> is internally defined as a
+recursive jq function. Recursive calls within <code>while</code> will
+not consume additional memory if <code>update</code> produces at most one
+output for each input. See advanced topics below.</p>
<div>
@@ -3802,16 +3738,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="until(cond;next)">
<h3>
-
-<code>until(cond; next)</code>
-
+ <code>until(cond; next)</code>
</h3>
-
-<p>The <code>until(cond; next)</code> function allows you to repeatedly apply the expression <code>next</code>, initially to <code>.</code> then to its own output, until <code>cond</code> is true. For example, this can be used to implement a factorial function (see below).</p>
-
-<p>Note that <code>until(cond; next)</code> is internally defined as a recursive jq function. Recursive calls within <code>until()</code> will not consume additional memory if <code>next</code> produces at most one output for each input. See advanced topics below.</p>
-
+ <p>The <code>until(cond; next)</code> function allows you to repeatedly
+apply the expression <code>next</code>, initially to <code>.</code> then to its own
+output, until <code>cond</code> is true. For example, this can be used
+to implement a factorial function (see below).</p>
+<p>Note that <code>until(cond; next)</code> is internally defined as a
+recursive jq function. Recursive calls within <code>until()</code> will
+not consume additional memory if <code>next</code> produces at most one
+output for each input. See advanced topics below.</p>
<div>
@@ -3843,36 +3780,41 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="recurse(f),recurse,recurse(f;condition),recurse_down">
<h3>
-
-<code>recurse(f)</code>, <code>recurse</code>, <code>recurse(f; condition)</code>, <code>recurse_down</code>
-
+ <code>recurse(f)</code>, <code>recurse</code>, <code>recurse(f; condition)</code>, <code>recurse_down</code>
</h3>
-
-<p>The <code>recurse(f)</code> function allows you to search through a recursive structure, and extract interesting data from all levels. Suppose your input represents a filesystem:</p>
-
-<pre><code>{&quot;name&quot;: &quot;/&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/bin&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/bin/ls&quot;, &quot;children&quot;: []},
- {&quot;name&quot;: &quot;/bin/sh&quot;, &quot;children&quot;: []}]},
- {&quot;name&quot;: &quot;/home&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/home/stephen&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/home/stephen/jq&quot;, &quot;children&quot;: []}]}]}]}</code></pre>
-
-<p>Now suppose you want to extract all of the filenames present. You need to retrieve <code>.name</code>, <code>.children[].name</code>, <code>.children[].children[].name</code>, and so on. You can do this with:</p>
-
-<pre><code>recurse(.children[]) | .name</code></pre>
-
-<p>When called without an argument, <code>recurse</code> is equivalent to <code>recurse(.[]?)</code>.</p>
-
-<p><code>recurse(f)</code> is identical to <code>recurse(f; . != null)</code> and can be used without concerns about recursion depth.</p>
-
-<p><code>recurse(f; condition)</code> is a generator which begins by emitting . and then emits in turn .|f, .|f|f, .|f|f|f, … so long as the computed value satisfies the condition. For example, to generate all the integers, at least in principle, one could write <code>recurse(.+1; true)</code>.</p>
-
-<p>For legacy reasons, <code>recurse_down</code> exists as an alias to calling <code>recurse</code> without arguments. This alias is considered <em>deprecated</em> and will be removed in the next major release.</p>
-
-<p>The recursive calls in <code>recurse</code> will not consume additional memory whenever <code>f</code> produces at most a single output for each input.</p>
-
+ <p>The <code>recurse(f)</code> function allows you to search through a
+recursive structure, and extract interesting data from all
+levels. Suppose your input represents a filesystem:</p>
+<pre><code>{"name": "/", "children": [
+ {"name": "/bin", "children": [
+ {"name": "/bin/ls", "children": []},
+ {"name": "/bin/sh", "children": []}]},
+ {"name": "/home", "children": [
+ {"name": "/home/stephen", "children": [
+ {"name": "/home/stephen/jq", "children": []}]}]}]}
+</code></pre>
+<p>Now suppose you want to extract all of the filenames
+present. You need to retrieve <code>.name</code>, <code>.children[].name</code>,
+<code>.children[].children[].name</code>, and so on. You can do this
+with:</p>
+<pre><code>recurse(.children[]) | .name
+</code></pre>
+<p>When called without an argument, <code>recurse</code> is equivalent to
+<code>recurse(.[]?)</code>.</p>
+<p><code>recurse(f)</code> is identical to <code>recurse(f; . != null)</code> and can be
+used without concerns about recursion depth.</p>
+<p><code>recurse(f; condition)</code> is a generator which begins by
+emitting . and then emits in turn .|f, .|f|f, .|f|f|f, ... so long
+as the computed value satisfies the condition. For example,
+to generate all the integers, at least in principle, one
+could write <code>recurse(.+1; true)</code>.</p>
+<p>For legacy reasons, <code>recurse_down</code> exists as an alias to
+calling <code>recurse</code> without arguments. This alias is considered
+<em>deprecated</em> and will be removed in the next major release.</p>
+<p>The recursive calls in <code>recurse</code> will not consume additional
+memory whenever <code>f</code> produces at most a single output for each
+input.</p>
<div>
@@ -3885,49 +3827,49 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'recurse(.foo[])'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;:[{&quot;foo&quot;: []}, {&quot;foo&quot;:[{&quot;foo&quot;:[]}]}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;:[{&#34;foo&#34;: []}, {&#34;foo&#34;:[{&#34;foo&#34;:[]}]}]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;:[{&quot;foo&quot;:[]},{&quot;foo&quot;:[{&quot;foo&quot;:[]}]}]}</td>
+ <td>{&#34;foo&#34;:[{&#34;foo&#34;:[]},{&#34;foo&#34;:[{&#34;foo&#34;:[]}]}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[]}</td>
+ <td>{&#34;foo&#34;:[]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[{&quot;foo&quot;:[]}]}</td>
+ <td>{&#34;foo&#34;:[{&#34;foo&#34;:[]}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[]}</td>
+ <td>{&#34;foo&#34;:[]}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'recurse'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:0,&quot;b&quot;:[1]}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:0,&#34;b&#34;:[1]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;:0,&quot;b&quot;:[1]}</td>
+ <td>{&#34;a&#34;:0,&#34;b&#34;:[1]}</td>
</tr>
<tr>
@@ -3988,14 +3930,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="..">
<h3>
-
-<code>..</code>
-
+ <code>..</code>
</h3>
-
-<p>Short-hand for <code>recurse</code> without arguments. This is intended to resemble the XPath <code>//</code> operator. Note that <code>..a</code> does not work; use <code>..|a</code> instead. In the example below we use <code>..|.a?</code> to find all the values of object keys “a” in any object found “below” <code>.</code>.</p>
-
+ <p>Short-hand for <code>recurse</code> without arguments. This is intended
+to resemble the XPath <code>//</code> operator. Note that <code>..a</code> does not
+work; use <code>..|a</code> instead. In the example below we use
+<code>..|.a?</code> to find all the values of object keys "a" in any
+object found "below" <code>.</code>.</p>
<div>
@@ -4008,7 +3950,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '..|.a?'</td></tr>
- <tr><th>Input</th><td>[[{&quot;a&quot;:1}]]</td></tr>
+ <tr><th>Input</th><td>[[{&#34;a&#34;:1}]]</td></tr>
<tr>
@@ -4027,14 +3969,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="env">
<h3>
-
-<code>env</code>
-
+ <code>env</code>
</h3>
-
-<p>Outputs an object representing jq’s environment.</p>
-
+ <p>Outputs an object representing jq's environment.</p>
<div>
@@ -4054,7 +3992,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;less&quot;</td>
+ <td>&#34;less&#34;</td>
</tr>
</table>
@@ -4066,14 +4004,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="transpose">
<h3>
-
-<code>transpose</code>
-
+ <code>transpose</code>
</h3>
-
-<p>Transpose a possibly jagged matrix (an array of arrays). Rows are padded with nulls so the result is always rectangular.</p>
-
+ <p>Transpose a possibly jagged matrix (an array of arrays).
+Rows are padded with nulls so the result is always rectangular.</p>
<div>
@@ -4105,14 +4040,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="bsearch(x)">
<h3>
-
-<code>bsearch(x)</code>
-
+ <code>bsearch(x)</code>
</h3>
-
-<p>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.</p>
-
+ <p>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.</p>
<div>
@@ -4172,14 +4110,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="Stringinterpolation-\(foo)">
<h3>
-
-String interpolation - <code>\(foo)</code>
-
+ String interpolation - <code>\(foo)</code>
</h3>
-
-<p>Inside a string, you can put an expression inside parens after a backslash. Whatever the expression returns will be interpolated into the string.</p>
-
+ <p>Inside a string, you can put an expression inside parens
+after a backslash. Whatever the expression returns will be
+interpolated into the string.</p>
<div>
@@ -4191,7 +4127,7 @@ String interpolation - <code>\(foo)</code>
<div id="example62" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '&quot;The input was \(.), which is one less than \(.+1)&quot;'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '&#34;The input was \(.), which is one less than \(.+1)&#34;'</td></tr>
<tr><th>Input</th><td>42</td></tr>
@@ -4199,7 +4135,7 @@ String interpolation - <code>\(foo)</code>
<th>Output</th>
- <td>&quot;The input was 42, which is one less than 43&quot;</td>
+ <td>&#34;The input was 42, which is one less than 43&#34;</td>
</tr>
</table>
@@ -4211,14 +4147,13 @@ String interpolation - <code>\(foo)</code>
<section id="Convertto/fromJSON">
<h3>
-
-Convert to/from JSON
-
+ Convert to/from JSON
</h3>
-
-<p>The <code>tojson</code> and <code>fromjson</code> 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.</p>
-
+ <p>The <code>tojson</code> and <code>fromjson</code> 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.</p>
<div>
@@ -4231,42 +4166,42 @@ Convert to/from JSON
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|tostring]'</td></tr>
- <tr><th>Input</th><td>[1, &quot;foo&quot;, [&quot;foo&quot;]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;foo&#34;, [&#34;foo&#34;]]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;1&quot;,&quot;foo&quot;,&quot;[\&quot;foo\&quot;]&quot;]</td>
+ <td>[&#34;1&#34;,&#34;foo&#34;,&#34;[\&#34;foo\&#34;]&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|tojson]'</td></tr>
- <tr><th>Input</th><td>[1, &quot;foo&quot;, [&quot;foo&quot;]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;foo&#34;, [&#34;foo&#34;]]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;1&quot;,&quot;\&quot;foo\&quot;&quot;,&quot;[\&quot;foo\&quot;]&quot;]</td>
+ <td>[&#34;1&#34;,&#34;\&#34;foo\&#34;&#34;,&#34;[\&#34;foo\&#34;]&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|tojson|fromjson]'</td></tr>
- <tr><th>Input</th><td>[1, &quot;foo&quot;, [&quot;foo&quot;]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;foo&#34;, [&#34;foo&#34;]]</td></tr>
<tr>
<th>Output</th>
- <td>[1,&quot;foo&quot;,[&quot;foo&quot;]]</td>
+ <td>[1,&#34;foo&#34;,[&#34;foo&#34;]]</td>
</tr>
</table>
@@ -4278,74 +4213,71 @@ Convert to/from JSON
<section id="Formatstringsandescaping">
<h3>
-
-Format strings and escaping
-
+ Format strings and escaping
</h3>
-
-<p>The <code>@foo</code> syntax is used to format and escape strings, which is useful for building URLs, documents in a language like HTML or XML, and so forth. <code>@foo</code> can be used as a filter on its own, the possible escapings are:</p>
-
+ <p>The <code>@foo</code> syntax is used to format and escape strings,
+which is useful for building URLs, documents in a language
+like HTML or XML, and so forth. <code>@foo</code> can be used as a
+filter on its own, the possible escapings are:</p>
<ul>
-<li>
-<p><code>@text</code>:</p>
-
+<li><code>@text</code>:</li>
+</ul>
<p>Calls <code>tostring</code>, see that function for details.</p>
-</li>
-
-<li>
-<p><code>@json</code>:</p>
-
+<ul>
+<li><code>@json</code>:</li>
+</ul>
<p>Serializes the input as JSON.</p>
-</li>
-
-<li>
-<p><code>@html</code>:</p>
-
-<p>Applies HTML/XML escaping, by mapping the characters <code>&lt;&gt;&amp;'&quot;</code> to their entity equivalents <code>&amp;lt;</code>, <code>&amp;gt;</code>, <code>&amp;amp;</code>, <code>&amp;apos;</code>, <code>&amp;quot;</code>.</p>
-</li>
-
-<li>
-<p><code>@uri</code>:</p>
-
-<p>Applies percent-encoding, by mapping all reserved URI characters to a <code>%XX</code> sequence.</p>
-</li>
-
-<li>
-<p><code>@csv</code>:</p>
-
-<p>The input must be an array, and it is rendered as CSV with double quotes for strings, and quotes escaped by repetition.</p>
-</li>
-
-<li>
-<p><code>@tsv</code>:</p>
-
-<p>The input must be an array, and it is rendered as TSV (tab-separated values). Each input array will be printed as a single line. Fields are separated by a single tab (ascii <code>0x09</code>). Input characters line-feed (ascii <code>0x0a</code>), carriage-return (ascii <code>0x0d</code>), tab (ascii <code>0x09</code>) and backslash (ascii <code>0x5c</code>) will be output as escape sequences <code>\n</code>, <code>\r</code>, <code>\t</code>, <code>\\</code> respectively.</p>
-</li>
-
-<li>
-<p><code>@sh</code>:</p>
-
-<p>The input is escaped suitable for use in a command-line for a POSIX shell. If the input is an array, the output will be a series of space-separated strings.</p>
-</li>
-
-<li>
-<p><code>@base64</code>:</p>
-
-<p>The input is converted to base64 as specified by RFC 4648.</p>
-</li>
+<ul>
+<li><code>@html</code>:</li>
</ul>
-
-<p>This syntax can be combined with string interpolation in a useful way. You can follow a <code>@foo</code> token with a string literal. The contents of the string literal will <em>not</em> be escaped. However, all interpolations made inside that string literal will be escaped. For instance,</p>
-
-<pre><code>@uri &quot;https://www.google.com/search?q=\(.search)&quot;</code></pre>
-
-<p>will produce the following output for the input <code>{&quot;search&quot;:&quot;what is jq?&quot;}</code>:</p>
-
-<pre><code>&quot;https://www.google.com/search?q=what%20is%20jq%3F&quot;</code></pre>
-
-<p>Note that the slashes, question mark, etc. in the URL are not escaped, as they were part of the string literal.</p>
-
+<p>Applies HTML/XML escaping, by mapping the characters
+ <code>&lt;&gt;&amp;'"</code> to their entity equivalents <code>&amp;lt;</code>, <code>&amp;gt;</code>,
+ <code>&amp;amp;</code>, <code>&amp;apos;</code>, <code>&amp;quot;</code>.</p>
+<ul>
+<li><code>@uri</code>:</li>
+</ul>
+<p>Applies percent-encoding, by mapping all reserved URI
+ characters to a <code>%XX</code> sequence.</p>
+<ul>
+<li><code>@csv</code>:</li>
+</ul>
+<p>The input must be an array, and it is rendered as CSV
+ with double quotes for strings, and quotes escaped by
+ repetition.</p>
+<ul>
+<li><code>@tsv</code>:</li>
+</ul>
+<p>The input must be an array, and it is rendered as TSV
+ (tab-separated values). Each input array will be printed as
+ a single line. Fields are separated by a single
+ tab (ascii <code>0x09</code>). Input characters line-feed (ascii <code>0x0a</code>),
+ carriage-return (ascii <code>0x0d</code>), tab (ascii <code>0x09</code>) and
+ backslash (ascii <code>0x5c</code>) will be output as escape sequences
+ <code>\n</code>, <code>\r</code>, <code>\t</code>, <code>\\</code> respectively.</p>
+<ul>
+<li><code>@sh</code>:</li>
+</ul>
+<p>The input is escaped suitable for use in a command-line
+ for a POSIX shell. If the input is an array, the output
+ will be a series of space-separated strings.</p>
+<ul>
+<li><code>@base64</code>:</li>
+</ul>
+<p>The input is converted to base64 as specified by RFC 4648.</p>
+<p>This syntax can be combined with string interpolation in a
+useful way. You can follow a <code>@foo</code> token with a string
+literal. The contents of the string literal will <em>not</em> be
+escaped. However, all interpolations made inside that string
+literal will be escaped. For instance,</p>
+<pre><code>@uri "https://www.google.com/search?q=\(.search)"
+</code></pre>
+<p>will produce the following output for the input
+<code>{"search":"what is jq?"}</code>:</p>
+<pre><code>"https://www.google.com/search?q=what%20is%20jq%3F"
+</code></pre>
+<p>Note that the slashes, question mark, etc. in the URL are
+not escaped, as they were part of the string literal.</p>
<div>
@@ -4358,28 +4290,28 @@ Format strings and escaping
<table>
<tr><th></th><td class="jqprogram">jq '@html'</td></tr>
- <tr><th>Input</th><td>&quot;This works if x &lt; y&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;This works if x &lt; y&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;This works if x &amp;lt; y&quot;</td>
+ <td>&#34;This works if x &amp;lt; y&#34;</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '@sh &quot;echo \(.)&quot;'</td></tr>
- <tr><th>Input</th><td>&quot;O'Hara's Ale&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq '@sh &#34;echo \(.)&#34;'</td></tr>
+ <tr><th>Input</th><td>&#34;O&#39;Hara&#39;s Ale&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;echo 'O'\\''Hara'\\''s Ale'&quot;</td>
+ <td>&#34;echo &#39;O&#39;\\&#39;&#39;Hara&#39;\\&#39;&#39;s Ale&#39;&#34;</td>
</tr>
</table>
@@ -4391,36 +4323,48 @@ Format strings and escaping
<section id="Dates">
<h3>
-
-Dates
-
+ Dates
</h3>
-
-<p>jq provides some basic date handling functionality, with some high-level and low-level builtins. In all cases these builtins deal exclusively with time in UTC.</p>
-
-<p>The <code>fromdateiso8601</code> builtin parses datetimes in the ISO 8601 format to a number of seconds since the Unix epoch (1970-01-01T00:00:00Z). The <code>todateiso8601</code> builtin does the inverse.</p>
-
-<p>The <code>fromdate</code> builtin parses datetime strings. Currently <code>fromdate</code> only supports ISO 8601 datetime strings, but in the future it will attempt to parse datetime strings in more formats.</p>
-
+ <p>jq provides some basic date handling functionality, with some
+high-level and low-level builtins. In all cases these
+builtins deal exclusively with time in UTC.</p>
+<p>The <code>fromdateiso8601</code> builtin parses datetimes in the ISO 8601
+format to a number of seconds since the Unix epoch
+(1970-01-01T00:00:00Z). The <code>todateiso8601</code> builtin does the
+inverse.</p>
+<p>The <code>fromdate</code> builtin parses datetime strings. Currently
+<code>fromdate</code> only supports ISO 8601 datetime strings, but in the
+future it will attempt to parse datetime strings in more
+formats.</p>
<p>The <code>todate</code> builtin is an alias for <code>todateiso8601</code>.</p>
-
-<p>The <code>now</code> builtin outputs the current time, in seconds since the Unix epoch.</p>
-
-<p>Low-level jq interfaces to the C-library time functions are also provided: <code>strptime</code>, <code>strftime</code>, <code>mktime</code>, and <code>gmtime</code>. Refer to your host operating system’s documentation for the format strings used by <code>strptime</code> and <code>strftime</code>. Note: these are not necessarily stable interfaces in jq, particularly as to their localization functionality.</p>
-
-<p>The <code>gmtime</code> builtin consumes a number of seconds since the Unix epoch and outputs a “broken down time” representation of time as an array of numbers representing (in this order): the year, the month (zero-based), the day of the month, the hour of the day, the minute of the hour, the second of the minute, the day of the week, and the day of the year – all one-based unless otherwise stated.</p>
-
-<p>The <code>mktime</code> builtin consumes “broken down time” representations of time output by <code>gmtime</code> and <code>strptime</code>.</p>
-
-<p>The <code>strptime(fmt)</code> builtin parses input strings matching the <code>fmt</code> argument. The output is in the “broken down time” representation consumed by <code>gmtime</code> and output by <code>mktime</code>.</p>
-
-<p>The <code>strftime(fmt)</code> builtin formats a time with the given format.</p>
-
-<p>The format strings for <code>strptime</code> and <code>strftime</code> are described in typical C library documentation. The format string for ISO 8601 datetime is <code>&quot;%Y-%m-%dT%H:%M:%SZ&quot;</code>.</p>
-
-<p>jq may not support some or all of this date functionality on some systems.</p>
-
+<p>The <code>now</code> builtin outputs the current time, in seconds since
+the Unix epoch.</p>
+<p>Low-level jq interfaces to the C-library time functions are
+also provided: <code>strptime</code>, <code>strftime</code>, <code>mktime</code>, and <code>gmtime</code>.
+Refer to your host operating system's documentation for the
+format strings used by <code>strptime</code> and <code>strftime</code>. Note: these
+are not necessarily stable interfaces in jq, particularly as
+to their localization functionality.</p>
+<p>The <code>gmtime</code> builtin consumes a number of seconds since the
+Unix epoch and outputs a "broken down time" representation of
+time as an array of numbers representing (in this order): the
+year, the month (zero-based), the day of the month, the hour
+of the day, the minute of the hour, the second of the minute,
+the day of the week, and the day of the year -- all one-based
+unless otherwise stated.</p>
+<p>The <code>mktime</code> builtin consumes "broken down time"
+representations of time output by <code>gmtime</code> and <code>strptime</code>.</p>
+<p>The <code>strptime(fmt)</code> builtin parses input strings matching the
+<code>fmt</code> argument. The output is in the "broken down time"
+representation consumed by <code>gmtime</code> and output by <code>mktime</code>.</p>
+<p>The <code>strftime(fmt)</code> builtin formats a time with the given
+format.</p>
+<p>The format strings for <code>strptime</code> and <code>strftime</code> are described
+in typical C library documentation. The format string for ISO
+8601 datetime is <code>"%Y-%m-%dT%H:%M:%SZ"</code>.</p>
+<p>jq may not support some or all of this date functionality on
+some systems.</p>
<div>
@@ -4433,7 +4377,7 @@ Dates
<table>
<tr><th></th><td class="jqprogram">jq 'fromdate'</td></tr>
- <tr><th>Input</th><td>&quot;2015-03-05T23:51:47Z&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;2015-03-05T23:51:47Z&#34;</td></tr>
<tr>
@@ -4446,8 +4390,8 @@ Dates
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'strptime(&quot;%Y-%m-%dT%H:%M:%SZ&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;2015-03-05T23:51:47Z&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'strptime(&#34;%Y-%m-%dT%H:%M:%SZ&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;2015-03-05T23:51:47Z&#34;</td></tr>
<tr>
@@ -4460,8 +4404,8 @@ Dates
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'strptime(&quot;%Y-%m-%dT%H:%M:%SZ&quot;)|mktime'</td></tr>
- <tr><th>Input</th><td>&quot;2015-03-05T23:51:47Z&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'strptime(&#34;%Y-%m-%dT%H:%M:%SZ&#34;)|mktime'</td></tr>
+ <tr><th>Input</th><td>&#34;2015-03-05T23:51:47Z&#34;</td></tr>
<tr>
@@ -4486,16 +4430,16 @@ Dates
<section id="==,!=">
<h3>
-
-<code>==</code>, <code>!=</code>
-
+ <code>==</code>, <code>!=</code>
</h3>
-
-<p>The expression ‘a == b’ will produce ‘true’ if the result of a and b are equal (that is, if they represent equivalent JSON documents) and ‘false’ otherwise. In particular, strings are never considered equal to numbers. If you’re coming from Javascript, jq’s == is like Javascript’s === - considering values equal only when they have the same type as well as the same value.</p>
-
-<p>!= is “not equal”, and ‘a != b’ returns the opposite value of ‘a == b’</p>
-
+ <p>The expression 'a == b' will produce 'true' if the result of a and b
+are equal (that is, if they represent equivalent JSON documents) and
+'false' otherwise. In particular, strings are never considered equal
+to numbers. If you're coming from Javascript, jq's == is like
+Javascript's === - considering values equal only when they have the
+same type as well as the same value.</p>
+<p>!= is "not equal", and 'a != b' returns the opposite value of 'a == b'</p>
<div>
@@ -4508,7 +4452,7 @@ Dates
<table>
<tr><th></th><td class="jqprogram">jq '.[] == 1'</td></tr>
- <tr><th>Input</th><td>[1, 1.0, &quot;1&quot;, &quot;banana&quot;]</td></tr>
+ <tr><th>Input</th><td>[1, 1.0, &#34;1&#34;, &#34;banana&#34;]</td></tr>
<tr>
@@ -4548,22 +4492,24 @@ Dates
<section id="if-then-else">
<h3>
-
-if-then-else
-
+ if-then-else
</h3>
-
-<p><code>if A then B else C end</code> will act the same as <code>B</code> if <code>A</code> produces a value other than false or null, but act the same as <code>C</code> otherwise.</p>
-
-<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 <code>if .name then A else B end</code>, you’ll need something more like <code>if (.name | length) &gt; 0 then A else
+ <p><code>if A then B else C end</code> will act the same as <code>B</code> if <code>A</code>
+produces a value other than false or null, but act the same
+as <code>C</code> otherwise.</p>
+<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 <code>if .name then A else B end</code>, you'll
+need something more like <code>if (.name | length) &gt; 0 then A else
B end</code> instead.</p>
-
-<p>If the condition <code>A</code> produces multiple results, then <code>B</code> is evaluated once for each result that is not false or null, and <code>C</code> is evaluated once for each false or null.</p>
-
+<p>If the condition <code>A</code> produces multiple results, then <code>B</code> is evaluated
+once for each result that is not false or null, and <code>C</code> is evaluated
+once for each false or null.</p>
<p>More cases can be added to an if using <code>elif A then B</code> syntax.</p>
-
<div>
@@ -4575,11 +4521,11 @@ B end</code> instead.</p>
<table>
<tr><th></th><td class="jqprogram">jq 'if . == 0 then
- &quot;zero&quot;
+ &#34;zero&#34;
elif . == 1 then
- &quot;one&quot;
+ &#34;one&#34;
else
- &quot;many&quot;
+ &#34;many&#34;
end'</td></tr>
<tr><th>Input</th><td>2</td></tr>
@@ -4588,7 +4534,7 @@ end'</td></tr>
<th>Output</th>
- <td>&quot;many&quot;</td>
+ <td>&#34;many&#34;</td>
</tr>
</table>
@@ -4598,19 +4544,17 @@ end'</td></tr>
</section>
- <section id=">,>=,<=,<">
+ <section id="&gt;,&gt;=,&lt;=,&lt;">
<h3>
-
-<code>&gt;, &gt;=, &lt;=, &lt;</code>
-
+ <code>&gt;, &gt;=, &lt;=, &lt;</code>
</h3>
-
-<p>The comparison operators <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;=</code>, <code>&lt;</code> 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).</p>
-
+ <p>The comparison operators <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;=</code>, <code>&lt;</code> 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).</p>
<p>The ordering is the same as that described for <code>sort</code>, above.</p>
-
<div>
@@ -4641,21 +4585,24 @@ end'</td></tr>
<section id="and/or/not">
<h3>
-
-and/or/not
-
+ and/or/not
</h3>
-
-<p>jq supports the normal Boolean operators and/or/not. They have the same standard of truth as if expressions - false and null are considered “false values”, and anything else is a “true value”.</p>
-
-<p>If an operand of one of these operators produces multiple results, the operator itself will produce a result for each input.</p>
-
-<p><code>not</code> is in fact a builtin function rather than an operator, so it is called as a filter to which things can be piped rather than with special syntax, as in <code>.foo and .bar |
+ <p>jq supports the normal Boolean operators and/or/not. They have the
+same standard of truth as if expressions - false and null are
+considered "false values", and anything else is a "true value".</p>
+<p>If an operand of one of these operators produces multiple
+results, the operator itself will produce a result for each input.</p>
+<p><code>not</code> is in fact a builtin function rather than an operator,
+so it is called as a filter to which things can be piped
+rather than with special syntax, as in <code>.foo and .bar |
not</code>.</p>
-
-<p>These three only produce the values “true” and “false”, and so are only useful for genuine Boolean operations, rather than the common Perl/Python/Ruby idiom of “value_that_may_be_null or default”. If you want to use this form of “or”, picking between two values rather than evaluating a condition, see the “//” operator below.</p>
-
+<p>These three only produce the values "true" and "false", and
+so are only useful for genuine Boolean operations, rather
+than the common Perl/Python/Ruby idiom of
+"value_that_may_be_null or default". If you want to use this
+form of "or", picking between two values rather than
+evaluating a condition, see the "//" operator below.</p>
<div>
@@ -4667,7 +4614,7 @@ not</code>.</p>
<div id="example69" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '42 and &quot;a string&quot;'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '42 and &#34;a string&#34;'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -4757,16 +4704,17 @@ not</code>.</p>
<section id="Alternativeoperator-//">
<h3>
-
-Alternative operator - <code>//</code>
-
+ Alternative operator - <code>//</code>
</h3>
-
-<p>A filter of the form <code>a // b</code> produces the same results as <code>a</code>, if <code>a</code> produces results other than <code>false</code> and <code>null</code>. Otherwise, <code>a // b</code> produces the same results as <code>b</code>.</p>
-
-<p>This is useful for providing defaults: <code>.foo // 1</code> will evaluate to <code>1</code> if there’s no <code>.foo</code> element in the input. It’s similar to how <code>or</code> is sometimes used in Python (jq’s <code>or</code> operator is reserved for strictly Boolean operations).</p>
-
+ <p>A filter of the form <code>a // b</code> produces the same
+results as <code>a</code>, if <code>a</code> produces results other than <code>false</code>
+and <code>null</code>. Otherwise, <code>a // b</code> produces the same results as <code>b</code>.</p>
+<p>This is useful for providing defaults: <code>.foo // 1</code> will
+evaluate to <code>1</code> if there's no <code>.foo</code> element in the
+input. It's similar to how <code>or</code> is sometimes used in Python
+(jq's <code>or</code> operator is reserved for strictly Boolean
+operations).</p>
<div>
@@ -4779,7 +4727,7 @@ Alternative operator - <code>//</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo // 42'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 19}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 19}</td></tr>
<tr>
@@ -4812,17 +4760,16 @@ Alternative operator - <code>//</code>
<section id="try-catch">
<h3>
-
-try-catch
-
+ try-catch
</h3>
-
-<p>Errors can be caught by using <code>try EXP catch EXP</code>. The first expression is executed, and if it fails then the second is executed with the error message. The output of the handler, if any, is output as if it had been the output of the expression to try.</p>
-
+ <p>Errors can be caught by using <code>try EXP catch EXP</code>. The first
+expression is executed, and if it fails then the second is
+executed with the error message. The output of the handler,
+if any, is output as if it had been the output of the
+expression to try.</p>
<p>The <code>try EXP</code> form uses <code>empty</code> as the exception handler.</p>
-
<div>
@@ -4833,7 +4780,7 @@ try-catch
<div id="example71" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'try .a catch &quot;. is not an object&quot;'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'try .a catch &#34;. is not an object&#34;'</td></tr>
<tr><th>Input</th><td>true</td></tr>
@@ -4841,14 +4788,14 @@ try-catch
<th>Output</th>
- <td>&quot;. is not an object&quot;</td>
+ <td>&#34;. is not an object&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|try .a]'</td></tr>
- <tr><th>Input</th><td>[{}, true, {&quot;a&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{}, true, {&#34;a&#34;:1}]</td></tr>
<tr>
@@ -4861,7 +4808,7 @@ try-catch
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'try error(&quot;some exception&quot;) catch .'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'try error(&#34;some exception&#34;) catch .'</td></tr>
<tr><th>Input</th><td>true</td></tr>
@@ -4869,7 +4816,7 @@ try-catch
<th>Output</th>
- <td>&quot;some exception&quot;</td>
+ <td>&#34;some exception&#34;</td>
</tr>
</table>
@@ -4881,53 +4828,42 @@ try-catch
<section id="Breakingoutofcontrolstructures">
<h3>
-
-Breaking out of control structures
-
+ Breaking out of control structures
</h3>
-
-<p>A convenient use of try/catch is to break out of control structures like <code>reduce</code>, <code>foreach</code>, <code>while</code>, and so on.</p>
-
+ <p>A convenient use of try/catch is to break out of control
+structures like <code>reduce</code>, <code>foreach</code>, <code>while</code>, and so on.</p>
<p>For example:</p>
-
-<pre><code># Repeat an expression until it raises &quot;break&quot; as an
+<pre><code># Repeat an expression until it raises "break" as an
# error, then stop repeating without re-raising the error.
-# But if the error caught is not &quot;break&quot; then re-raise it.
-try repeat(exp) catch .==&quot;break&quot; then empty else error;</code></pre>
-
-<p>jq has a syntax for named lexical labels to “break” or “go (back) to”:</p>
-
-<pre><code>label $out | ... break $out ...</code></pre>
-
-<p>The <code>break $label_name</code> expression will cause the program to to act as though the nearest (to the left) <code>label $label_name</code> produced <code>empty</code>.</p>
-
-<p>The relationship between the <code>break</code> and corresponding <code>label</code> is lexical: the label has to be “visible” from the break.</p>
-
+# But if the error caught is not "break" then re-raise it.
+try repeat(exp) catch .=="break" then empty else error;
+</code></pre>
+<p>jq has a syntax for named lexical labels to "break" or "go (back) to":</p>
+<pre><code>label $out | ... break $out ...
+</code></pre>
+<p>The <code>break $label_name</code> expression will cause the program to
+to act as though the nearest (to the left) <code>label $label_name</code>
+produced <code>empty</code>.</p>
+<p>The relationship between the <code>break</code> and corresponding <code>label</code>
+is lexical: the label has to be "visible" from the break.</p>
<p>To break out of a <code>reduce</code>, for example:</p>
-
-<pre><code>label $out | reduce .[] as $item (null; if .==false then break $out else ... end)</code></pre>
-
+<pre><code>label $out | reduce .[] as $item (null; if .==false then break $out else ... end)
+</code></pre>
<p>The following jq program produces a syntax error:</p>
-
-<pre><code>break $out</code></pre>
-
+<pre><code>break $out
+</code></pre>
<p>because no label <code>$out</code> is visible.</p>
-
</section>
<section id="?operator">
<h3>
-
-<code>?</code> operator
-
+ <code>?</code> operator
</h3>
-
-<p>The <code>?</code> operator, used as <code>EXP?</code>, is shorthand for <code>try EXP</code>.</p>
-
+ <p>The <code>?</code> operator, used as <code>EXP?</code>, is shorthand for <code>try EXP</code>.</p>
<div>
@@ -4940,7 +4876,7 @@ try repeat(exp) catch .==&quot;break&quot; then empty else error;</code></pre>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|(.a)?]'</td></tr>
- <tr><th>Input</th><td>[{}, true, {&quot;a&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{}, true, {&#34;a&#34;:1}]</td></tr>
<tr>
@@ -4961,71 +4897,48 @@ try repeat(exp) catch .==&quot;break&quot; then empty else error;</code></pre>
<section id="RegularexpressionsPCRE">
<h2>Regular expressions (PCRE)</h2>
-
-<p>jq uses the Oniguruma regular expression library, as do php, ruby, TextMate, Sublime Text, etc, so the description here will focus on jq specifics.</p>
-
-<p>The jq regex filters are defined so that they can be used using one of these patterns:</p>
-
+ <p>jq uses the Oniguruma regular expression library, as do php,
+ruby, TextMate, Sublime Text, etc, so the description here
+will focus on jq specifics.</p>
+<p>The jq regex filters are defined so that they can be used using
+one of these patterns:</p>
<pre><code>STRING | FILTER( REGEX )
STRING | FILTER( REGEX; FLAGS )
STRING | FILTER( [REGEX] )
-STRING | FILTER( [REGEX, FLAGS] )</code></pre>
-
-<p>where:</p>
-
-<ul>
-<li>STRING, REGEX and FLAGS are jq strings and subject to jq string interpolation;</li>
-
-<li>REGEX, after string interpolation, should be a valid PCRE regex;</li>
-
-<li>FILTER is one of <code>test</code>, <code>match</code>, or <code>capture</code>, as described below.</li>
-</ul>
-
+STRING | FILTER( [REGEX, FLAGS] )
+</code></pre>
+<p>where:
+<em> STRING, REGEX and FLAGS are jq strings and subject to jq string interpolation;
+</em> REGEX, after string interpolation, should be a valid PCRE regex;
+* FILTER is one of <code>test</code>, <code>match</code>, or <code>capture</code>, as described below.</p>
<p>FLAGS is a string consisting of one of more of the supported flags:</p>
-
<ul>
<li><code>g</code> - Global search (find all matches, not just the first)</li>
-
<li><code>i</code> - Case insensitive search</li>
-
-<li><code>m</code> - Multi line mode (‘.’ will match newlines)</li>
-
+<li><code>m</code> - Multi line mode ('.' will match newlines)</li>
<li><code>n</code> - Ignore empty matches</li>
-
<li><code>p</code> - Both s and m modes are enabled</li>
-
-<li><code>s</code> - Single line mode (‘^’ -&gt; ‘\A’, ‘$’ -&gt; ‘\Z’)</li>
-
+<li><code>s</code> - Single line mode ('^' -&gt; '\A', '$' -&gt; '\Z')</li>
<li><code>l</code> - Find longest possible matches</li>
-
<li><code>x</code> - Extended regex format (ignore whitespace and comments)</li>
</ul>
-
<p>To match whitespace in an x pattern use an escape such as \s, e.g.</p>
-
<ul>
-<li>test( “a\sb”, “x” ).</li>
+<li>test( "a\sb", "x" ).</li>
</ul>
-
<p>Note that certain flags may also be specified within REGEX, e.g.</p>
-
<ul>
-<li>jq -n ‘(“test”, “TEst”, “teST”, “TEST”) | test( “(?i)te(?-i)st” )’</li>
+<li>jq -n '("test", "TEst", "teST", "TEST") | test( "(?i)te(?-i)st" )'</li>
</ul>
-
<p>evaluates to: true, true, false, false.</p>
-
<section id="test(val),test(regex;flags)">
<h3>
-
-<code>test(val)</code>, <code>test(regex; flags)</code>
-
+ <code>test(val)</code>, <code>test(regex; flags)</code>
</h3>
-
-<p>Like <code>match</code>, but does not return match objects, only <code>true</code> or <code>false</code> for whether or not the regex matches the input.</p>
-
+ <p>Like <code>match</code>, but does not return match objects, only <code>true</code> or <code>false</code>
+for whether or not the regex matches the input.</p>
<div>
@@ -5037,8 +4950,8 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<div id="example73" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'test(&quot;foo&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foo&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'test(&#34;foo&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foo&#34;</td></tr>
<tr>
@@ -5051,8 +4964,8 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[] | test(&quot;a b c # spaces are ignored&quot;; &quot;ix&quot;)'</td></tr>
- <tr><th>Input</th><td>[&quot;xabcd&quot;, &quot;ABC&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[] | test(&#34;a b c # spaces are ignored&#34;; &#34;ix&#34;)'</td></tr>
+ <tr><th>Input</th><td>[&#34;xabcd&#34;, &#34;ABC&#34;]</td></tr>
<tr>
@@ -5078,39 +4991,26 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<section id="match(val),match(regex;flags)">
<h3>
-
-<code>match(val)</code>, <code>match(regex; flags)</code>
-
+ <code>match(val)</code>, <code>match(regex; flags)</code>
</h3>
-
-<p><strong>match</strong> outputs an object for each match it finds. Matches have the following fields:</p>
-
+ <p><strong>match</strong> outputs an object for each match it finds. Matches have
+the following fields:</p>
<ul>
<li><code>offset</code> - offset in UTF-8 codepoints from the beginning of the input</li>
-
<li><code>length</code> - length in UTF-8 codepoints of the match</li>
-
<li><code>string</code> - the string that it matched</li>
-
<li><code>captures</code> - an array of objects representing capturing groups.</li>
</ul>
-
<p>Capturing group objects have the following fields:</p>
-
<ul>
<li><code>offset</code> - offset in UTF-8 codepoints from the beginning of the input</li>
-
<li><code>length</code> - length in UTF-8 codepoints of this capturing group</li>
-
<li><code>string</code> - the string that was captured</li>
-
<li><code>name</code> - the name of the capturing group (or <code>null</code> if it was unnamed)</li>
</ul>
-
<p>Capturing groups that did not match anything return an offset of -1</p>
-
<div>
@@ -5121,85 +5021,85 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<div id="example74" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'match(&quot;(abc)+&quot;; &quot;g&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;abc abc&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'match(&#34;(abc)+&#34;; &#34;g&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;abc abc&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;offset&quot;: 0, &quot;length&quot;: 3, &quot;string&quot;: &quot;abc&quot;, &quot;captures&quot;: [{&quot;offset&quot;: 0, &quot;length&quot;: 3, &quot;string&quot;: &quot;abc&quot;, &quot;name&quot;: null}]}</td>
+ <td>{&#34;offset&#34;: 0, &#34;length&#34;: 3, &#34;string&#34;: &#34;abc&#34;, &#34;captures&#34;: [{&#34;offset&#34;: 0, &#34;length&#34;: 3, &#34;string&#34;: &#34;abc&#34;, &#34;name&#34;: null}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;offset&quot;: 4, &quot;length&quot;: 3, &quot;string&quot;: &quot;abc&quot;, &quot;captures&quot;: [{&quot;offset&quot;: 4, &quot;length&quot;: 3, &quot;string&quot;: &quot;abc&quot;, &quot;name&quot;: null}]}</td>
+ <td>{&#34;offset&#34;: 4, &#34;length&#34;: 3, &#34;string&#34;: &#34;abc&#34;, &#34;captures&#34;: [{&#34;offset&#34;: 4, &#34;length&#34;: 3, &#34;string&#34;: &#34;abc&#34;, &#34;name&#34;: null}]}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'match(&quot;foo&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foo bar foo&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'match(&#34;foo&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foo bar foo&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;offset&quot;: 0, &quot;length&quot;: 3, &quot;string&quot;: &quot;foo&quot;, &quot;captures&quot;: []}</td>
+ <td>{&#34;offset&#34;: 0, &#34;length&#34;: 3, &#34;string&#34;: &#34;foo&#34;, &#34;captures&#34;: []}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'match([&quot;foo&quot;, &quot;ig&quot;])'</td></tr>
- <tr><th>Input</th><td>&quot;foo bar FOO&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'match([&#34;foo&#34;, &#34;ig&#34;])'</td></tr>
+ <tr><th>Input</th><td>&#34;foo bar FOO&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;offset&quot;: 0, &quot;length&quot;: 3, &quot;string&quot;: &quot;foo&quot;, &quot;captures&quot;: []}</td>
+ <td>{&#34;offset&#34;: 0, &#34;length&#34;: 3, &#34;string&#34;: &#34;foo&#34;, &#34;captures&#34;: []}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;offset&quot;: 8, &quot;length&quot;: 3, &quot;string&quot;: &quot;FOO&quot;, &quot;captures&quot;: []}</td>
+ <td>{&#34;offset&#34;: 8, &#34;length&#34;: 3, &#34;string&#34;: &#34;FOO&#34;, &#34;captures&#34;: []}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'match(&quot;foo (?&lt;bar123&gt;bar)? foo&quot;; &quot;ig&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foo bar foo foo foo&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'match(&#34;foo (?&lt;bar123&gt;bar)? foo&#34;; &#34;ig&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foo bar foo foo foo&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;offset&quot;: 0, &quot;length&quot;: 11, &quot;string&quot;: &quot;foo bar foo&quot;, &quot;captures&quot;: [{&quot;offset&quot;: 4, &quot;length&quot;: 3, &quot;string&quot;: &quot;bar&quot;, &quot;name&quot;: &quot;bar123&quot;}]}</td>
+ <td>{&#34;offset&#34;: 0, &#34;length&#34;: 11, &#34;string&#34;: &#34;foo bar foo&#34;, &#34;captures&#34;: [{&#34;offset&#34;: 4, &#34;length&#34;: 3, &#34;string&#34;: &#34;bar&#34;, &#34;name&#34;: &#34;bar123&#34;}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;offset&quot;: 12, &quot;length&quot;: 8, &quot;string&quot;: &quot;foo foo&quot;, &quot;captures&quot;: [{&quot;offset&quot;: -1, &quot;length&quot;: 0, &quot;string&quot;: null, &quot;name&quot;: &quot;bar123&quot;}]}</td>
+ <td>{&#34;offset&#34;: 12, &#34;length&#34;: 8, &#34;string&#34;: &#34;foo foo&#34;, &#34;captures&#34;: [{&#34;offset&#34;: -1, &#34;length&#34;: 0, &#34;string&#34;: null, &#34;name&#34;: &#34;bar123&#34;}]}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '[ match(&quot;.&quot;; &quot;g&quot;)] | length'</td></tr>
- <tr><th>Input</th><td>&quot;abc&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[ match(&#34;.&#34;; &#34;g&#34;)] | length'</td></tr>
+ <tr><th>Input</th><td>&#34;abc&#34;</td></tr>
<tr>
@@ -5218,14 +5118,12 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<section id="capture(val),capture(regex;flags)">
<h3>
-
-<code>capture(val)</code>, <code>capture(regex; flags)</code>
-
+ <code>capture(val)</code>, <code>capture(regex; flags)</code>
</h3>
-
-<p>Collects the named captures in a JSON object, with the name of each capture as the key, and the matched string as the corresponding value.</p>
-
+ <p>Collects the named captures in a JSON object, with the name
+of each capture as the key, and the matched string as the
+corresponding value.</p>
<div>
@@ -5237,15 +5135,15 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<div id="example75" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'capture(&quot;(?&lt;a&gt;[a-z]+)-(?&lt;n&gt;[0-9]+)&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;xyzzy-14&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'capture(&#34;(?&lt;a&gt;[a-z]+)-(?&lt;n&gt;[0-9]+)&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;xyzzy-14&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{ &quot;a&quot;: &quot;xyzzy&quot;, &quot;n&quot;: &quot;14&quot; }</td>
+ <td>{ &#34;a&#34;: &#34;xyzzy&#34;, &#34;n&#34;: &#34;14&#34; }</td>
</tr>
</table>
@@ -5257,70 +5155,61 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<section id="scan(regex),scan(regex;flags)">
<h3>
-
-<code>scan(regex)</code>, <code>scan(regex; flags)</code>
-
+ <code>scan(regex)</code>, <code>scan(regex; flags)</code>
</h3>
-
-<p>Emit a stream of the non-overlapping substrings of the input that match the regex in accordance with the flags, if any have been specified. If there is no match, the stream is empty. To capture all the matches for each input string, use the idiom <code>[ expr ]</code>, e.g. <code>[ scan(regex) ]</code>.</p>
-
+ <p>Emit a stream of the non-overlapping substrings of the input
+that match the regex in accordance with the flags, if any
+have been specified. If there is no match, the stream is empty.
+To capture all the matches for each input string, use the idiom
+<code>[ expr ]</code>, e.g. <code>[ scan(regex) ]</code>.</p>
</section>
<section id="split(regex;flags)">
<h3>
-
-<code>split(regex; flags)</code>
-
+ <code>split(regex; flags)</code>
</h3>
-
-<p>For backwards compatibility, <code>split</code> splits on a string, not a regex.</p>
-
+ <p>For backwards compatibility, <code>split</code> splits on a string, not a regex.</p>
</section>
<section id="splits(regex),splits(regex;flags)">
<h3>
-
-<code>splits(regex)</code>, <code>splits(regex; flags)</code>
-
+ <code>splits(regex)</code>, <code>splits(regex; flags)</code>
</h3>
-
-<p>These provide the same results as their <code>split</code> counterparts, but as a stream instead of an array.</p>
-
+ <p>These provide the same results as their <code>split</code> counterparts,
+but as a stream instead of an array.</p>
</section>
<section id="sub(regex;tostring)sub(regex;string;flags)">
<h3>
-
-<code>sub(regex; tostring)</code> <code>sub(regex; string; flags)</code>
-
+ <code>sub(regex; tostring)</code> <code>sub(regex; string; flags)</code>
</h3>
-
-<p>Emit the string obtained by replacing the first match of regex in the input string with <code>tostring</code>, after interpolation. <code>tostring</code> 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 <code>capture</code>) to <code>tostring</code>, so a reference to a captured variable named “x” would take the form: “(.x)”.</p>
-
+ <p>Emit the string obtained by replacing the first match of regex in the
+input string with <code>tostring</code>, after interpolation. <code>tostring</code> 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 <code>capture</code>) to <code>tostring</code>, so a reference to a captured
+variable named "x" would take the form: "(.x)".</p>
</section>
<section id="gsub(regex;string),gsub(regex;string;flags)">
<h3>
-
-<code>gsub(regex; string)</code>, <code>gsub(regex; string; flags)</code>
-
+ <code>gsub(regex; string)</code>, <code>gsub(regex; string; flags)</code>
</h3>
-
-<p><code>gsub</code> is like <code>sub</code> but all the non-overlapping occurrences of the regex are replaced by the string, after interpolation.</p>
-
+ <p><code>gsub</code> is like <code>sub</code> but all the non-overlapping occurrences of the regex are
+replaced by the string, after interpolation.</p>
</section>
@@ -5329,79 +5218,100 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<section id="Advancedfeatures">
<h2>Advanced features</h2>
-
-<p>Variables are an absolute necessity in most programming languages, but they’re relegated to an “advanced feature” in jq.</p>
-
-<p>In most languages, variables are the only means of passing around data. If you calculate a value, and you want to use it more than once, you’ll need to store it in a variable. To pass a value to another part of the program, you’ll need that part of the program to define a variable (as a function parameter, object member, or whatever) in which to place the data.</p>
-
-<p>It is also possible to define functions in jq, although this is is a feature whose biggest use is defining jq’s standard library (many jq functions such as <code>map</code> and <code>find</code> are in fact written in jq).</p>
-
-<p>jq has reduction operators, which are very powerful but a bit tricky. Again, these are mostly used internally, to define some useful bits of jq’s standard library.</p>
-
-<p>It may not be obvious at first, but jq is all about generators (yes, as often found in other languages). Some utilities are provided to help deal with generators.</p>
-
-<p>Some minimal I/O support (besides reading JSON from standard input, and writing JSON to standard output) is available.</p>
-
+ <p>Variables are an absolute necessity in most programming languages, but
+they're relegated to an "advanced feature" in jq.</p>
+<p>In most languages, variables are the only means of passing around
+data. If you calculate a value, and you want to use it more than once,
+you'll need to store it in a variable. To pass a value to another part
+of the program, you'll need that part of the program to define a
+variable (as a function parameter, object member, or whatever) in
+which to place the data.</p>
+<p>It is also possible to define functions in jq, although this is
+is a feature whose biggest use is defining jq's standard library
+(many jq functions such as <code>map</code> and <code>find</code> are in fact written
+in jq).</p>
+<p>jq has reduction operators, which are very powerful but a bit
+tricky. Again, these are mostly used internally, to define some
+useful bits of jq's standard library.</p>
+<p>It may not be obvious at first, but jq is all about generators
+(yes, as often found in other languages). Some utilities are
+provided to help deal with generators.</p>
+<p>Some minimal I/O support (besides reading JSON from standard
+input, and writing JSON to standard output) is available.</p>
<p>Finally, there is a module/library system.</p>
-
<section id="Variables">
<h3>
-
-Variables
-
+ Variables
</h3>
-
-<p>In jq, all filters have an input and an output, so manual plumbing is not necessary to pass a value from one part of a program to the next. Many expressions, for instance <code>a + b</code>, pass their input to two distinct subexpressions (here <code>a</code> and <code>b</code> are both passed the same input), so variables aren’t usually necessary in order to use a value twice.</p>
-
-<p>For instance, calculating the average value of an array of numbers requires a few variables in most languages - at least one to hold the array, perhaps one for each element or for a loop counter. In jq, it’s simply <code>add / length</code> - the <code>add</code> expression is given the array and produces its sum, and the <code>length</code> expression is given the array and produces its length.</p>
-
-<p>So, there’s generally a cleaner way to solve most problems in jq than defining variables. Still, sometimes they do make things easier, so jq lets you define variables using <code>expression as $variable</code>. All variable names start with <code>$</code>. Here’s a slightly uglier version of the array-averaging example:</p>
-
-<pre><code>length as $array_length | add / $array_length</code></pre>
-
-<p>We’ll need a more complicated problem to find a situation where using variables actually makes our lives easier.</p>
-
-<p>Suppose we have an array of blog posts, with “author” and “title” fields, and another object which is used to map author usernames to real names. Our input looks like:</p>
-
-<pre><code>{&quot;posts&quot;: [{&quot;title&quot;: &quot;Frist psot&quot;, &quot;author&quot;: &quot;anon&quot;},
- {&quot;title&quot;: &quot;A well-written article&quot;, &quot;author&quot;: &quot;person1&quot;}],
- &quot;realnames&quot;: {&quot;anon&quot;: &quot;Anonymous Coward&quot;,
- &quot;person1&quot;: &quot;Person McPherson&quot;}}</code></pre>
-
-<p>We want to produce the posts with the author field containing a real name, as in:</p>
-
-<pre><code>{&quot;title&quot;: &quot;Frist psot&quot;, &quot;author&quot;: &quot;Anonymous Coward&quot;}
-{&quot;title&quot;: &quot;A well-written article&quot;, &quot;author&quot;: &quot;Person McPherson&quot;}</code></pre>
-
-<p>We use a variable, $names, to store the realnames object, so that we can refer to it later when looking up author usernames:</p>
-
-<pre><code>.realnames as $names | .posts[] | {title, author: $names[.author]}</code></pre>
-
-<p>The expression <code>exp as $x | ...</code> means: for each value of expression <code>exp</code>, run the rest of the pipeline with the entire original input, and with <code>$x</code> set to that value. Thus <code>as</code> functions as something of a foreach loop.</p>
-
-<p>Just as <code>{foo}</code> is a handy way of writing <code>{foo: .foo}</code>, so <code>{$foo}</code> is a handy way of writing <code>{foo:$foo}</code>.</p>
-
-<p>Multiple variables may be declared using a single <code>as</code> expression by providing a pattern that matches the structure of the input (this is known as “destructuring”):</p>
-
-<pre><code>. as {realnames: $names, posts: [$first, $second]} | ...</code></pre>
-
+ <p>In jq, all filters have an input and an output, so manual
+plumbing is not necessary to pass a value from one part of a program
+to the next. Many expressions, for instance <code>a + b</code>, pass their input
+to two distinct subexpressions (here <code>a</code> and <code>b</code> are both passed the
+same input), so variables aren't usually necessary in order to use a
+value twice.</p>
+<p>For instance, calculating the average value of an array of numbers
+requires a few variables in most languages - at least one to hold the
+array, perhaps one for each element or for a loop counter. In jq, it's
+simply <code>add / length</code> - the <code>add</code> expression is given the array and
+produces its sum, and the <code>length</code> expression is given the array and
+produces its length.</p>
+<p>So, there's generally a cleaner way to solve most problems in jq than
+defining variables. Still, sometimes they do make things easier, so jq
+lets you define variables using <code>expression as $variable</code>. All
+variable names start with <code>$</code>. Here's a slightly uglier version of the
+array-averaging example:</p>
+<pre><code>length as $array_length | add / $array_length
+</code></pre>
+<p>We'll need a more complicated problem to find a situation where using
+variables actually makes our lives easier.</p>
+<p>Suppose we have an array of blog posts, with "author" and "title"
+fields, and another object which is used to map author usernames to
+real names. Our input looks like:</p>
+<pre><code>{"posts": [{"title": "Frist psot", "author": "anon"},
+ {"title": "A well-written article", "author": "person1"}],
+ "realnames": {"anon": "Anonymous Coward",
+ "person1": "Person McPherson"}}
+</code></pre>
+<p>We want to produce the posts with the author field containing a real
+name, as in:</p>
+<pre><code>{"title": "Frist psot", "author": "Anonymous Coward"}
+{"title": "A well-written article", "author": "Person McPherson"}
+</code></pre>
+<p>We use a variable, $names, to store the realnames object, so that we
+can refer to it later when looking up author usernames:</p>
+<pre><code>.realnames as $names | .posts[] | {title, author: $names[.author]}
+</code></pre>
+<p>The expression <code>exp as $x | ...</code> means: for each value of expression
+<code>exp</code>, run the rest of the pipeline with the entire original input, and
+with <code>$x</code> set to that value. Thus <code>as</code> functions as something of a
+foreach loop.</p>
+<p>Just as <code>{foo}</code> is a handy way of writing <code>{foo: .foo}</code>, so
+<code>{$foo}</code> is a handy way of writing <code>{foo:$foo}</code>.</p>
+<p>Multiple variables may be declared using a single <code>as</code> expression by
+providing a pattern that matches the structure of the input
+(this is known as "destructuring"):</p>
+<pre><code>. as {realnames: $names, posts: [$first, $second]} | ...
+</code></pre>
<p>The variable declarations in array patterns (e.g., <code>. as
-[$first, $second]</code>) bind to the elements of the array in from the element at index zero on up, in order. When there is no value at the index for an array pattern element, <code>null</code> is bound to that variable.</p>
-
-<p>Variables are scoped over the rest of the expression that defines them, so</p>
-
-<pre><code>.realnames as $names | (.posts[] | {title, author: $names[.author]})</code></pre>
-
+[$first, $second]</code>) bind to the elements of the array in from
+the element at index zero on up, in order. When there is no
+value at the index for an array pattern element, <code>null</code> is
+bound to that variable.</p>
+<p>Variables are scoped over the rest of the expression that defines
+them, so</p>
+<pre><code>.realnames as $names | (.posts[] | {title, author: $names[.author]})
+</code></pre>
<p>will work, but</p>
-
-<pre><code>(.realnames as $names | .posts[]) | {title, author: $names[.author]}</code></pre>
-
-<p>won’t.</p>
-
-<p>For programming language theorists, it’s more accurate to say that jq variables are lexically-scoped bindings. In particular there’s no way to change the value of a binding; one can only setup a new binding with the same name, but which will not be visible where the old one was.</p>
-
+<pre><code>(.realnames as $names | .posts[]) | {title, author: $names[.author]}
+</code></pre>
+<p>won't.</p>
+<p>For programming language theorists, it's more accurate to
+say that jq variables are lexically-scoped bindings. In
+particular there's no way to change the value of a binding;
+one can only setup a new binding with the same name, but which
+will not be visible where the old one was.</p>
<div>
@@ -5414,7 +5324,7 @@ Variables
<table>
<tr><th></th><td class="jqprogram">jq '.bar as $x | .foo | . + $x'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;:10, &quot;bar&quot;:200}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;:10, &#34;bar&#34;:200}</td></tr>
<tr>
@@ -5442,7 +5352,7 @@ Variables
<table>
<tr><th></th><td class="jqprogram">jq '. as [$a, $b, {c: $c}] | $a + $b + $c'</td></tr>
- <tr><th>Input</th><td>[2, 3, {&quot;c&quot;: 4, &quot;d&quot;: 5}]</td></tr>
+ <tr><th>Input</th><td>[2, 3, {&#34;c&#34;: 4, &#34;d&#34;: 5}]</td></tr>
<tr>
@@ -5463,21 +5373,21 @@ Variables
<th>Output</th>
- <td>{&quot;a&quot;:0,&quot;b&quot;:null}</td>
+ <td>{&#34;a&#34;:0,&#34;b&#34;:null}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;a&quot;:0,&quot;b&quot;:1}</td>
+ <td>{&#34;a&#34;:0,&#34;b&#34;:1}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;a&quot;:2,&quot;b&quot;:1}</td>
+ <td>{&#34;a&#34;:2,&#34;b&#34;:1}</td>
</tr>
</table>
@@ -5489,39 +5399,44 @@ Variables
<section id="DefiningFunctions">
<h3>
-
-Defining Functions
-
+ Defining Functions
</h3>
-
-<p>You can give a filter a name using “def” syntax:</p>
-
-<pre><code>def increment: . + 1;</code></pre>
-
-<p>From then on, <code>increment</code> is usable as a filter just like a builtin function (in fact, this is how some of the builtins are defined). A function may take arguments:</p>
-
-<pre><code>def map(f): [.[] | f];</code></pre>
-
-<p>Arguments are passed as filters, not as values. The same argument may be referenced multiple times with different inputs (here <code>f</code> is run for each element of the input array). Arguments to a function work more like callbacks than like value arguments. This is important to understand. Consider:</p>
-
+ <p>You can give a filter a name using "def" syntax:</p>
+<pre><code>def increment: . + 1;
+</code></pre>
+<p>From then on, <code>increment</code> is usable as a filter just like a
+builtin function (in fact, this is how some of the builtins
+are defined). A function may take arguments:</p>
+<pre><code>def map(f): [.[] | f];
+</code></pre>
+<p>Arguments are passed as filters, not as values. The
+same argument may be referenced multiple times with
+different inputs (here <code>f</code> is run for each element of the
+input array). Arguments to a function work more like
+callbacks than like value arguments. This is important to
+understand. Consider:</p>
<pre><code>def foo(f): f|f;
-5|foo(.*2)</code></pre>
-
-<p>The result will be 20 because <code>f</code> is <code>.*2</code>, and during the first invocation of <code>f</code> <code>.</code> will be 5, and the second time it will be 10 (5 * 2), so the result will be 20. Function arguments are filters, and filters expect an input when invoked.</p>
-
-<p>If you want the value-argument behaviour for defining simple functions, you can just use a variable:</p>
-
-<pre><code>def addvalue(f): f as $f | map(. + $f);</code></pre>
-
+5|foo(.*2)
+</code></pre>
+<p>The result will be 20 because <code>f</code> is <code>.*2</code>, and during the
+first invocation of <code>f</code> <code>.</code> will be 5, and the second time it
+will be 10 (5 * 2), so the result will be 20. Function
+arguments are filters, and filters expect an input when
+invoked.</p>
+<p>If you want the value-argument behaviour for defining simple
+functions, you can just use a variable:</p>
+<pre><code>def addvalue(f): f as $f | map(. + $f);
+</code></pre>
<p>Or use the short-hand:</p>
-
-<pre><code>def addvalue($f): ...;</code></pre>
-
-<p>With either definition, <code>addvalue(.foo)</code> will add the current input’s <code>.foo</code> field to each element of the array.</p>
-
-<p>Multiple definitions using the same function name are allowed. Each re-definition replaces the previous one for the same number of function arguments, but only for references from functions (or main program) subsequent to the re-definition.</p>
-
+<pre><code>def addvalue($f): ...;
+</code></pre>
+<p>With either definition, <code>addvalue(.foo)</code> will add the current
+input's <code>.foo</code> field to each element of the array.</p>
+<p>Multiple definitions using the same function name are allowed.
+Each re-definition replaces the previous one for the same
+number of function arguments, but only for references from
+functions (or main program) subsequent to the re-definition.</p>
<div>
@@ -5567,22 +5482,22 @@ Defining Functions
<section id="Reduce">
<h3>
-
-Reduce
-
+ Reduce
</h3>
-
-<p>The <code>reduce</code> syntax in jq allows you to combine all of the results of an expression by accumulating them into a single answer. As an example, we’ll pass <code>[3,2,1]</code> to this expression:</p>
-
-<pre><code>reduce .[] as $item (0; . + $item)</code></pre>
-
-<p>For each result that <code>.[]</code> produces, <code>. + $item</code> is run to accumulate a running total, starting from 0. In this example, <code>.[]</code> produces the results 3, 2, and 1, so the effect is similar to running something like this:</p>
-
+ <p>The <code>reduce</code> syntax in jq allows you to combine all of the
+results of an expression by accumulating them into a single
+answer. As an example, we'll pass <code>[3,2,1]</code> to this expression:</p>
+<pre><code>reduce .[] as $item (0; . + $item)
+</code></pre>
+<p>For each result that <code>.[]</code> produces, <code>. + $item</code> is run to
+accumulate a running total, starting from 0. In this
+example, <code>.[]</code> produces the results 3, 2, and 1, so the
+effect is similar to running something like this:</p>
<pre><code>0 | (3 as $item | . + $item) |
(2 as $item | . + $item) |
- (1 as $item | . + $item)</code></pre>
-
+ (1 as $item | . + $item)
+</code></pre>
<div>
@@ -5614,14 +5529,10 @@ Reduce
<section id="limit(n;exp)">
<h3>
-
-<code>limit(n; exp)</code>
-
+ <code>limit(n; exp)</code>
</h3>
-
-<p>The <code>limit</code> function extracts up to <code>n</code> outputs from <code>exp</code>.</p>
-
+ <p>The <code>limit</code> function extracts up to <code>n</code> outputs from <code>exp</code>.</p>
<div>
@@ -5653,17 +5564,15 @@ Reduce
<section id="first(expr),last(expr),nth(n;expr)">
<h3>
-
-<code>first(expr)</code>, <code>last(expr)</code>, <code>nth(n; expr)</code>
-
+ <code>first(expr)</code>, <code>last(expr)</code>, <code>nth(n; expr)</code>
</h3>
-
-<p>The <code>first(expr)</code> and <code>last(expr)</code> functions extract the first and last values from <code>expr</code>, respectively.</p>
-
-<p>The <code>nth(n; expr)</code> function extracts the nth value output by <code>expr</code>. This can be defined as <code>def nth(n; expr):
-last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t support negative values of <code>n</code>.</p>
-
+ <p>The <code>first(expr)</code> and <code>last(expr)</code> functions extract the first
+and last values from <code>expr</code>, respectively.</p>
+<p>The <code>nth(n; expr)</code> function extracts the nth value output by
+<code>expr</code>. This can be defined as <code>def nth(n; expr):
+last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn't
+support negative values of <code>n</code>.</p>
<div>
@@ -5695,17 +5604,13 @@ last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t
<section id="first,last,nth(n)">
<h3>
-
-<code>first</code>, <code>last</code>, <code>nth(n)</code>
-
+ <code>first</code>, <code>last</code>, <code>nth(n)</code>
</h3>
-
-<p>The <code>first</code> and <code>last</code> functions extract the first and last values from any array at <code>.</code>.</p>
-
+ <p>The <code>first</code> and <code>last</code> functions extract the first
+and last values from any array at <code>.</code>.</p>
<p>The <code>nth(n)</code> function extracts the nth value of any array at <code>.</code>.</p>
-
<div>
@@ -5736,18 +5641,22 @@ last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t
<section id="foreach">
<h3>
-
-<code>foreach</code>
-
+ <code>foreach</code>
</h3>
-
-<p>The <code>foreach</code> syntax is similar to <code>reduce</code>, but intended to allow the construction of <code>limit</code> and reducers that produce intermediate results (see example).</p>
-
-<p>The form is <code>foreach EXP as $var (INIT; UPDATE; EXTRACT)</code>. Like <code>reduce</code>, <code>INIT</code> is evaluated once to produce a state value, then each output of <code>EXP</code> is bound to <code>$var</code>, <code>UPDATE</code> is evaluated for each output of <code>EXP</code> with the current state and with <code>$var</code> visible. Each value output by <code>UPDATE</code> replaces the previous state. Finally, <code>EXTRACT</code> is evaluated for each new state to extract an output of <code>foreach</code>.</p>
-
-<p>This is mostly useful only for constructing <code>reduce</code>- and <code>limit</code>-like functions. But it is much more general, as it allows for partial reductions (see the example below).</p>
-
+ <p>The <code>foreach</code> syntax is similar to <code>reduce</code>, but intended to
+allow the construction of <code>limit</code> and reducers that produce
+intermediate results (see example).</p>
+<p>The form is <code>foreach EXP as $var (INIT; UPDATE; EXTRACT)</code>.
+Like <code>reduce</code>, <code>INIT</code> is evaluated once to produce a state
+value, then each output of <code>EXP</code> is bound to <code>$var</code>, <code>UPDATE</code>
+is evaluated for each output of <code>EXP</code> with the current state
+and with <code>$var</code> visible. Each value output by <code>UPDATE</code>
+replaces the previous state. Finally, <code>EXTRACT</code> is evaluated
+for each new state to extract an output of <code>foreach</code>.</p>
+<p>This is mostly useful only for constructing <code>reduce</code>- and
+<code>limit</code>-like functions. But it is much more general, as it
+allows for partial reductions (see the example below).</p>
<div>
@@ -5760,14 +5669,14 @@ last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t
<table>
<tr><th></th><td class="jqprogram">jq '[foreach .[] as $item ([[],[]]; if $item == null then [[],.[0]] else [(.[0] + [$item]),[]] end; if $item == null then .[1] else empty end)]'</td></tr>
- <tr><th>Input</th><td>[1,2,3,4,null,&quot;a&quot;,&quot;b&quot;,null]</td></tr>
+ <tr><th>Input</th><td>[1,2,3,4,null,&#34;a&#34;,&#34;b&#34;,null]</td></tr>
<tr>
<th>Output</th>
- <td>[[1,2,3,4],[&quot;a&quot;,&quot;b&quot;]]</td>
+ <td>[[1,2,3,4],[&#34;a&#34;,&#34;b&#34;]]</td>
</tr>
</table>
@@ -5779,18 +5688,17 @@ last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t
<section id="Recursion">
<h3>
-
-Recursion
-
+ Recursion
</h3>
-
-<p>As described above, <code>recurse</code> uses recursion, and any jq function can be recursive. The <code>while</code> builtin is also implemented in terms of recursion.</p>
-
-<p>Tail calls are optimized whenever the expression to the left of the recursive call outputs its last value. In practice this means that the expression to the left of the recursive call should not produce more than one output for each input.</p>
-
+ <p>As described above, <code>recurse</code> uses recursion, and any jq
+function can be recursive. The <code>while</code> builtin is also
+implemented in terms of recursion.</p>
+<p>Tail calls are optimized whenever the expression to the left of
+the recursive call outputs its last value. In practice this
+means that the expression to the left of the recursive call
+should not produce more than one output for each input.</p>
<p>For example:</p>
-
<pre><code>def recurse(f): def r: ., (f | select(. != null) | r); r;
def while(cond; update):
@@ -5801,28 +5709,39 @@ def while(cond; update):
def repeat(exp):
def _repeat:
exp, _repeat;
- _repeat;</code></pre>
-
+ _repeat;
+</code></pre>
</section>
<section id="Generatorsanditerators">
<h3>
-
-Generators and iterators
-
+ Generators and iterators
</h3>
-
-<p>Some jq operators and functions are actually generators in that they can produce zero, one, or more values for each input, just as one might expect in other programming languages that have generators. For example, <code>.[]</code> generates all the values in its input (which must be an array or an object), <code>range(0; 10)</code> generates the integers between 0 and 10, and so on.</p>
-
-<p>Even the comma operator is a generator, generating first the values generated by the expression to the left of the comma, then for each of those, the values generate by the expression on the right of the comma.</p>
-
-<p>The <code>empty</code> builtin is the generator that produces zero outputs. The <code>empty</code> builtin backtracks to the preceding generator expression.</p>
-
-<p>All jq functions can be generators just by using builtin generators. It is also possible to define new generators using only recursion and the comma operator. If the recursive call(s) is(are) “in tail position” then the generator will be efficient. In the example below the recursive call by <code>_range</code> to itself is in tail position. The example shows off three advanced topics: tail recursion, generator construction, and sub-functions.</p>
-
+ <p>Some jq operators and functions are actually generators in
+that they can produce zero, one, or more values for each
+input, just as one might expect in other programming
+languages that have generators. For example, <code>.[]</code>
+generates all the values in its input (which must be an
+array or an object), <code>range(0; 10)</code> generates the integers
+between 0 and 10, and so on.</p>
+<p>Even the comma operator is a generator, generating first the
+values generated by the expression to the left of the comma,
+then for each of those, the values generate by the
+expression on the right of the comma.</p>
+<p>The <code>empty</code> builtin is the generator that produces zero
+outputs. The <code>empty</code> builtin backtracks to the preceding
+generator expression.</p>
+<p>All jq functions can be generators just by using builtin
+generators. It is also possible to define new generators
+using only recursion and the comma operator. If the
+recursive call(s) is(are) "in tail position" then the
+generator will be efficient. In the example below the
+recursive call by <code>_range</code> to itself is in tail position.
+The example shows off three advanced topics: tail recursion,
+generator construction, and sub-functions.</p>
<div>
@@ -5891,92 +5810,88 @@ Generators and iterators
<section id="Math">
<h2>Math</h2>
-
-<p>jq currently only has IEEE754 double-precision (64-bit) floating point number support.</p>
-
-<p>Besides simple arithmetic operators such as <code>+</code>, jq also has most standard math functions from the C math library. C math functions that take a single input argument (e.g., <code>sin()</code>) are available as zero-argument jq functions. C math functions that take two input arguments (e.g., <code>pow()</code>) are available as two-argument jq functions that ignore <code>.</code>.</p>
-
-<p>Availability of standard math functions depends on the availability of the corresponding math functions in your operating system and C math library. Unavailable math functions will be defined but will raise an error.</p>
-
+ <p>jq currently only has IEEE754 double-precision (64-bit) floating
+point number support.</p>
+<p>Besides simple arithmetic operators such as <code>+</code>, jq also has most
+standard math functions from the C math library. C math functions
+that take a single input argument (e.g., <code>sin()</code>) are available as
+zero-argument jq functions. C math functions that take two input
+arguments (e.g., <code>pow()</code>) are available as two-argument jq
+functions that ignore <code>.</code>.</p>
+<p>Availability of standard math functions depends on the
+availability of the corresponding math functions in your operating
+system and C math library. Unavailable math functions will be
+defined but will raise an error.</p>
</section>
<section id="IO">
<h2>I/O</h2>
-
-<p>At this time jq has minimal support for I/O, mostly in the form of control over when inputs are read. Two builtins functions are provided for this, <code>input</code> and <code>inputs</code>, that read from the same sources (e.g., <code>stdin</code>, files named on the command-line) as jq itself. These two builtins, and jq’s own reading actions, can be interleaved with each other.</p>
-
-<p>One builtin provides minimal output capabilities, <code>debug</code>. (Recall that a jq program’s output values are always output as JSON texts on <code>stdout</code>.) The <code>debug</code> builtin can have application-specific behavior, such as for executables that use the libjq C API but aren’t the jq executable itself.</p>
-
+ <p>At this time jq has minimal support for I/O, mostly in the
+form of control over when inputs are read. Two builtins functions
+are provided for this, <code>input</code> and <code>inputs</code>, that read from the
+same sources (e.g., <code>stdin</code>, files named on the command-line) as
+jq itself. These two builtins, and jq's own reading actions, can
+be interleaved with each other.</p>
+<p>One builtin provides minimal output capabilities, <code>debug</code>.
+(Recall that a jq program's output values are always output as
+JSON texts on <code>stdout</code>.) The <code>debug</code> builtin can have
+application-specific behavior, such as for executables that use
+the libjq C API but aren't the jq executable itself.</p>
<section id="input">
<h3>
-
-<code>input</code>
-
+ <code>input</code>
</h3>
-
-<p>Outputs one new input.</p>
-
+ <p>Outputs one new input.</p>
</section>
<section id="inputs">
<h3>
-
-<code>inputs</code>
-
+ <code>inputs</code>
</h3>
-
-<p>Outputs all remaining inputs, one by one.</p>
-
-<p>This is primarily useful for reductions over a program’s inputs.</p>
-
+ <p>Outputs all remaining inputs, one by one.</p>
+<p>This is primarily useful for reductions over a program's
+inputs.</p>
</section>
<section id="debug">
<h3>
-
-<code>debug</code>
-
+ <code>debug</code>
</h3>
-
-<p>Causes a debug message based on the input value to be produced. The jq executable wraps the input value with <code>[&quot;DEBUG:&quot;, &lt;input-value&gt;]</code> and prints that and a newline on stderr, compactly. This may change in the future.</p>
-
+ <p>Causes a debug message based on the input value to be
+produced. The jq executable wraps the input value with
+<code>["DEBUG:", &lt;input-value&gt;]</code> and prints that and a newline on
+stderr, compactly. This may change in the future.</p>
</section>
<section id="input_filename">
<h3>
-
-<code>input_filename</code>
-
+ <code>input_filename</code>
</h3>
-
-<p>Returns the name of the file whose input is currently being filtered. Note that this will not work well unless jq is running in a UTF-8 locale.</p>
-
+ <p>Returns the name of the file whose input is currently being
+filtered. Note that this will not work well unless jq is
+running in a UTF-8 locale.</p>
</section>
<section id="input_line_number">
<h3>
-
-<code>input_line_number</code>
-
+ <code>input_line_number</code>
</h3>
-
-<p>Returns the line number of the input currently being filtered.</p>
-
+ <p>Returns the line number of the input currently being filtered.</p>
</section>
@@ -5985,28 +5900,30 @@ Generators and iterators
<section id="Streaming">
<h2>Streaming</h2>
-
-<p>With the <code>--stream</code> option jq can parse input texts in a streaming fashion, allowing jq programs to start processing large JSON texts immediately rather than after the parse completes. If you have a single JSON text that is 1GB in size, streaming it will allow you to process it much more quickly.</p>
-
-<p>However, streaming isn’t easy to deal with as the jq program will have <code>[&lt;path&gt;, &lt;leaf-value&gt;]</code> (and a few other forms) as inputs.</p>
-
+ <p>With the <code>--stream</code> option jq can parse input texts in a streaming
+fashion, allowing jq programs to start processing large JSON texts
+immediately rather than after the parse completes. If you have a
+single JSON text that is 1GB in size, streaming it will allow you
+to process it much more quickly.</p>
+<p>However, streaming isn't easy to deal with as the jq program will
+have <code>[&lt;path&gt;, &lt;leaf-value&gt;]</code> (and a few other forms) as inputs.</p>
<p>Several builtins are provided to make handling streams easier.</p>
-
-<p>The examples below use the streamed form of <code>[0,[1]]</code>, which is <code>[[0],0],[[1,0],1],[[1,0]],[[1]]</code>.</p>
-
-<p>Streaming forms include <code>[&lt;path&gt;, &lt;leaf-value&gt;]</code> (to indicate any scalar value, empty array, or empty object), and <code>[&lt;path&gt;]</code> (to indicate the end of an array or object). Future versions of jq run with <code>--stream</code> and <code>-seq</code> may output additional forms such as <code>[&quot;error message&quot;]</code> when an input text fails to parse.</p>
-
+<p>The examples below use the streamed form of <code>[0,[1]]</code>, which
+is <code>[[0],0],[[1,0],1],[[1,0]],[[1]]</code>.</p>
+<p>Streaming forms include <code>[&lt;path&gt;, &lt;leaf-value&gt;]</code> (to indicate any
+scalar value, empty array, or empty object), and <code>[&lt;path&gt;]</code> (to
+indicate the end of an array or object). Future versions of jq
+run with <code>--stream</code> and <code>-seq</code> may output additional forms such as
+<code>["error message"]</code> when an input text fails to parse.</p>
<section id="truncate_stream(stream_expression)">
<h3>
-
-<code>truncate_stream(stream_expression)</code>
-
+ <code>truncate_stream(stream_expression)</code>
</h3>
-
-<p>Consumes a number as input and truncates the corresponding number of path elements from the left of the outputs of the given streaming expression.</p>
-
+ <p>Consumes a number as input and truncates the corresponding
+number of path elements from the left of the outputs of the
+given streaming expression.</p>
<div>
@@ -6038,14 +5955,11 @@ Generators and iterators
<section id="fromstream(stream_expression)">
<h3>
-
-<code>fromstream(stream_expression)</code>
-
+ <code>fromstream(stream_expression)</code>
</h3>
-
-<p>Outputs values corresponding to the stream expression’s outputs.</p>
-
+ <p>Outputs values corresponding to the stream expression's
+outputs.</p>
<div>
@@ -6077,14 +5991,10 @@ Generators and iterators
<section id="tostream">
<h3>
-
-<code>tostream</code>
-
+ <code>tostream</code>
</h3>
-
-<p>The <code>tostream</code> builtin outputs the streamed form of its input.</p>
-
+ <p>The <code>tostream</code> builtin outputs the streamed form of its input.</p>
<div>
@@ -6097,7 +6007,7 @@ Generators and iterators
<table>
<tr><th></th><td class="jqprogram">jq '. as $dot|fromstream($dot|tostream)|.==$dot'</td></tr>
- <tr><th>Input</th><td>[0,[1,{&quot;a&quot;:1},{&quot;b&quot;:2}]]</td></tr>
+ <tr><th>Input</th><td>[0,[1,{&#34;a&#34;:1},{&#34;b&#34;:2}]]</td></tr>
<tr>
@@ -6118,66 +6028,84 @@ Generators and iterators
<section id="Assignment">
<h2>Assignment</h2>
-
-<p>Assignment works a little differently in jq than in most programming languages. jq doesn’t distinguish between references to and copies of something - two objects or arrays are either equal or not equal, without any further notion of being “the same object” or “not the same object”.</p>
-
-<p>If an object has two fields which are arrays, <code>.foo</code> and <code>.bar</code>, and you append something to <code>.foo</code>, then <code>.bar</code> will not get bigger. Even if you’ve just set <code>.bar = .foo</code>. If you’re used to programming in languages like Python, Java, Ruby, Javascript, etc. then you can think of it as though jq does a full deep copy of every object before it does the assignment (for performance, it doesn’t actually do that, but that’s the general idea).</p>
-
-<p>All the assignment operators in jq have path expressions on the left-hand side.</p>
-
+ <p>Assignment works a little differently in jq than in most
+programming languages. jq doesn't distinguish between references
+to and copies of something - two objects or arrays are either
+equal or not equal, without any further notion of being "the
+same object" or "not the same object".</p>
+<p>If an object has two fields which are arrays, <code>.foo</code> and <code>.bar</code>,
+and you append something to <code>.foo</code>, then <code>.bar</code> will not get
+bigger. Even if you've just set <code>.bar = .foo</code>. If you're used to
+programming in languages like Python, Java, Ruby, Javascript,
+etc. then you can think of it as though jq does a full deep copy
+of every object before it does the assignment (for performance,
+it doesn't actually do that, but that's the general idea).</p>
+<p>All the assignment operators in jq have path expressions on the
+left-hand side.</p>
<section id="=">
<h3>
-
-<code>=</code>
-
+ <code>=</code>
</h3>
-
-<p>The filter <code>.foo = 1</code> will take as input an object and produce as output an object with the “foo” field set to 1. There is no notion of “modifying” or “changing” something in jq - all jq values are immutable. For instance,</p>
-
+ <p>The filter <code>.foo = 1</code> will take as input an object
+and produce as output an object with the "foo" field set to
+1. There is no notion of "modifying" or "changing" something
+in jq - all jq values are immutable. For instance,</p>
<p>.foo = .bar | .foo.baz = 1</p>
-
-<p>will not have the side-effect of setting .bar.baz to be set to 1, as the similar-looking program in Javascript, Python, Ruby or other languages would. Unlike these languages (but like Haskell and some other functional languages), there is no notion of two arrays or objects being “the same array” or “the same object”. They can be equal, or not equal, but if we change one of them in no circumstances will the other change behind our backs.</p>
-
-<p>This means that it’s impossible to build circular values in jq (such as an array whose first element is itself). This is quite intentional, and ensures that anything a jq program can produce can be represented in JSON.</p>
-
-<p>Note that the left-hand side of ‘=’ refers to a value in <code>.</code>. Thus <code>$var.foo = 1</code> won’t work as expected (<code>$var.foo</code> is not a valid or useful path expression in <code>.</code>); use <code>$var | .foo =
+<p>will not have the side-effect of setting .bar.baz to be set
+to 1, as the similar-looking program in Javascript, Python,
+Ruby or other languages would. Unlike these languages (but
+like Haskell and some other functional languages), there is
+no notion of two arrays or objects being "the same array" or
+"the same object". They can be equal, or not equal, but if
+we change one of them in no circumstances will the other
+change behind our backs.</p>
+<p>This means that it's impossible to build circular values in
+jq (such as an array whose first element is itself). This is
+quite intentional, and ensures that anything a jq program
+can produce can be represented in JSON.</p>
+<p>Note that the left-hand side of '=' refers to a value in <code>.</code>.
+Thus <code>$var.foo = 1</code> won't work as expected (<code>$var.foo</code> is not
+a valid or useful path expression in <code>.</code>); use <code>$var | .foo =
1</code> instead.</p>
-
-<p>If the right-hand side of ‘=’ produces multiple values, then for each such value jq will set the paths on the left-hand side to the value and then it will output the modified <code>.</code>. For example, <code>(.a,.b)=range(2)</code> outputs <code>{&quot;a&quot;:0,&quot;b&quot;:0}</code>, then <code>{&quot;a&quot;:1,&quot;b&quot;:1}</code>. The “update” assignment forms (see below) do not do this.</p>
-
-<p>Note too that <code>.a,.b=0</code> does not set <code>.a</code> and <code>.b</code>, but <code>(.a,.b)=0</code> sets both.</p>
-
+<p>If the right-hand side of '=' produces multiple values, then
+for each such value jq will set the paths on the left-hand
+side to the value and then it will output the modified <code>.</code>.
+For example, <code>(.a,.b)=range(2)</code> outputs <code>{"a":0,"b":0}</code>, then
+<code>{"a":1,"b":1}</code>. The "update" assignment forms (see below) do
+not do this.</p>
+<p>Note too that <code>.a,.b=0</code> does not set <code>.a</code> and <code>.b</code>, but
+<code>(.a,.b)=0</code> sets both.</p>
</section>
<section id="|=">
<h3>
-
-<code>|=</code>
-
+ <code>|=</code>
</h3>
-
-<p>As well as the assignment operator ‘=’, jq provides the “update” operator ‘|=’, which takes a filter on the right-hand side and works out the new value for the property of <code>.</code> being assigned to by running the old value through this expression. For instance, .foo |= .+1 will build an object with the “foo” field set to the input’s “foo” plus 1.</p>
-
-<p>This example should show the difference between ‘=’ and ‘|=’:</p>
-
-<p>Provide input ‘{“a”: {“b”: 10}, “b”: 20}’ to the programs:</p>
-
-<p>.a = .b .a |= .b</p>
-
-<p>The former will set the “a” field of the input to the “b” field of the input, and produce the output {“a”: 20}. The latter will set the “a” field of the input to the “a” field’s “b” field, producing {“a”: 10}.</p>
-
+ <p>As well as the assignment operator '=', jq provides the "update"
+operator '|=', which takes a filter on the right-hand side and
+works out the new value for the property of <code>.</code> being assigned
+to by running the old value through this expression. For
+instance, .foo |= .+1 will build an object with the "foo"
+field set to the input's "foo" plus 1.</p>
+<p>This example should show the difference between '=' and '|=':</p>
+<p>Provide input '{"a": {"b": 10}, "b": 20}' to the programs:</p>
+<p>.a = .b
+.a |= .b</p>
+<p>The former will set the "a" field of the input to the "b" field of the
+input, and produce the output {"a": 20}. The latter will set the "a"
+field of the input to the "a" field's "b" field, producing {"a": 10}.</p>
<p>The left-hand side can be any general path expression; see <code>path()</code>.</p>
-
-<p>Note that the left-hand side of ‘|=’ refers to a value in <code>.</code>. Thus <code>$var.foo |= . + 1</code> won’t work as expected (<code>$var.foo</code> is not a valid or useful path expression in <code>.</code>); use <code>$var |
+<p>Note that the left-hand side of '|=' refers to a value in <code>.</code>.
+Thus <code>$var.foo |= . + 1</code> won't work as expected (<code>$var.foo</code> is
+not a valid or useful path expression in <code>.</code>); use <code>$var |
.foo |= . + 1</code> instead.</p>
-
-<p>If the right-hand side outputs multiple values, only the last one will be used.</p>
-
+<p>If the right-hand side outputs multiple values, only the last
+one will be used.</p>
<div>
@@ -6189,7 +6117,7 @@ Generators and iterators
<div id="example87" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '(..|select(type==&quot;boolean&quot;)) |= if . then 1 else 0 end'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '(..|select(type==&#34;boolean&#34;)) |= if . then 1 else 0 end'</td></tr>
<tr><th>Input</th><td>[true,false,[5,true,[true,[false]],false]]</td></tr>
@@ -6209,14 +6137,11 @@ Generators and iterators
<section id="+=,-=,*=,/=,%=,//=">
<h3>
-
-<code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>, <code>%=</code>, <code>//=</code>
-
+ <code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>, <code>%=</code>, <code>//=</code>
</h3>
-
-<p>jq has a few operators of the form <code>a op= b</code>, which are all equivalent to <code>a |= . op b</code>. So, <code>+= 1</code> can be used to increment values.</p>
-
+ <p>jq has a few operators of the form <code>a op= b</code>, which are all
+equivalent to <code>a |= . op b</code>. So, <code>+= 1</code> can be used to increment values.</p>
<div>
@@ -6229,14 +6154,14 @@ Generators and iterators
<table>
<tr><th></th><td class="jqprogram">jq '.foo += 1'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;: 43}</td>
+ <td>{&#34;foo&#34;: 43}</td>
</tr>
</table>
@@ -6248,33 +6173,41 @@ Generators and iterators
<section id="Complexassignments">
<h3>
-
-Complex assignments
-
+ Complex assignments
</h3>
-
-<p>Lots more things are allowed on the left-hand side of a jq assignment than in most languages. We’ve already seen simple field accesses on the left hand side, and it’s no surprise that array accesses work just as well:</p>
-
-<pre><code>.posts[0].title = &quot;JQ Manual&quot;</code></pre>
-
-<p>What may come as a surprise is that the expression on the left may produce multiple results, referring to different points in the input document:</p>
-
-<pre><code>.posts[].comments |= . + [&quot;this is great&quot;]</code></pre>
-
-<p>That example appends the string “this is great” to the “comments” array of each post in the input (where the input is an object with a field “posts” which is an array of posts).</p>
-
-<p>When jq encounters an assignment like ‘a = b’, it records the “path” taken to select a part of the input document while executing a. This path is then used to find which part of the input to change while executing the assignment. Any filter may be used on the left-hand side of an equals - whichever paths it selects from the input will be where the assignment is performed.</p>
-
-<p>This is a very powerful operation. Suppose we wanted to add a comment to blog posts, using the same “blog” input above. This time, we only want to comment on the posts written by “stedolan”. We can find those posts using the “select” function described earlier:</p>
-
-<pre><code>.posts[] | select(.author == &quot;stedolan&quot;)</code></pre>
-
-<p>The paths provided by this operation point to each of the posts that “stedolan” wrote, and we can comment on each of them in the same way that we did before:</p>
-
-<pre><code>(.posts[] | select(.author == &quot;stedolan&quot;) | .comments) |=
- . + [&quot;terrible.&quot;]</code></pre>
-
+ <p>Lots more things are allowed on the left-hand side of a jq assignment
+than in most languages. We've already seen simple field accesses on
+the left hand side, and it's no surprise that array accesses work just
+as well:</p>
+<pre><code>.posts[0].title = "JQ Manual"
+</code></pre>
+<p>What may come as a surprise is that the expression on the left may
+produce multiple results, referring to different points in the input
+document:</p>
+<pre><code>.posts[].comments |= . + ["this is great"]
+</code></pre>
+<p>That example appends the string "this is great" to the "comments"
+array of each post in the input (where the input is an object with a
+field "posts" which is an array of posts).</p>
+<p>When jq encounters an assignment like 'a = b', it records the "path"
+taken to select a part of the input document while executing a. This
+path is then used to find which part of the input to change while
+executing the assignment. Any filter may be used on the
+left-hand side of an equals - whichever paths it selects from the
+input will be where the assignment is performed.</p>
+<p>This is a very powerful operation. Suppose we wanted to add a comment
+to blog posts, using the same "blog" input above. This time, we only
+want to comment on the posts written by "stedolan". We can find those
+posts using the "select" function described earlier:</p>
+<pre><code>.posts[] | select(.author == "stedolan")
+</code></pre>
+<p>The paths provided by this operation point to each of the posts that
+"stedolan" wrote, and we can comment on each of them in the same way
+that we did before:</p>
+<pre><code>(.posts[] | select(.author == "stedolan") | .comments) |=
+ . + ["terrible."]
+</code></pre>
</section>
@@ -6283,115 +6216,125 @@ Complex assignments
<section id="Modules">
<h2>Modules</h2>
-
-<p>jq has a library/module system. Modules are files whose names end in <code>.jq</code>.</p>
-
-<p>Modules imported by a program are searched for in a default search path (see below). The <code>import</code> and <code>include</code> directives allow the importer to alter this path.</p>
-
+ <p>jq has a library/module system. Modules are files whose names end
+in <code>.jq</code>.</p>
+<p>Modules imported by a program are searched for in a default search
+path (see below). The <code>import</code> and <code>include</code> directives allow the
+importer to alter this path.</p>
<p>Paths in the a search path are subject to various substitutions.</p>
-
-<p>For paths starting with “~/”, the user’s home directory is substituted for “~”.</p>
-
-<p>For paths starting with “$ORIGIN/”, the path of the jq executable is substituted for “$ORIGIN”.</p>
-
-<p>For paths starting with “./” or paths that are “.”, the path of the including file is substituted for “.”. For top-level programs given on the command-line, the current directory is used.</p>
-
-<p>Import directives can optionally specify a search path to which the default is appended.</p>
-
-<p>The default search path is the search path given to the <code>-L</code> command-line option, else <code>[&quot;~/.jq&quot;, &quot;$ORIGIN/../lib/jq&quot;,
-&quot;$ORIGIN/../lib&quot;]</code>.</p>
-
-<p>Null and empty string path elements terminate search path processing.</p>
-
-<p>A dependency with relative path “foo/bar” would be searched for in “foo/bar.jq” and “foo/bar/bar.jq” in the given search path. This is intended to allow modules to be placed in a directory along with, for example, version control files, README files, and so on, but also to allow for single-file modules.</p>
-
-<p>Consecutive components with the same name are not allowed to avoid ambiguities (e.g., “foo/foo”).</p>
-
-<p>For example, with <code>-L$HOME/.jq</code> a module <code>foo</code> can be found in <code>$HOME/.jq/foo.jq</code> and <code>$HOME/.jq/foo/foo.jq</code>.</p>
-
-<p>If “$HOME/.jq” is a file, it is sourced into the main program.</p>
-
-
- <section id="importRelativePathStringasNAME[<metadata>];">
+<p>For paths starting with "~/", the user's home directory is
+substituted for "~".</p>
+<p>For paths starting with "$ORIGIN/", the path of the jq executable
+is substituted for "$ORIGIN".</p>
+<p>For paths starting with "./" or paths that are ".", the path of
+the including file is substituted for ".". For top-level programs
+given on the command-line, the current directory is used.</p>
+<p>Import directives can optionally specify a search path to which
+the default is appended.</p>
+<p>The default search path is the search path given to the <code>-L</code>
+command-line option, else <code>["~/.jq", "$ORIGIN/../lib/jq",
+"$ORIGIN/../lib"]</code>.</p>
+<p>Null and empty string path elements terminate search path
+processing.</p>
+<p>A dependency with relative path "foo/bar" would be searched for in
+"foo/bar.jq" and "foo/bar/bar.jq" in the given search path. This
+is intended to allow modules to be placed in a directory along
+with, for example, version control files, README files, and so on,
+but also to allow for single-file modules.</p>
+<p>Consecutive components with the same name are not allowed to avoid
+ambiguities (e.g., "foo/foo").</p>
+<p>For example, with <code>-L$HOME/.jq</code> a module <code>foo</code> can be found in
+<code>$HOME/.jq/foo.jq</code> and <code>$HOME/.jq/foo/foo.jq</code>.</p>
+<p>If "$HOME/.jq" is a file, it is sourced into the main program.</p>
+
+ <section id="importRelativePathStringasNAME[&lt;metadata&gt;];">
<h3>
-
-<code>import RelativePathString as NAME [&lt;metadata&gt;];</code>
-
+ <code>import RelativePathString as NAME [&lt;metadata&gt;];</code>
</h3>
-
-<p>Imports a module found at the given path relative to a directory in a search path. A “.jq” suffix will be added to the relative path string. The module’s symbols are prefixed with “NAME::”.</p>
-
-<p>The optional metadata must be a constant jq expression. It should be an object with keys like “homepage” and so on. At this time jq only uses the “search” key/value of the metadata. The metadata is also made available to users via the <code>modulemeta</code> builtin.</p>
-
-<p>The “search” key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top-level search path.</p>
-
+ <p>Imports a module found at the given path relative to a
+directory in a search path. A ".jq" suffix will be added to
+the relative path string. The module's symbols are prefixed
+with "NAME::".</p>
+<p>The optional metadata must be a constant jq expression. It
+should be an object with keys like "homepage" and so on. At
+this time jq only uses the "search" key/value of the metadata.
+The metadata is also made available to users via the
+<code>modulemeta</code> builtin.</p>
+<p>The "search" key in the metadata, if present, should have a
+string or array value (array of strings); this is the search
+path to be prefixed to the top-level search path.</p>
</section>
- <section id="includeRelativePathString[<metadata>];">
+ <section id="includeRelativePathString[&lt;metadata&gt;];">
<h3>
-
-<code>include RelativePathString [&lt;metadata&gt;];</code>
-
+ <code>include RelativePathString [&lt;metadata&gt;];</code>
</h3>
-
-<p>Imports a module found at the given path relative to a directory in a search path as if it were included in place. A “.jq” suffix will be added to the relative path string. The module’s symbols are imported into the caller’s namespace as if the module’s content had been included directly.</p>
-
-<p>The optional metadata must be a constant jq expression. It should be an object with keys like “homepage” and so on. At this time jq only uses the “search” key/value of the metadata. The metadata is also made available to users via the <code>modulemeta</code> builtin.</p>
-
+ <p>Imports a module found at the given path relative to a
+directory in a search path as if it were included in place. A
+".jq" suffix will be added to the relative path string. The
+module's symbols are imported into the caller's namespace as
+if the module's content had been included directly.</p>
+<p>The optional metadata must be a constant jq expression. It
+should be an object with keys like "homepage" and so on. At
+this time jq only uses the "search" key/value of the metadata.
+The metadata is also made available to users via the
+<code>modulemeta</code> builtin.</p>
</section>
- <section id="importRelativePathStringas$NAME[<metadata>];">
+ <section id="importRelativePathStringas$NAME[&lt;metadata&gt;];">
<h3>
-
-<code>import RelativePathString as $NAME [&lt;metadata&gt;];</code>
-
+ <code>import RelativePathString as $NAME [&lt;metadata&gt;];</code>
</h3>
-
-<p>Imports a JSON file found at the given path relative to a directory in a search path. A “.json” suffix will be added to the relative path string. The file’s data will be available as <code>$NAME::NAME</code>.</p>
-
-<p>The optional metadata must be a constant jq expression. It should be an object with keys like “homepage” and so on. At this time jq only uses the “search” key/value of the metadata. The metadata is also made available to users via the <code>modulemeta</code> builtin.</p>
-
-<p>The “search” key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top-level search path.</p>
-
+ <p>Imports a JSON file found at the given path relative to a
+directory in a search path. A ".json" suffix will be added to
+the relative path string. The file's data will be available
+as <code>$NAME::NAME</code>.</p>
+<p>The optional metadata must be a constant jq expression. It
+should be an object with keys like "homepage" and so on. At
+this time jq only uses the "search" key/value of the metadata.
+The metadata is also made available to users via the
+<code>modulemeta</code> builtin.</p>
+<p>The "search" key in the metadata, if present, should have a
+string or array value (array of strings); this is the search
+path to be prefixed to the top-level search path.</p>
</section>
- <section id="module<metadata>;">
+ <section id="module&lt;metadata&gt;;">
<h3>
-
-<code>module &lt;metadata&gt;;</code>
-
+ <code>module &lt;metadata&gt;;</code>
</h3>
-
-<p>This directive is entirely optional. It’s not required for proper operation. It serves only the purpose of providing metadata that can be read with the <code>modulemeta</code> builtin.</p>
-
-<p>The metadata must be a constant jq expression. It should be an object with keys like “homepage”. At this time jq doesn’t use this metadata, but it is made available to users via the <code>modulemeta</code> builtin.</p>
-
+ <p>This directive is entirely optional. It's not required for
+proper operation. It serves only the purpose of providing
+metadata that can be read with the <code>modulemeta</code> builtin.</p>
+<p>The metadata must be a constant jq expression. It should be
+an object with keys like "homepage". At this time jq doesn't
+use this metadata, but it is made available to users via the
+<code>modulemeta</code> builtin.</p>
</section>
<section id="modulemeta">
<h3>
-
-<code>modulemeta</code>
-
+ <code>modulemeta</code>
</h3>
-
-<p>Takes a module name as input and outputs the module’s metadata as an object, with the module’s imports (including metadata) as an array value for the “deps” key.</p>
-
-<p>Programs can use this to query a module’s metadata, which they could then use to, for example, search for, download, and install missing dependencies.</p>
-
+ <p>Takes a module name as input and outputs the module's metadata
+as an object, with the module's imports (including metadata)
+as an array value for the "deps" key.</p>
+<p>Programs can use this to query a module's metadata, which they
+could then use to, for example, search for, download, and
+install missing dependencies.</p>
</section>
@@ -6404,7 +6347,7 @@ Complex assignments
<footer>
<div class="container">
- <p>This website is made with <a href="http://www.tinytree.info">Bonsai</a> and <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
+ <p>This website is made with <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
<p>jq is licensed under the MIT license (code) and the <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a> license (docs).</p>
</div>
</footer>
@@ -6412,7 +6355,6 @@ Complex assignments
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<script src="https://twitter.github.io/typeahead.js/releases/0.11.1/typeahead.bundle.js"></script>
-
<script>
var section_map = {
@@ -6427,7 +6369,7 @@ Complex assignments
".foo?" : ".foo?",
- ".[<string>], .[2], .[10:15]" : ".[<string>],.[2],.[10:15]",
+ ".[\u003cstring\u003e], .[2], .[10:15]" : ".[\u003cstring\u003e],.[2],.[10:15]",
".[]" : ".[]",
@@ -6573,7 +6515,7 @@ Complex assignments
"if-then-else" : "if-then-else",
- ">, >=, <=, <" : ">,>=,<=,<",
+ "\u003e, \u003e=, \u003c=, \u003c" : "\u003e,\u003e=,\u003c=,\u003c",
"and/or/not" : "and/or/not",
@@ -6671,13 +6613,13 @@ Complex assignments
,
- "import RelativePathString as NAME [<metadata>];" : "importRelativePathStringasNAME[<metadata>];",
+ "import RelativePathString as NAME [\u003cmetadata\u003e];" : "importRelativePathStringasNAME[\u003cmetadata\u003e];",
- "include RelativePathString [<metadata>];" : "includeRelativePathString[<metadata>];",
+ "include RelativePathString [\u003cmetadata\u003e];" : "includeRelativePathString[\u003cmetadata\u003e];",
- "import RelativePathString as $NAME [<metadata>];" : "importRelativePathStringas$NAME[<metadata>];",
+ "import RelativePathString as $NAME [\u003cmetadata\u003e];" : "importRelativePathStringas$NAME[\u003cmetadata\u003e];",
- "module <metadata>;" : "module<metadata>;",
+ "module \u003cmetadata\u003e;" : "module\u003cmetadata\u003e;",
"modulemeta" : "modulemeta",
@@ -6688,4 +6630,4 @@ Complex assignments
</script>
<script src="/jq/js/manual-search.js"></script>
</body>
-</html>
+</html> \ No newline at end of file
diff --git a/manual/v1.6/index.html b/manual/v1.6/index.html
index d4d3f6c..d2f3b05 100644
--- a/manual/v1.6/index.html
+++ b/manual/v1.6/index.html
@@ -18,7 +18,6 @@
<![endif]-->
</head>
-
<body id="v1.6" data-spy="scroll" data-target="#navcolumn" data-offset="100">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
@@ -56,7 +55,6 @@
</div>
</div>
-
<div class="container">
<div class="row">
<div class="affix" id="navcolumn">
@@ -128,206 +126,226 @@
<div id="manualcontent">
<h1>jq 1.6 Manual</h1>
<p><em>The manual for the development version of jq can be found
-<a href='/jq/manual'>here</a>.</em></p>
- <p>A jq program is a &ldquo;filter&rdquo;: it takes an input, and produces an
+<a href="/jq/manual">here</a>.</em></p>
+ <p>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.</p><p>Filters can be combined in various ways - you can pipe the output of
+or various other standard tasks.</p>
+<p>Filters can be combined in various ways - you can pipe the output of
one filter into another filter, or collect the output of a filter
-into an array.</p><p>Some filters produce multiple results, for instance there&rsquo;s one that
+into an array.</p>
+<p>Some filters produce multiple results, for instance there's one that
produces all the elements of its input array. Piping that filter
into a second runs the second filter for each element of the
array. Generally, things that would be done with loops and iteration
-in other languages are just done by gluing filters together in jq.</p><p>It&rsquo;s important to remember that every filter has an input and an
-output. Even literals like &ldquo;hello&rdquo; or 42 are filters - they take an
+in other languages are just done by gluing filters together in jq.</p>
+<p>It's important to remember that every filter has an input and an
+output. Even literals like "hello" or 42 are filters - they take an
input but always produce the same literal as output. Operations that
combine two filters, like addition, generally feed the same input to
both and combine the results. So, you can implement an averaging
filter as <code>add / length</code> - feeding the input array both to the <code>add</code>
-filter and the <code>length</code> filter and then performing the division.</p><p>But that&rsquo;s getting ahead of ourselves. :) Let&rsquo;s start with something
+filter and the <code>length</code> filter and then performing the division.</p>
+<p>But that's getting ahead of ourselves. :) Let's start with something
simpler:</p>
<section id="Invokingjq">
<h2>Invoking jq</h2>
-
-<p>jq filters run on a stream of JSON data. The input to jq is parsed as a sequence of whitespace-separated JSON values which are passed through the provided filter one at a time. The output(s) of the filter are written to standard out, again as a sequence of whitespace-separated JSON data.</p>
-
-<p>Note: it is important to mind the shell’s quoting rules. As a general rule it’s best to always quote (with single-quote characters) the jq program, as too many characters with special meaning to jq are also shell meta-characters. For example, <code>jq
-&quot;foo&quot;</code> will fail on most Unix shells because that will be the same as <code>jq foo</code>, which will generally fail because <code>foo is not
-defined</code>. When using the Windows command shell (cmd.exe) it’s best to use double quotes around your jq program when given on the command-line (instead of the <code>-f program-file</code> option), but then double-quotes in the jq program need backslash escaping.</p>
-
-<p>You can affect how jq reads and writes its input and output using some command-line options:</p>
-
+ <p>jq filters run on a stream of JSON data. The input to jq is
+parsed as a sequence of whitespace-separated JSON values which
+are passed through the provided filter one at a time. The
+output(s) of the filter are written to standard out, again as a
+sequence of whitespace-separated JSON data.</p>
+<p>Note: it is important to mind the shell's quoting rules. As a
+general rule it's best to always quote (with single-quote
+characters) the jq program, as too many characters with special
+meaning to jq are also shell meta-characters. For example, <code>jq
+"foo"</code> will fail on most Unix shells because that will be the same
+as <code>jq foo</code>, which will generally fail because <code>foo is not
+defined</code>. When using the Windows command shell (cmd.exe) it's
+best to use double quotes around your jq program when given on the
+command-line (instead of the <code>-f program-file</code> option), but then
+double-quotes in the jq program need backslash escaping.</p>
+<p>You can affect how jq reads and writes its input and output
+using some command-line options:</p>
<ul>
-<li>
-<p><code>--version</code>:</p>
-
+<li><code>--version</code>:</li>
+</ul>
<p>Output the jq version and exit with zero.</p>
-</li>
-
-<li>
-<p><code>--seq</code>:</p>
-
-<p>Use the <code>application/json-seq</code> 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 <code>--seq</code> option.</p>
-</li>
-
-<li>
-<p><code>--stream</code>:</p>
-
-<p>Parse the input in streaming fashion, outputing arrays of path and leaf values (scalars and empty arrays or empty objects). For example, <code>&quot;a&quot;</code> becomes <code>[[],&quot;a&quot;]</code>, and <code>[[],&quot;a&quot;,[&quot;b&quot;]]</code> becomes <code>[[0],[]]</code>, <code>[[1],&quot;a&quot;]</code>, and <code>[[1,0],&quot;b&quot;]</code>.</p>
-
-<p>This is useful for processing very large inputs. Use this in conjunction with filtering and the <code>reduce</code> and <code>foreach</code> syntax to reduce large inputs incrementally.</p>
-</li>
-
-<li>
-<p><code>--slurp</code>/<code>-s</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--raw-input</code>/<code>-R</code>:</p>
-
-<p>Don’t parse the input as JSON. Instead, each line of text is passed to the filter as a string. If combined with <code>--slurp</code>, then the entire input is passed to the filter as a single long string.</p>
-</li>
-
-<li>
-<p><code>--null-input</code>/<code>-n</code>:</p>
-
-<p>Don’t read any input at all! Instead, the filter is run once using <code>null</code> as the input. This is useful when using jq as a simple calculator or to construct JSON data from scratch.</p>
-</li>
-
-<li>
-<p><code>--compact-output</code> / <code>-c</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--tab</code>:</p>
-
+<ul>
+<li><code>--seq</code>:</li>
+</ul>
+<p>Use the <code>application/json-seq</code> 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 <code>--seq</code>
+ option.</p>
+<ul>
+<li><code>--stream</code>:</li>
+</ul>
+<p>Parse the input in streaming fashion, outputting arrays of path
+ and leaf values (scalars and empty arrays or empty objects).
+ For example, <code>"a"</code> becomes <code>[[],"a"]</code>, and <code>[[],"a",["b"]]</code>
+ becomes <code>[[0],[]]</code>, <code>[[1],"a"]</code>, and <code>[[1,0],"b"]</code>.</p>
+<p>This is useful for processing very large inputs. Use this in
+ conjunction with filtering and the <code>reduce</code> and <code>foreach</code> syntax
+ to reduce large inputs incrementally.</p>
+<ul>
+<li><code>--slurp</code>/<code>-s</code>:</li>
+</ul>
+<p>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.</p>
+<ul>
+<li><code>--raw-input</code>/<code>-R</code>:</li>
+</ul>
+<p>Don't parse the input as JSON. Instead, each line of text is
+ passed to the filter as a string. If combined with <code>--slurp</code>,
+ then the entire input is passed to the filter as a single long
+ string.</p>
+<ul>
+<li><code>--null-input</code>/<code>-n</code>:</li>
+</ul>
+<p>Don't read any input at all! Instead, the filter is run once
+ using <code>null</code> as the input. This is useful when using jq as a
+ simple calculator or to construct JSON data from scratch.</p>
+<ul>
+<li><code>--compact-output</code> / <code>-c</code>:</li>
+</ul>
+<p>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.</p>
+<ul>
+<li><code>--tab</code>:</li>
+</ul>
<p>Use a tab for each indentation level instead of two spaces.</p>
-</li>
-
-<li>
-<p><code>--indent n</code>:</p>
-
-<p>Use the given number of spaces (no more than 8) for indentation.</p>
-</li>
-
-<li>
-<p><code>--color-output</code> / <code>-C</code> and <code>--monochrome-output</code> / <code>-M</code>:</p>
-
-<p>By default, jq outputs colored JSON if writing to a terminal. You can force it to produce color even if writing to a pipe or a file using <code>-C</code>, and disable color with <code>-M</code>.</p>
-
-<p>Colors can be configured with the <code>JQ_COLORS</code> environment variable (see below).</p>
-</li>
-
-<li>
-<p><code>--ascii-output</code> / <code>-a</code>:</p>
-
-<p>jq usually outputs non-ASCII Unicode codepoints as UTF-8, even if the input specified them as escape sequences (like “\u03bc”). Using this option, you can force jq to produce pure ASCII output with every non-ASCII character replaced with the equivalent escape sequence.</p>
-</li>
-
-<li>
-<p><code>--unbuffered</code></p>
-
-<p>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).</p>
-</li>
-
-<li>
-<p><code>--sort-keys</code> / <code>-S</code>:</p>
-
+<ul>
+<li><code>--indent n</code>:</li>
+</ul>
+<p>Use the given number of spaces (no more than 7) for indentation.</p>
+<ul>
+<li><code>--color-output</code> / <code>-C</code> and <code>--monochrome-output</code> / <code>-M</code>:</li>
+</ul>
+<p>By default, jq outputs colored JSON if writing to a
+ terminal. You can force it to produce color even if writing to
+ a pipe or a file using <code>-C</code>, and disable color with <code>-M</code>.</p>
+<p>Colors can be configured with the <code>JQ_COLORS</code> environment
+ variable (see below).</p>
+<ul>
+<li><code>--ascii-output</code> / <code>-a</code>:</li>
+</ul>
+<p>jq usually outputs non-ASCII Unicode codepoints as UTF-8, even
+ if the input specified them as escape sequences (like
+ "\u03bc"). Using this option, you can force jq to produce pure
+ ASCII output with every non-ASCII character replaced with the
+ equivalent escape sequence.</p>
+<ul>
+<li><code>--unbuffered</code></li>
+</ul>
+<p>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).</p>
+<ul>
+<li><code>--sort-keys</code> / <code>-S</code>:</li>
+</ul>
<p>Output the fields of each object with the keys in sorted order.</p>
-</li>
-
-<li>
-<p><code>--raw-output</code> / <code>-r</code>:</p>
-
-<p>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.</p>
-</li>
-
-<li>
-<p><code>--join-output</code> / <code>-j</code>:</p>
-
-<p>Like <code>-r</code> but jq won’t print a newline after each output.</p>
-</li>
-
-<li>
-<p><code>-f filename</code> / <code>--from-file filename</code>:</p>
-
-<p>Read filter from the file rather than from a command line, like awk’s -f option. You can also use ‘#’ to make comments.</p>
-</li>
-
-<li>
-<p><code>-Ldirectory</code> / <code>-L directory</code>:</p>
-
-<p>Prepend <code>directory</code> to the search list for modules. If this option is used then no builtin search list is used. See the section on modules below.</p>
-</li>
-
-<li>
-<p><code>-e</code> / <code>--exit-status</code>:</p>
-
-<p>Sets the exit status of jq to 0 if the last output values was neither <code>false</code> nor <code>null</code>, 1 if the last output value was either <code>false</code> or <code>null</code>, or 4 if no valid result was ever produced. Normally jq exits with 2 if there was any usage problem or system error, 3 if there was a jq program compile error, or 0 if the jq program ran.</p>
-
-<p>Another way to set the exit status is with the <code>halt_error</code> builtin function.</p>
-</li>
-
-<li>
-<p><code>--arg name value</code>:</p>
-
-<p>This option passes a value to the jq program as a predefined variable. If you run jq with <code>--arg foo bar</code>, then <code>$foo</code> is available in the program and has the value <code>&quot;bar&quot;</code>. Note that <code>value</code> will be treated as a string, so <code>--arg foo 123</code> will bind <code>$foo</code> to <code>&quot;123&quot;</code>.</p>
-
-<p>Named arguments are also available to the jq program as <code>$ARGS.named</code>.</p>
-</li>
-
-<li>
-<p><code>--argjson name JSON-text</code>:</p>
-
-<p>This option passes a JSON-encoded value to the jq program as a predefined variable. If you run jq with <code>--argjson foo 123</code>, then <code>$foo</code> is available in the program and has the value <code>123</code>.</p>
-</li>
-
-<li>
-<p><code>--slurpfile variable-name filename</code>:</p>
-
-<p>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 <code>--slurpfile foo bar</code>, then <code>$foo</code> is available in the program and has an array whose elements correspond to the texts in the file named <code>bar</code>.</p>
-</li>
-
-<li>
-<p><code>--rawfile variable-name filename</code>:</p>
-
-<p>This option reads in the named file and binds its contents to the given global variable. If you run jq with <code>--rawfile foo bar</code>, then <code>$foo</code> is available in the program and has a string whose contents are to the texs in the file named <code>bar</code>.</p>
-</li>
-
-<li>
-<p><code>--argfile variable-name filename</code>:</p>
-
-<p>Do not use. Use <code>--slurpfile</code> instead.</p>
-
-<p>(This option is like <code>--slurpfile</code>, but when the file has just one text, then that is used, else an array of texts is used as in <code>--slurpfile</code>.)</p>
-</li>
-
-<li>
-<p><code>--args</code>:</p>
-
-<p>Remaining arguments are positional string arguments. These are available to the jq program as <code>$ARGS.positional[]</code>.</p>
-</li>
-
-<li>
-<p><code>--jsonargs</code>:</p>
-
-<p>Remaining arguments are positional JSON text arguments. These are available to the jq program as <code>$ARGS.positional[]</code>.</p>
-</li>
-
-<li>
-<p><code>--run-tests [filename]</code>:</p>
-
-<p>Runs the tests in the given file or standard input. This must be the last option given and does not honor all preceding options. The input consists of comment lines, empty lines, and program lines followed by one input line, as many lines of output as are expected (one per output), and a terminating empty line. Compilation failure tests start with a line containing only “%%FAIL”, then a line containing the program to compile, then a line containing an error message to compare to the actual.</p>
-
-<p>Be warned that this option can change backwards-incompatibly.</p>
-</li>
+<ul>
+<li><code>--raw-output</code> / <code>-r</code>:</li>
</ul>
-
+<p>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.</p>
+<ul>
+<li><code>--join-output</code> / <code>-j</code>:</li>
+</ul>
+<p>Like <code>-r</code> but jq won't print a newline after each output.</p>
+<ul>
+<li><code>-f filename</code> / <code>--from-file filename</code>:</li>
+</ul>
+<p>Read filter from the file rather than from a command line, like
+ awk's -f option. You can also use '#' to make comments.</p>
+<ul>
+<li><code>-Ldirectory</code> / <code>-L directory</code>:</li>
+</ul>
+<p>Prepend <code>directory</code> to the search list for modules. If this
+ option is used then no builtin search list is used. See the
+ section on modules below.</p>
+<ul>
+<li><code>-e</code> / <code>--exit-status</code>:</li>
+</ul>
+<p>Sets the exit status of jq to 0 if the last output values was
+ neither <code>false</code> nor <code>null</code>, 1 if the last output value was
+ either <code>false</code> or <code>null</code>, or 4 if no valid result was ever
+ produced. Normally jq exits with 2 if there was any usage
+ problem or system error, 3 if there was a jq program compile
+ error, or 0 if the jq program ran.</p>
+<p>Another way to set the exit status is with the <code>halt_error</code>
+ builtin function.</p>
+<ul>
+<li><code>--arg name value</code>:</li>
+</ul>
+<p>This option passes a value to the jq program as a predefined
+ variable. If you run jq with <code>--arg foo bar</code>, then <code>$foo</code> is
+ available in the program and has the value <code>"bar"</code>. Note that
+ <code>value</code> will be treated as a string, so <code>--arg foo 123</code> will
+ bind <code>$foo</code> to <code>"123"</code>.</p>
+<p>Named arguments are also available to the jq program as
+ <code>$ARGS.named</code>.</p>
+<ul>
+<li><code>--argjson name JSON-text</code>:</li>
+</ul>
+<p>This option passes a JSON-encoded value to the jq program as a
+ predefined variable. If you run jq with <code>--argjson foo 123</code>, then
+ <code>$foo</code> is available in the program and has the value <code>123</code>.</p>
+<ul>
+<li><code>--slurpfile variable-name filename</code>:</li>
+</ul>
+<p>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 <code>--slurpfile foo bar</code>, then <code>$foo</code> is available
+ in the program and has an array whose elements correspond to the
+ texts in the file named <code>bar</code>.</p>
+<ul>
+<li><code>--rawfile variable-name filename</code>:</li>
+</ul>
+<p>This option reads in the named file and binds its contents to the given
+ global variable. If you run jq with <code>--rawfile foo bar</code>, then <code>$foo</code> is
+ available in the program and has a string whose contents are to the texs
+ in the file named <code>bar</code>.</p>
+<ul>
+<li><code>--argfile variable-name filename</code>:</li>
+</ul>
+<p>Do not use. Use <code>--slurpfile</code> instead.</p>
+<p>(This option is like <code>--slurpfile</code>, but when the file has just
+ one text, then that is used, else an array of texts is used as
+ in <code>--slurpfile</code>.)</p>
+<ul>
+<li><code>--args</code>:</li>
+</ul>
+<p>Remaining arguments are positional string arguments. These are
+ available to the jq program as <code>$ARGS.positional[]</code>.</p>
+<ul>
+<li><code>--jsonargs</code>:</li>
+</ul>
+<p>Remaining arguments are positional JSON text arguments. These
+ are available to the jq program as <code>$ARGS.positional[]</code>.</p>
+<ul>
+<li><code>--run-tests [filename]</code>:</li>
+</ul>
+<p>Runs the tests in the given file or standard input. This must
+ be the last option given and does not honor all preceding
+ options. The input consists of comment lines, empty lines, and
+ program lines followed by one input line, as many lines of
+ output as are expected (one per output), and a terminating empty
+ line. Compilation failure tests start with a line containing
+ only "%%FAIL", then a line containing the program to compile,
+ then a line containing an error message to compare to the
+ actual.</p>
+<p>Be warned that this option can change backwards-incompatibly.</p>
</section>
@@ -337,36 +355,88 @@ defined</code>. When using the Windows command shell (cmd.exe) it’s best to us
<section id="Identity:.">
<h3>
-
-Identity: <code>.</code>
-
+ Identity: <code>.</code>
</h3>
-
-<p>The absolute simplest filter is <code>.</code> . This is a filter that takes its input and produces it unchanged as output. That is, this is the identity operator.</p>
-
-<p>Since jq by default pretty-prints all output, this trivial program can be a useful way of formatting JSON output from, say, <code>curl</code>.</p>
-
+ <p>The absolute simplest filter is <code>.</code> . This is a filter that
+takes its input and produces it unchanged as output. That is,
+this is the identity operator.</p>
+<p>Since jq by default pretty-prints all output, this trivial
+program can be a useful way of formatting JSON output from,
+say, <code>curl</code>.</p>
+<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>
+<p>jq doesn't truncate the literal numbers to double unless there
+is a need to make arithmetic operations with the number.
+Comparisons are carried out over the untruncated big decimal
+representation of the number.</p>
+<p>jq will also try to maintain the original decimal precision of the provided
+number literal. See below for examples. </p>
<div>
<a data-toggle="collapse" href="#example1">
<i class="glyphicon glyphicon-chevron-right"></i>
- Example
+ Examples
</a>
<div id="example1" class="manual-example collapse">
<table>
<tr><th></th><td class="jqprogram">jq '.'</td></tr>
- <tr><th>Input</th><td>&quot;Hello, world!&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;Hello, world!&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;Hello, world!&quot;</td>
+ <td>&#34;Hello, world!&#34;</td>
+ </tr>
+
+ </table>
+
+ <table>
+ <tr><th></th><td class="jqprogram">jq '. | tojson'</td></tr>
+ <tr><th>Input</th><td>12345678909876543212345</td></tr>
+
+
+ <tr>
+
+ <th>Output</th>
+
+ <td>&#34;12345678909876543212345&#34;</td>
+ </tr>
+
+ </table>
+
+ <table>
+ <tr><th></th><td class="jqprogram">jq 'map([., . == 1]) | tojson'</td></tr>
+ <tr><th>Input</th><td>[1, 1.000, 1.0, 100e-2]</td></tr>
+
+
+ <tr>
+
+ <th>Output</th>
+
+ <td>&#34;[[1,true],[1.000,true],[1.0,true],[1.00,true]]&#34;</td>
+ </tr>
+
+ </table>
+
+ <table>
+ <tr><th></th><td class="jqprogram">jq '. as $big | [$big, $big + 1] | map(. &gt; 10000000000000000000000000000000)'</td></tr>
+ <tr><th>Input</th><td>10000000000000000000000000000001</td></tr>
+
+
+ <tr>
+
+ <th>Output</th>
+
+ <td>[true, false]</td>
</tr>
</table>
@@ -378,22 +448,21 @@ Identity: <code>.</code>
<section id="ObjectIdentifier-Index:.foo,.foo.bar">
<h3>
-
-Object Identifier-Index: <code>.foo</code>, <code>.foo.bar</code>
-
+ Object Identifier-Index: <code>.foo</code>, <code>.foo.bar</code>
</h3>
-
-<p>The simplest <em>useful</em> filter is <code>.foo</code>. When given a JSON object (aka dictionary or hash) as input, it produces the value at the key “foo”, or null if there’s none present.</p>
-
+ <p>The simplest <em>useful</em> filter is <code>.foo</code>. When given a
+JSON object (aka dictionary or hash) as input, it produces
+the value at the key "foo", or null if there's none present.</p>
<p>A filter of the form <code>.foo.bar</code> is equivalent to <code>.foo|.bar</code>.</p>
-
-<p>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>
-
-<p>If the key contains special characters, you need to surround it with double quotes like this: <code>.&quot;foo$&quot;</code>, or else <code>.[&quot;foo$&quot;]</code>.</p>
-
-<p>For example <code>.[&quot;foo::bar&quot;]</code> and <code>.[&quot;foo.bar&quot;]</code> work while <code>.foo::bar</code> does not, and <code>.foo.bar</code> means <code>.[&quot;foo&quot;].[&quot;bar&quot;]</code>.</p>
-
+<p>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>
+<p>If the key contains special characters or starts with a digit,
+you need to surround it with double quotes like this:
+<code>."foo$"</code>, or else <code>.["foo$"]</code>.</p>
+<p>For example <code>.["foo::bar"]</code> and <code>.["foo.bar"]</code> work while
+<code>.foo::bar</code> does not, and <code>.foo.bar</code> means <code>.["foo"].["bar"]</code>.</p>
<div>
@@ -406,7 +475,7 @@ Object Identifier-Index: <code>.foo</code>, <code>.foo.bar</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;less interesting data&quot;}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;less interesting data&#34;}</td></tr>
<tr>
@@ -420,7 +489,7 @@ Object Identifier-Index: <code>.foo</code>, <code>.foo.bar</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo'</td></tr>
- <tr><th>Input</th><td>{&quot;notfoo&quot;: true, &quot;alsonotfoo&quot;: false}</td></tr>
+ <tr><th>Input</th><td>{&#34;notfoo&#34;: true, &#34;alsonotfoo&#34;: false}</td></tr>
<tr>
@@ -433,8 +502,8 @@ Object Identifier-Index: <code>.foo</code>, <code>.foo.bar</code>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[&quot;foo&quot;]'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42}</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[&#34;foo&#34;]'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42}</td></tr>
<tr>
@@ -453,14 +522,11 @@ Object Identifier-Index: <code>.foo</code>, <code>.foo.bar</code>
<section id="OptionalObjectIdentifier-Index:.foo?">
<h3>
-
-Optional Object Identifier-Index: <code>.foo?</code>
-
+ Optional Object Identifier-Index: <code>.foo?</code>
</h3>
-
-<p>Just like <code>.foo</code>, but does not output even an error when <code>.</code> is not an array or an object.</p>
-
+ <p>Just like <code>.foo</code>, but does not output even an error when <code>.</code>
+is not an array or an object.</p>
<div>
@@ -473,7 +539,7 @@ Optional Object Identifier-Index: <code>.foo?</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo?'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;less interesting data&quot;}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;less interesting data&#34;}</td></tr>
<tr>
@@ -487,7 +553,7 @@ Optional Object Identifier-Index: <code>.foo?</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo?'</td></tr>
- <tr><th>Input</th><td>{&quot;notfoo&quot;: true, &quot;alsonotfoo&quot;: false}</td></tr>
+ <tr><th>Input</th><td>{&#34;notfoo&#34;: true, &#34;alsonotfoo&#34;: false}</td></tr>
<tr>
@@ -500,8 +566,8 @@ Optional Object Identifier-Index: <code>.foo?</code>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[&quot;foo&quot;]?'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42}</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[&#34;foo&#34;]?'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42}</td></tr>
<tr>
@@ -532,32 +598,28 @@ Optional Object Identifier-Index: <code>.foo?</code>
</section>
- <section id="GenericObjectIndex:.[<string>]">
+ <section id="GenericObjectIndex:.[&lt;string&gt;]">
<h3>
-
-Generic Object Index: <code>.[&lt;string&gt;]</code>
-
+ Generic Object Index: <code>.[&lt;string&gt;]</code>
</h3>
-
-<p>You can also look up fields of an object using syntax like <code>.[&quot;foo&quot;]</code> (.foo above is a shorthand version of this, but only for identifier-like strings).</p>
-
+ <p>You can also look up fields of an object using syntax like
+<code>.["foo"]</code> (.foo above is a shorthand version of this, but
+only for identifier-like strings).</p>
</section>
<section id="ArrayIndex:.[2]">
<h3>
-
-Array Index: <code>.[2]</code>
-
+ Array Index: <code>.[2]</code>
</h3>
-
-<p>When the index value is an integer, <code>.[&lt;value&gt;]</code> can index arrays. Arrays are zero-based, so <code>.[2]</code> returns the third element.</p>
-
-<p>Negative indices are allowed, with -1 referring to the last element, -2 referring to the next to last element, and so on.</p>
-
+ <p>When the index value is an integer, <code>.[&lt;value&gt;]</code> can index
+arrays. Arrays are zero-based, so <code>.[2]</code> returns the third
+element.</p>
+<p>Negative indices are allowed, with -1 referring to the last
+element, -2 referring to the next to last element, and so on.</p>
<div>
@@ -570,21 +632,21 @@ Array Index: <code>.[2]</code>
<table>
<tr><th></th><td class="jqprogram">jq '.[0]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}</td>
+ <td>{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[2]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
@@ -617,14 +679,16 @@ Array Index: <code>.[2]</code>
<section id="Array/StringSlice:.[10:15]">
<h3>
-
-Array/String Slice: <code>.[10:15]</code>
-
+ Array/String Slice: <code>.[10:15]</code>
</h3>
-
-<p>The <code>.[10:15]</code> syntax can be used to return a subarray of an array or substring of a string. The array returned by <code>.[10:15]</code> will be of length 5, containing the elements from index 10 (inclusive) to index 15 (exclusive). Either index may be negative (in which case it counts backwards from the end of the array), or omitted (in which case it refers to the start or end of the array).</p>
-
+ <p>The <code>.[10:15]</code> syntax can be used to return a subarray of an
+array or substring of a string. The array returned by
+<code>.[10:15]</code> will be of length 5, containing the elements from
+index 10 (inclusive) to index 15 (exclusive). Either index may
+be negative (in which case it counts backwards from the end of
+the array), or omitted (in which case it refers to the start
+or end of the array).</p>
<div>
@@ -637,56 +701,56 @@ Array/String Slice: <code>.[10:15]</code>
<table>
<tr><th></th><td class="jqprogram">jq '.[2:4]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;c&quot;, &quot;d&quot;]</td>
+ <td>[&#34;c&#34;, &#34;d&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[2:4]'</td></tr>
- <tr><th>Input</th><td>&quot;abcdefghi&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;abcdefghi&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;cd&quot;</td>
+ <td>&#34;cd&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[:3]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</td>
+ <td>[&#34;a&#34;, &#34;b&#34;, &#34;c&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[-2:]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;d&quot;, &quot;e&quot;]</td>
+ <td>[&#34;d&#34;, &#34;e&#34;]</td>
</tr>
</table>
@@ -698,16 +762,16 @@ Array/String Slice: <code>.[10:15]</code>
<section id="Array/ObjectValueIterator:.[]">
<h3>
-
-Array/Object Value Iterator: <code>.[]</code>
-
+ Array/Object Value Iterator: <code>.[]</code>
</h3>
-
-<p>If you use the <code>.[index]</code> syntax, but omit the index entirely, it will return <em>all</em> of the elements of an array. Running <code>.[]</code> with the input <code>[1,2,3]</code> will produce the numbers as three separate results, rather than as a single array.</p>
-
-<p>You can also use this on an object, and it will return all the values of the object.</p>
-
+ <p>If you use the <code>.[index]</code> syntax, but omit the index
+entirely, it will return <em>all</em> of the elements of an
+array. Running <code>.[]</code> with the input <code>[1,2,3]</code> will produce the
+numbers as three separate results, rather than as a single
+array.</p>
+<p>You can also use this on an object, and it will return all
+the values of the object.</p>
<div>
@@ -720,21 +784,21 @@ Array/Object Value Iterator: <code>.[]</code>
<table>
<tr><th></th><td class="jqprogram">jq '.[]'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}</td>
+ <td>{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}</td>
+ <td>{&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}</td>
</tr>
</table>
@@ -753,7 +817,7 @@ Array/Object Value Iterator: <code>.[]</code>
<table>
<tr><th></th><td class="jqprogram">jq '.[]'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 1}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 1}</td></tr>
<tr>
@@ -779,29 +843,27 @@ Array/Object Value Iterator: <code>.[]</code>
<section id=".[]?">
<h3>
-
-<code>.[]?</code>
-
+ <code>.[]?</code>
</h3>
-
-<p>Like <code>.[]</code>, but no errors will be output if . is not an array or object.</p>
-
+ <p>Like <code>.[]</code>, but no errors will be output if . is not an array
+or object.</p>
</section>
<section id="Comma:,">
<h3>
-
-Comma: <code>,</code>
-
+ Comma: <code>,</code>
</h3>
-
-<p>If two filters are separated by a comma, then the same input will be fed into both and the two filters’ output value streams will be concatenated in order: first, all of the outputs produced by the left expression, and then all of the outputs produced by the right. For instance, filter <code>.foo,
-.bar</code>, produces both the “foo” fields and “bar” fields as separate outputs.</p>
-
+ <p>If two filters are separated by a comma, then the
+same input will be fed into both and the two filters' output
+value streams will be concatenated in order: first, all of the
+outputs produced by the left expression, and then all of the
+outputs produced by the right. For instance, filter <code>.foo,
+.bar</code>, produces both the "foo" fields and "bar" fields as
+separate outputs.</p>
<div>
@@ -814,7 +876,7 @@ Comma: <code>,</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo, .bar'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: &quot;something else&quot;, &quot;baz&quot;: true}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: &#34;something else&#34;, &#34;baz&#34;: true}</td></tr>
<tr>
@@ -828,56 +890,56 @@ Comma: <code>,</code>
<th></th>
- <td>&quot;something else&quot;</td>
+ <td>&#34;something else&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.user, .projects[]'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;projects&quot;: [&quot;jq&quot;, &quot;wikiflow&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;projects&#34;: [&#34;jq&#34;, &#34;wikiflow&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>&quot;stedolan&quot;</td>
+ <td>&#34;stedolan&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;jq&quot;</td>
+ <td>&#34;jq&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;wikiflow&quot;</td>
+ <td>&#34;wikiflow&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[4,2]'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;,&#34;d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;e&quot;</td>
+ <td>&#34;e&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;c&quot;</td>
+ <td>&#34;c&#34;</td>
</tr>
</table>
@@ -889,20 +951,22 @@ Comma: <code>,</code>
<section id="Pipe:|">
<h3>
-
-Pipe: <code>|</code>
-
+ Pipe: <code>|</code>
</h3>
-
-<p>The | operator combines two filters by feeding the output(s) of the one on the left into the input of the one on the right. It’s pretty much the same as the Unix shell’s pipe, if you’re used to that.</p>
-
-<p>If the one on the left produces multiple results, the one on the right will be run for each of those results. So, the expression <code>.[] | .foo</code> retrieves the “foo” field of each element of the input array.</p>
-
+ <p>The | operator combines two filters by feeding the output(s) of
+the one on the left into the input of the one on the right. It's
+pretty much the same as the Unix shell's pipe, if you're used to
+that.</p>
+<p>If the one on the left produces multiple results, the one on
+the right will be run for each of those results. So, the
+expression <code>.[] | .foo</code> retrieves the "foo" field of each
+element of the input array.</p>
<p>Note that <code>.a.b.c</code> is the same as <code>.a | .b | .c</code>.</p>
-
-<p>Note too that <code>.</code> is the input value at the particular stage in a “pipeline”, specifically: where the <code>.</code> expression appears. Thus <code>.a | . | .b</code> is the same as <code>.a.b</code>, as the <code>.</code> in the middle refers to whatever value <code>.a</code> produced.</p>
-
+<p>Note too that <code>.</code> is the input value at the particular stage
+in a "pipeline", specifically: where the <code>.</code> expression appears.
+Thus <code>.a | . | .b</code> is the same as <code>.a.b</code>, as the <code>.</code> in the
+middle refers to whatever value <code>.a</code> produced.</p>
<div>
@@ -915,21 +979,21 @@ Pipe: <code>|</code>
<table>
<tr><th></th><td class="jqprogram">jq '.[] | .name'</td></tr>
- <tr><th>Input</th><td>[{&quot;name&quot;:&quot;JSON&quot;, &quot;good&quot;:true}, {&quot;name&quot;:&quot;XML&quot;, &quot;good&quot;:false}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;name&#34;:&#34;JSON&#34;, &#34;good&#34;:true}, {&#34;name&#34;:&#34;XML&#34;, &#34;good&#34;:false}]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;JSON&quot;</td>
+ <td>&#34;JSON&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;XML&quot;</td>
+ <td>&#34;XML&#34;</td>
</tr>
</table>
@@ -941,14 +1005,11 @@ Pipe: <code>|</code>
<section id="Parenthesis">
<h3>
-
-Parenthesis
-
+ Parenthesis
</h3>
-
-<p>Parenthesis work as a grouping operator just as in any typical programming language.</p>
-
+ <p>Parenthesis work as a grouping operator just as in any typical
+programming language.</p>
<div>
@@ -982,26 +1043,43 @@ Parenthesis
<section id="TypesandValues">
<h2>Types and Values</h2>
-
-<p>jq supports the same set of datatypes as JSON - numbers, strings, booleans, arrays, objects (which in JSON-speak are hashes with only string keys), and “null”.</p>
-
-<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 - <code>42</code> is a valid jq expression that takes an input, ignores it, and returns 42 instead.</p>
-
+ <p>jq supports the same set of datatypes as JSON - numbers,
+strings, booleans, arrays, objects (which in JSON-speak are
+hashes with only string keys), and "null".</p>
+<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 - <code>42</code> is a valid jq
+expression that takes an input, ignores it, and returns 42
+instead.</p>
+<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>
+<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. </p>
<section id="Arrayconstruction:[]">
<h3>
-
-Array construction: <code>[]</code>
-
+ Array construction: <code>[]</code>
</h3>
-
-<p>As in JSON, <code>[]</code> is used to construct arrays, as in <code>[1,2,3]</code>. 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 <code>[.foo, .bar, .baz]</code>) or to “collect” all the results of a filter into an array (as in <code>[.items[].name]</code>)</p>
-
-<p>Once you understand the “,” operator, you can look at jq’s array syntax in a different light: the expression <code>[1,2,3]</code> is not using a built-in syntax for comma-separated arrays, but is instead applying the <code>[]</code> operator (collect results) to the expression 1,2,3 (which produces three different results).</p>
-
-<p>If you have a filter <code>X</code> that produces four results, then the expression <code>[X]</code> will produce a single result, an array of four elements.</p>
-
+ <p>As in JSON, <code>[]</code> is used to construct arrays, as in
+<code>[1,2,3]</code>. 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 <code>[.foo, .bar, .baz]</code>) or to "collect" all the
+results of a filter into an array (as in <code>[.items[].name]</code>)</p>
+<p>Once you understand the "," operator, you can look at jq's array
+syntax in a different light: the expression <code>[1,2,3]</code> is not using a
+built-in syntax for comma-separated arrays, but is instead applying
+the <code>[]</code> operator (collect results) to the expression 1,2,3 (which
+produces three different results).</p>
+<p>If you have a filter <code>X</code> that produces four results,
+then the expression <code>[X]</code> will produce a single result, an
+array of four elements.</p>
<div>
@@ -1014,14 +1092,14 @@ Array construction: <code>[]</code>
<table>
<tr><th></th><td class="jqprogram">jq '[.user, .projects[]]'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;projects&quot;: [&quot;jq&quot;, &quot;wikiflow&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;projects&#34;: [&#34;jq&#34;, &#34;wikiflow&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;stedolan&quot;, &quot;jq&quot;, &quot;wikiflow&quot;]</td>
+ <td>[&#34;stedolan&#34;, &#34;jq&#34;, &#34;wikiflow&#34;]</td>
</tr>
</table>
@@ -1047,47 +1125,47 @@ Array construction: <code>[]</code>
<section id="ObjectConstruction:{}">
<h3>
-
-Object Construction: <code>{}</code>
-
+ Object Construction: <code>{}</code>
</h3>
-
-<p>Like JSON, <code>{}</code> is for constructing objects (aka dictionaries or hashes), as in: <code>{&quot;a&quot;: 42, &quot;b&quot;: 17}</code>.</p>
-
-<p>If the keys are “identifier-like”, then the quotes can be left off, as in <code>{a:42, b:17}</code>. Keys generated by expressions need to be parenthesized, e.g., <code>{(&quot;a&quot;+&quot;b&quot;):59}</code>.</p>
-
-<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).</p>
-
-<pre><code>{foo: .bar}</code></pre>
-
-<p>will produce the JSON object <code>{&quot;foo&quot;: 42}</code> if given the JSON object <code>{&quot;bar&quot;:42, &quot;baz&quot;:43}</code> as its input. You can use this to select particular fields of an object: if the input is an object with “user”, “title”, “id”, and “content” fields and you just want “user” and “title”, you can write</p>
-
-<pre><code>{user: .user, title: .title}</code></pre>
-
-<p>Because that is so common, there’s a shortcut syntax for it: <code>{user, title}</code>.</p>
-
-<p>If one of the expressions produces multiple results, multiple dictionaries will be produced. If the input’s</p>
-
-<pre><code>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</code></pre>
-
+ <p>Like JSON, <code>{}</code> is for constructing objects (aka
+dictionaries or hashes), as in: <code>{"a": 42, "b": 17}</code>.</p>
+<p>If the keys are "identifier-like", then the quotes can be left
+off, as in <code>{a:42, b:17}</code>. Keys generated by expressions need
+to be parenthesized, e.g., <code>{("a"+"b"):59}</code>.</p>
+<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).</p>
+<pre><code>{foo: .bar}
+</code></pre>
+<p>will produce the JSON object <code>{"foo": 42}</code> if given the JSON
+object <code>{"bar":42, "baz":43}</code> as its input. You can use this
+to select particular fields of an object: if the input is an
+object with "user", "title", "id", and "content" fields and
+you just want "user" and "title", you can write</p>
+<pre><code>{user: .user, title: .title}
+</code></pre>
+<p>Because that is so common, there's a shortcut syntax for it:
+<code>{user, title}</code>.</p>
+<p>If one of the expressions produces multiple results,
+multiple dictionaries will be produced. If the input's</p>
+<pre><code>{"user":"stedolan","titles":["JQ Primer", "More JQ"]}
+</code></pre>
<p>then the expression</p>
-
-<pre><code>{user, title: .titles[]}</code></pre>
-
+<pre><code>{user, title: .titles[]}
+</code></pre>
<p>will produce two outputs:</p>
-
-<pre><code>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;JQ Primer&quot;}
-{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;More JQ&quot;}</code></pre>
-
-<p>Putting parentheses around the key means it will be evaluated as an expression. With the same input as above,</p>
-
-<pre><code>{(.user): .titles}</code></pre>
-
+<pre><code>{"user":"stedolan", "title": "JQ Primer"}
+{"user":"stedolan", "title": "More JQ"}
+</code></pre>
+<p>Putting parentheses around the key means it will be evaluated as an
+expression. With the same input as above,</p>
+<pre><code>{(.user): .titles}
+</code></pre>
<p>produces</p>
-
-<pre><code>{&quot;stedolan&quot;: [&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</code></pre>
-
+<pre><code>{"stedolan": ["JQ Primer", "More JQ"]}
+</code></pre>
<div>
@@ -1100,35 +1178,35 @@ Object Construction: <code>{}</code>
<table>
<tr><th></th><td class="jqprogram">jq '{user, title: .titles[]}'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;,&#34;titles&#34;:[&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;JQ Primer&quot;}</td>
+ <td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;title&#34;: &#34;JQ Primer&#34;}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;user&quot;:&quot;stedolan&quot;, &quot;title&quot;: &quot;More JQ&quot;}</td>
+ <td>{&#34;user&#34;:&#34;stedolan&#34;, &#34;title&#34;: &#34;More JQ&#34;}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '{(.user): .titles}'</td></tr>
- <tr><th>Input</th><td>{&quot;user&quot;:&quot;stedolan&quot;,&quot;titles&quot;:[&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td></tr>
+ <tr><th>Input</th><td>{&#34;user&#34;:&#34;stedolan&#34;,&#34;titles&#34;:[&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;stedolan&quot;: [&quot;JQ Primer&quot;, &quot;More JQ&quot;]}</td>
+ <td>{&#34;stedolan&#34;: [&#34;JQ Primer&#34;, &#34;More JQ&#34;]}</td>
</tr>
</table>
@@ -1140,16 +1218,17 @@ Object Construction: <code>{}</code>
<section id="RecursiveDescent:..">
<h3>
-
-Recursive Descent: <code>..</code>
-
+ Recursive Descent: <code>..</code>
</h3>
-
-<p>Recursively descends <code>.</code>, producing every value. This is the same as the zero-argument <code>recurse</code> builtin (see below). This is intended to resemble the XPath <code>//</code> operator. Note that <code>..a</code> does not work; use <code>..|.a</code> instead. In the example below we use <code>..|.a?</code> to find all the values of object keys “a” in any object found “below” <code>.</code>.</p>
-
-<p>This is particularly useful in conjunction with <code>path(EXP)</code> (also see below) and the <code>?</code> operator.</p>
-
+ <p>Recursively descends <code>.</code>, producing every value. This is the
+same as the zero-argument <code>recurse</code> builtin (see below). This
+is intended to resemble the XPath <code>//</code> operator. Note that
+<code>..a</code> does not work; use <code>..|.a</code> instead. In the example
+below we use <code>..|.a?</code> to find all the values of object keys
+"a" in any object found "below" <code>.</code>.</p>
+<p>This is particularly useful in conjunction with <code>path(EXP)</code>
+(also see below) and the <code>?</code> operator.</p>
<div>
@@ -1162,7 +1241,7 @@ Recursive Descent: <code>..</code>
<table>
<tr><th></th><td class="jqprogram">jq '..|.a?'</td></tr>
- <tr><th>Input</th><td>[[{&quot;a&quot;:1}]]</td></tr>
+ <tr><th>Input</th><td>[[{&#34;a&#34;:1}]]</td></tr>
<tr>
@@ -1183,40 +1262,50 @@ Recursive Descent: <code>..</code>
<section id="Builtinoperatorsandfunctions">
<h2>Builtin operators and functions</h2>
-
-<p>Some jq operator (for instance, <code>+</code>) 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>
-
+ <p>Some jq operators (for instance, <code>+</code>) 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>
+<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>
+<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.</p>
<section id="Addition:+">
<h3>
-
-Addition: <code>+</code>
-
+ Addition: <code>+</code>
</h3>
-
-<p>The operator <code>+</code> takes two filters, applies them both to the same input, and adds the results together. What “adding” means depends on the types involved:</p>
-
+ <p>The operator <code>+</code> takes two filters, applies them both
+to the same input, and adds the results together. What
+"adding" means depends on the types involved:</p>
<ul>
<li>
<p><strong>Numbers</strong> are added by normal arithmetic.</p>
</li>
-
<li>
<p><strong>Arrays</strong> are added by being concatenated into a larger array.</p>
</li>
-
<li>
<p><strong>Strings</strong> are added by being joined into a larger string.</p>
</li>
-
<li>
-<p><strong>Objects</strong> are added by merging, that is, inserting all the key-value pairs from both objects into a single combined object. If both objects contain a value for the same key, the object on the right of the <code>+</code> wins. (For recursive merge use the <code>*</code> operator.)</p>
+<p><strong>Objects</strong> are added by merging, that is, inserting all
+ the key-value pairs from both objects into a single
+ combined object. If both objects contain a value for the
+ same key, the object on the right of the <code>+</code> wins. (For
+ recursive merge use the <code>*</code> operator.)</p>
</li>
</ul>
-
-<p><code>null</code> can be added to any value, and returns the other value unchanged.</p>
-
+<p><code>null</code> can be added to any value, and returns the other
+value unchanged.</p>
<div>
@@ -1229,7 +1318,7 @@ Addition: <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + 1'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 7}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 7}</td></tr>
<tr>
@@ -1243,7 +1332,7 @@ Addition: <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + .b'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: [1,2], &quot;b&quot;: [3,4]}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: [1,2], &#34;b&#34;: [3,4]}</td></tr>
<tr>
@@ -1257,7 +1346,7 @@ Addition: <code>+</code>
<table>
<tr><th></th><td class="jqprogram">jq '.a + null'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1}</td></tr>
<tr>
@@ -1292,7 +1381,7 @@ Addition: <code>+</code>
<th>Output</th>
- <td>{&quot;a&quot;: 42, &quot;b&quot;: 2, &quot;c&quot;: 3}</td>
+ <td>{&#34;a&#34;: 42, &#34;b&#34;: 2, &#34;c&#34;: 3}</td>
</tr>
</table>
@@ -1304,14 +1393,12 @@ Addition: <code>+</code>
<section id="Subtraction:-">
<h3>
-
-Subtraction: <code>-</code>
-
+ Subtraction: <code>-</code>
</h3>
-
-<p>As well as normal arithmetic subtraction on numbers, the <code>-</code> operator can be used on arrays to remove all occurrences of the second array’s elements from the first array.</p>
-
+ <p>As well as normal arithmetic subtraction on numbers, the <code>-</code>
+operator can be used on arrays to remove all occurrences of
+the second array's elements from the first array.</p>
<div>
@@ -1324,7 +1411,7 @@ Subtraction: <code>-</code>
<table>
<tr><th></th><td class="jqprogram">jq '4 - .a'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:3}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:3}</td></tr>
<tr>
@@ -1337,15 +1424,15 @@ Subtraction: <code>-</code>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '. - [&quot;xml&quot;, &quot;yaml&quot;]'</td></tr>
- <tr><th>Input</th><td>[&quot;xml&quot;, &quot;yaml&quot;, &quot;json&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '. - [&#34;xml&#34;, &#34;yaml&#34;]'</td></tr>
+ <tr><th>Input</th><td>[&#34;xml&#34;, &#34;yaml&#34;, &#34;json&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;json&quot;]</td>
+ <td>[&#34;json&#34;]</td>
</tr>
</table>
@@ -1357,20 +1444,19 @@ Subtraction: <code>-</code>
<section id="Multiplication,division,modulo:*,/,and%">
<h3>
-
-Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</code>
-
+ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</code>
</h3>
-
-<p>These infix operators behave as expected when given two numbers. Division by zero raises an error. <code>x % y</code> computes x modulo y.</p>
-
-<p>Multiplying a string by a number produces the concatenation of that string that many times. <code>&quot;x&quot; * 0</code> produces <strong>null</strong>.</p>
-
-<p>Dividing a string by another splits the first using the second as separators.</p>
-
-<p>Multiplying two objects will merge them recursively: this works like addition but if both objects contain a value for the same key, and the values are objects, the two are merged with the same strategy.</p>
-
+ <p>These infix operators behave as expected when given two numbers.
+Division by zero raises an error. <code>x % y</code> computes x modulo y.</p>
+<p>Multiplying a string by a number produces the concatenation of
+that string that many times. <code>"x" * 0</code> produces <strong>null</strong>.</p>
+<p>Dividing a string by another splits the first using the second
+as separators.</p>
+<p>Multiplying two objects will merge them recursively: this works
+like addition but if both objects contain a value for the
+same key, and the values are objects, the two are merged with
+the same strategy.</p>
<div>
@@ -1396,21 +1482,21 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '. / &quot;, &quot;'</td></tr>
- <tr><th>Input</th><td>&quot;a, b,c,d, e&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq '. / &#34;, &#34;'</td></tr>
+ <tr><th>Input</th><td>&#34;a, b,c,d, e&#34;</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;a&quot;,&quot;b,c,d&quot;,&quot;e&quot;]</td>
+ <td>[&#34;a&#34;,&#34;b,c,d&#34;,&#34;e&#34;]</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '{&quot;k&quot;: {&quot;a&quot;: 1, &quot;b&quot;: 2}} * {&quot;k&quot;: {&quot;a&quot;: 0,&quot;c&quot;: 3}}'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '{&#34;k&#34;: {&#34;a&#34;: 1, &#34;b&#34;: 2}} * {&#34;k&#34;: {&#34;a&#34;: 0,&#34;c&#34;: 3}}'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -1418,7 +1504,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<th>Output</th>
- <td>{&quot;k&quot;: {&quot;a&quot;: 0, &quot;b&quot;: 2, &quot;c&quot;: 3}}</td>
+ <td>{&#34;k&#34;: {&#34;a&#34;: 0, &#34;b&#34;: 2, &#34;c&#34;: 3}}</td>
</tr>
</table>
@@ -1451,33 +1537,28 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="length">
<h3>
-
-<code>length</code>
-
+ <code>length</code>
</h3>
-
-<p>The builtin function <code>length</code> gets the length of various different types of value:</p>
-
+ <p>The builtin function <code>length</code> gets the length of various
+different types of value:</p>
<ul>
<li>
-<p>The length of a <strong>string</strong> is the number of Unicode codepoints it contains (which will be the same as its JSON-encoded length in bytes if it’s pure ASCII).</p>
+<p>The length of a <strong>string</strong> is the number of Unicode
+ codepoints it contains (which will be the same as its
+ JSON-encoded length in bytes if it's pure ASCII).</p>
</li>
-
<li>
<p>The length of an <strong>array</strong> is the number of elements.</p>
</li>
-
<li>
<p>The length of an <strong>object</strong> is the number of key-value pairs.</p>
</li>
-
<li>
<p>The length of <strong>null</strong> is zero.</p>
</li>
</ul>
-
<div>
@@ -1489,7 +1570,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<table>
<tr><th></th><td class="jqprogram">jq '.[] | length'</td></tr>
- <tr><th>Input</th><td>[[1,2], &quot;string&quot;, {&quot;a&quot;:2}, null]</td></tr>
+ <tr><th>Input</th><td>[[1,2], &#34;string&#34;, {&#34;a&#34;:2}, null]</td></tr>
<tr>
@@ -1529,14 +1610,11 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="utf8bytelength">
<h3>
-
-<code>utf8bytelength</code>
-
+ <code>utf8bytelength</code>
</h3>
-
-<p>The builtin function <code>utf8bytelength</code> outputs the number of bytes used to encode a string in UTF-8.</p>
-
+ <p>The builtin function <code>utf8bytelength</code> outputs the number of
+bytes used to encode a string in UTF-8.</p>
<div>
@@ -1549,7 +1627,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<table>
<tr><th></th><td class="jqprogram">jq 'utf8bytelength'</td></tr>
- <tr><th>Input</th><td>&quot;\u03bc&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;\u03bc&#34;</td></tr>
<tr>
@@ -1568,20 +1646,21 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="keys,keys_unsorted">
<h3>
-
-<code>keys</code>, <code>keys_unsorted</code>
-
+ <code>keys</code>, <code>keys_unsorted</code>
</h3>
-
-<p>The builtin function <code>keys</code>, when given an object, returns its keys in an array.</p>
-
-<p>The keys are sorted “alphabetically”, by unicode codepoint order. This is not an order that makes particular sense in any particular language, but you can count on it being the same for any two objects with the same set of keys, regardless of locale settings.</p>
-
-<p>When <code>keys</code> is given an array, it returns the valid indices for that array: the integers from 0 to length-1.</p>
-
-<p>The <code>keys_unsorted</code> function is just like <code>keys</code>, but if the input is an object then the keys will not be sorted, instead the keys will roughly be in insertion order.</p>
-
+ <p>The builtin function <code>keys</code>, when given an object, returns
+its keys in an array.</p>
+<p>The keys are sorted "alphabetically", by unicode codepoint
+order. This is not an order that makes particular sense in
+any particular language, but you can count on it being the
+same for any two objects with the same set of keys,
+regardless of locale settings.</p>
+<p>When <code>keys</code> is given an array, it returns the valid indices
+for that array: the integers from 0 to length-1.</p>
+<p>The <code>keys_unsorted</code> function is just like <code>keys</code>, but if
+the input is an object then the keys will not be sorted,
+instead the keys will roughly be in insertion order.</p>
<div>
@@ -1594,14 +1673,14 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<table>
<tr><th></th><td class="jqprogram">jq 'keys'</td></tr>
- <tr><th>Input</th><td>{&quot;abc&quot;: 1, &quot;abcd&quot;: 2, &quot;Foo&quot;: 3}</td></tr>
+ <tr><th>Input</th><td>{&#34;abc&#34;: 1, &#34;abcd&#34;: 2, &#34;Foo&#34;: 3}</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;Foo&quot;, &quot;abc&quot;, &quot;abcd&quot;]</td>
+ <td>[&#34;Foo&#34;, &#34;abc&#34;, &#34;abcd&#34;]</td>
</tr>
</table>
@@ -1627,16 +1706,15 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="has(key)">
<h3>
-
-<code>has(key)</code>
-
+ <code>has(key)</code>
</h3>
-
-<p>The builtin function <code>has</code> returns whether the input object has the given key, or the input array has an element at the given index.</p>
-
-<p><code>has($key)</code> has the same effect as checking whether <code>$key</code> is a member of the array returned by <code>keys</code>, although <code>has</code> will be faster.</p>
-
+ <p>The builtin function <code>has</code> returns whether the input object
+has the given key, or the input array has an element at the
+given index.</p>
+<p><code>has($key)</code> has the same effect as checking whether <code>$key</code>
+is a member of the array returned by <code>keys</code>, although <code>has</code>
+will be faster.</p>
<div>
@@ -1648,8 +1726,8 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<div id="example19" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'map(has(&quot;foo&quot;))'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;: 42}, {}]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'map(has(&#34;foo&#34;))'</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;: 42}, {}]</td></tr>
<tr>
@@ -1663,7 +1741,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<table>
<tr><th></th><td class="jqprogram">jq 'map(has(2))'</td></tr>
- <tr><th>Input</th><td>[[0,1], [&quot;a&quot;,&quot;b&quot;,&quot;c&quot;]]</td></tr>
+ <tr><th>Input</th><td>[[0,1], [&#34;a&#34;,&#34;b&#34;,&#34;c&#34;]]</td></tr>
<tr>
@@ -1682,14 +1760,13 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="in">
<h3>
-
-<code>in</code>
-
+ <code>in</code>
</h3>
-
-<p>The builtin function <code>in</code> returns whether or not the input key is in the given object, or the input index corresponds to an element in the given array. It is, essentially, an inversed version of <code>has</code>.</p>
-
+ <p>The builtin function <code>in</code> returns whether or not the input key is in the
+given object, or the input index corresponds to an element
+in the given array. It is, essentially, an inversed version
+of <code>has</code>.</p>
<div>
@@ -1701,8 +1778,8 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<div id="example20" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '.[] | in({&quot;foo&quot;: 42})'</td></tr>
- <tr><th>Input</th><td>[&quot;foo&quot;, &quot;bar&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[] | in({&#34;foo&#34;: 42})'</td></tr>
+ <tr><th>Input</th><td>[&#34;foo&#34;, &#34;bar&#34;]</td></tr>
<tr>
@@ -1742,18 +1819,16 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="map(x),map_values(x)">
<h3>
-
-<code>map(x)</code>, <code>map_values(x)</code>
-
+ <code>map(x)</code>, <code>map_values(x)</code>
</h3>
-
-<p>For any filter <code>x</code>, <code>map(x)</code> will run that filter for each element of the input array, and return the outputs in a new array. <code>map(.+1)</code> will increment each element of an array of numbers.</p>
-
-<p>Similarly, <code>map_values(x)</code> will run that filter for each element, but it will return an object when an object is passed.</p>
-
-<p><code>map(x)</code> is equivalent to <code>[.[] | x]</code>. In fact, this is how it’s defined. Similarly, <code>map_values(x)</code> is defined as <code>.[] |= x</code>.</p>
-
+ <p>For any filter <code>x</code>, <code>map(x)</code> will run that filter for each
+element of the input array, and return the outputs in a new
+array. <code>map(.+1)</code> will increment each element of an array of numbers.</p>
+<p>Similarly, <code>map_values(x)</code> will run that filter for each element,
+but it will return an object when an object is passed.</p>
+<p><code>map(x)</code> is equivalent to <code>[.[] | x]</code>. In fact, this is how
+it's defined. Similarly, <code>map_values(x)</code> is defined as <code>.[] |= x</code>.</p>
<div>
@@ -1780,14 +1855,14 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<table>
<tr><th></th><td class="jqprogram">jq 'map_values(.+1)'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: 3}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 2, &#34;c&#34;: 3}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;: 2, &quot;b&quot;: 3, &quot;c&quot;: 4}</td>
+ <td>{&#34;a&#34;: 2, &#34;b&#34;: 3, &#34;c&#34;: 4}</td>
</tr>
</table>
@@ -1799,22 +1874,25 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="path(path_expression)">
<h3>
-
-<code>path(path_expression)</code>
-
+ <code>path(path_expression)</code>
</h3>
-
-<p>Outputs array representations of the given path expression in <code>.</code>. The outputs are arrays of strings (object keys) and/or numbers (array indices).</p>
-
-<p>Path expressions are jq expressions like <code>.a</code>, but also <code>.[]</code>. There are two types of path expressions: ones that can match exactly, and ones that cannot. For example, <code>.a.b.c</code> is an exact match path expression, while <code>.a[].b</code> is not.</p>
-
-<p><code>path(exact_path_expression)</code> will produce the array representation of the path expression even if it does not exist in <code>.</code>, if <code>.</code> is <code>null</code> or an array or an object.</p>
-
-<p><code>path(pattern)</code> will produce array representations of the paths matching <code>pattern</code> if the paths exist in <code>.</code>.</p>
-
-<p>Note that the path expressions are not different from normal expressions. The expression <code>path(..|select(type==&quot;boolean&quot;))</code> outputs all the paths to boolean values in <code>.</code>, and only those paths.</p>
-
+ <p>Outputs array representations of the given path expression
+in <code>.</code>. The outputs are arrays of strings (object keys)
+and/or numbers (array indices).</p>
+<p>Path expressions are jq expressions like <code>.a</code>, but also <code>.[]</code>.
+There are two types of path expressions: ones that can match
+exactly, and ones that cannot. For example, <code>.a.b.c</code> is an
+exact match path expression, while <code>.a[].b</code> is not.</p>
+<p><code>path(exact_path_expression)</code> will produce the array
+representation of the path expression even if it does not
+exist in <code>.</code>, if <code>.</code> is <code>null</code> or an array or an object.</p>
+<p><code>path(pattern)</code> will produce array representations of the
+paths matching <code>pattern</code> if the paths exist in <code>.</code>.</p>
+<p>Note that the path expressions are not different from normal
+expressions. The expression
+<code>path(..|select(type=="boolean"))</code> outputs all the paths to
+boolean values in <code>.</code>, and only those paths.</p>
<div>
@@ -1834,21 +1912,21 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<th>Output</th>
- <td>[&quot;a&quot;,0,&quot;b&quot;]</td>
+ <td>[&#34;a&#34;,0,&#34;b&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[path(..)]'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:[{&quot;b&quot;:1}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:[{&#34;b&#34;:1}]}</td></tr>
<tr>
<th>Output</th>
- <td>[[],[&quot;a&quot;],[&quot;a&quot;,0],[&quot;a&quot;,0,&quot;b&quot;]]</td>
+ <td>[[],[&#34;a&#34;],[&#34;a&#34;,0],[&#34;a&#34;,0,&#34;b&#34;]]</td>
</tr>
</table>
@@ -1860,14 +1938,11 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="del(path_expression)">
<h3>
-
-<code>del(path_expression)</code>
-
+ <code>del(path_expression)</code>
</h3>
-
-<p>The builtin function <code>del</code> removes a key and its corresponding value from an object.</p>
-
+ <p>The builtin function <code>del</code> removes a key and its corresponding
+value from an object.</p>
<div>
@@ -1880,28 +1955,28 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<table>
<tr><th></th><td class="jqprogram">jq 'del(.foo)'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42, &quot;bar&quot;: 9001, &quot;baz&quot;: 42}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42, &#34;bar&#34;: 9001, &#34;baz&#34;: 42}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;bar&quot;: 9001, &quot;baz&quot;: 42}</td>
+ <td>{&#34;bar&#34;: 9001, &#34;baz&#34;: 42}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'del(.[1, 2])'</td></tr>
- <tr><th>Input</th><td>[&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;foo&#34;, &#34;bar&#34;, &#34;baz&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;foo&quot;]</td>
+ <td>[&#34;foo&#34;]</td>
</tr>
</table>
@@ -1913,14 +1988,11 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="getpath(PATHS)">
<h3>
-
-<code>getpath(PATHS)</code>
-
+ <code>getpath(PATHS)</code>
</h3>
-
-<p>The builtin function <code>getpath</code> outputs the values in <code>.</code> found at each path in <code>PATHS</code>.</p>
-
+ <p>The builtin function <code>getpath</code> outputs the values in <code>.</code> found
+at each path in <code>PATHS</code>.</p>
<div>
@@ -1932,7 +2004,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<div id="example24" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'getpath([&quot;a&quot;,&quot;b&quot;])'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'getpath([&#34;a&#34;,&#34;b&#34;])'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -1946,8 +2018,8 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '[getpath([&quot;a&quot;,&quot;b&quot;], [&quot;a&quot;,&quot;c&quot;])]'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:{&quot;b&quot;:0, &quot;c&quot;:1}}</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[getpath([&#34;a&#34;,&#34;b&#34;], [&#34;a&#34;,&#34;c&#34;])]'</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:{&#34;b&#34;:0, &#34;c&#34;:1}}</td></tr>
<tr>
@@ -1966,14 +2038,10 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="setpath(PATHS;VALUE)">
<h3>
-
-<code>setpath(PATHS; VALUE)</code>
-
+ <code>setpath(PATHS; VALUE)</code>
</h3>
-
-<p>The builtin function <code>setpath</code> sets the <code>PATHS</code> in <code>.</code> to <code>VALUE</code>.</p>
-
+ <p>The builtin function <code>setpath</code> sets the <code>PATHS</code> in <code>.</code> to <code>VALUE</code>.</p>
<div>
@@ -1985,7 +2053,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<div id="example25" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'setpath([&quot;a&quot;,&quot;b&quot;]; 1)'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'setpath([&#34;a&#34;,&#34;b&#34;]; 1)'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -1993,27 +2061,27 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<th>Output</th>
- <td>{&quot;a&quot;: {&quot;b&quot;: 1}}</td>
+ <td>{&#34;a&#34;: {&#34;b&#34;: 1}}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'setpath([&quot;a&quot;,&quot;b&quot;]; 1)'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:{&quot;b&quot;:0}}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'setpath([&#34;a&#34;,&#34;b&#34;]; 1)'</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:{&#34;b&#34;:0}}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;: {&quot;b&quot;: 1}}</td>
+ <td>{&#34;a&#34;: {&#34;b&#34;: 1}}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'setpath([0,&quot;a&quot;]; 1)'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'setpath([0,&#34;a&#34;]; 1)'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -2021,7 +2089,7 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<th>Output</th>
- <td>[{&quot;a&quot;:1}]</td>
+ <td>[{&#34;a&#34;:1}]</td>
</tr>
</table>
@@ -2033,14 +2101,12 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="delpaths(PATHS)">
<h3>
-
-<code>delpaths(PATHS)</code>
-
+ <code>delpaths(PATHS)</code>
</h3>
-
-<p>The builtin function <code>delpaths</code> sets the <code>PATHS</code> in <code>.</code>. <code>PATHS</code> must be an array of paths, where each path is an array of strings and numbers.</p>
-
+ <p>The builtin function <code>delpaths</code> sets the <code>PATHS</code> in <code>.</code>.
+<code>PATHS</code> must be an array of paths, where each path is an array
+of strings and numbers.</p>
<div>
@@ -2052,15 +2118,15 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<div id="example26" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'delpaths([[&quot;a&quot;,&quot;b&quot;]])'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:{&quot;b&quot;:1},&quot;x&quot;:{&quot;y&quot;:2}}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'delpaths([[&#34;a&#34;,&#34;b&#34;]])'</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:{&#34;b&#34;:1},&#34;x&#34;:{&#34;y&#34;:2}}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;:{},&quot;x&quot;:{&quot;y&quot;:2}}</td>
+ <td>{&#34;a&#34;:{},&#34;x&#34;:{&#34;y&#34;:2}}</td>
</tr>
</table>
@@ -2072,17 +2138,18 @@ Multiplication, division, modulo: <code>*</code>, <code>/</code>, and <code>%</c
<section id="to_entries,from_entries,with_entries">
<h3>
-
-<code>to_entries</code>, <code>from_entries</code>, <code>with_entries</code>
-
+ <code>to_entries</code>, <code>from_entries</code>, <code>with_entries</code>
</h3>
-
-<p>These functions convert between an object and an array of key-value pairs. If <code>to_entries</code> is passed an object, then for each <code>k: v</code> entry in the input, the output array includes <code>{&quot;key&quot;: k, &quot;value&quot;: v}</code>.</p>
-
-<p><code>from_entries</code> does the opposite conversion, and <code>with_entries(foo)</code> is a shorthand for <code>to_entries |
-map(foo) | from_entries</code>, useful for doing some operation to all keys and values of an object. <code>from_entries</code> accepts key, Key, name, Name, value and Value as keys.</p>
-
+ <p>These functions convert between an object and an array of
+key-value pairs. If <code>to_entries</code> is passed an object, then
+for each <code>k: v</code> entry in the input, the output array
+includes <code>{"key": k, "value": v}</code>.</p>
+<p><code>from_entries</code> does the opposite conversion, and
+<code>with_entries(foo)</code> is a shorthand for <code>to_entries |
+map(foo) | from_entries</code>, useful for doing some operation to
+all keys and values of an object. <code>from_entries</code> accepts key, Key,
+name, Name, value and Value as keys.</p>
<div>
@@ -2095,42 +2162,42 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'to_entries'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;key&quot;:&quot;a&quot;, &quot;value&quot;:1}, {&quot;key&quot;:&quot;b&quot;, &quot;value&quot;:2}]</td>
+ <td>[{&#34;key&#34;:&#34;a&#34;, &#34;value&#34;:1}, {&#34;key&#34;:&#34;b&#34;, &#34;value&#34;:2}]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'from_entries'</td></tr>
- <tr><th>Input</th><td>[{&quot;key&quot;:&quot;a&quot;, &quot;value&quot;:1}, {&quot;key&quot;:&quot;b&quot;, &quot;value&quot;:2}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;key&#34;:&#34;a&#34;, &#34;value&#34;:1}, {&#34;key&#34;:&#34;b&#34;, &#34;value&#34;:2}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td>
+ <td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'with_entries(.key |= &quot;KEY_&quot; + .)'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;: 1, &quot;b&quot;: 2}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'with_entries(.key |= &#34;KEY_&#34; + .)'</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;: 1, &#34;b&#34;: 2}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;KEY_a&quot;: 1, &quot;KEY_b&quot;: 2}</td>
+ <td>{&#34;KEY_a&#34;: 1, &#34;KEY_b&#34;: 2}</td>
</tr>
</table>
@@ -2142,16 +2209,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="select(boolean_expression)">
<h3>
-
-<code>select(boolean_expression)</code>
-
+ <code>select(boolean_expression)</code>
</h3>
-
-<p>The function <code>select(foo)</code> produces its input unchanged if <code>foo</code> returns true for that input, and produces no output otherwise.</p>
-
-<p>It’s useful for filtering lists: <code>[1,2,3] | map(select(. &gt;= 2))</code> will give you <code>[2,3]</code>.</p>
-
+ <p>The function <code>select(foo)</code> produces its input unchanged if
+<code>foo</code> returns true for that input, and produces no output
+otherwise.</p>
+<p>It's useful for filtering lists: <code>[1,2,3] | map(select(. &gt;= 2))</code>
+will give you <code>[2,3]</code>.</p>
<div>
@@ -2177,15 +2242,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[] | select(.id == &quot;second&quot;)'</td></tr>
- <tr><th>Input</th><td>[{&quot;id&quot;: &quot;first&quot;, &quot;val&quot;: 1}, {&quot;id&quot;: &quot;second&quot;, &quot;val&quot;: 2}]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[] | select(.id == &#34;second&#34;)'</td></tr>
+ <tr><th>Input</th><td>[{&#34;id&#34;: &#34;first&#34;, &#34;val&#34;: 1}, {&#34;id&#34;: &#34;second&#34;, &#34;val&#34;: 2}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;id&quot;: &quot;second&quot;, &quot;val&quot;: 2}</td>
+ <td>{&#34;id&#34;: &#34;second&#34;, &#34;val&#34;: 2}</td>
</tr>
</table>
@@ -2197,14 +2262,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="arrays,objects,iterables,booleans,numbers,normals,finites,strings,nulls,values,scalars">
<h3>
-
-<code>arrays</code>, <code>objects</code>, <code>iterables</code>, <code>booleans</code>, <code>numbers</code>, <code>normals</code>, <code>finites</code>, <code>strings</code>, <code>nulls</code>, <code>values</code>, <code>scalars</code>
-
+ <code>arrays</code>, <code>objects</code>, <code>iterables</code>, <code>booleans</code>, <code>numbers</code>, <code>normals</code>, <code>finites</code>, <code>strings</code>, <code>nulls</code>, <code>values</code>, <code>scalars</code>
</h3>
-
-<p>These built-ins select only inputs that are arrays, objects, iterables (arrays or objects), booleans, numbers, normal numbers, finite numbers, strings, null, non-null values, and non-iterables, respectively.</p>
-
+ <p>These built-ins select only inputs that are arrays, objects,
+iterables (arrays or objects), booleans, numbers, normal
+numbers, finite numbers, strings, null, non-null values, and
+non-iterables, respectively.</p>
<div>
@@ -2217,7 +2281,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[]|numbers'</td></tr>
- <tr><th>Input</th><td>[[],{},1,&quot;foo&quot;,null,true,false]</td></tr>
+ <tr><th>Input</th><td>[[],{},1,&#34;foo&#34;,null,true,false]</td></tr>
<tr>
@@ -2236,16 +2300,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="empty">
<h3>
-
-<code>empty</code>
-
+ <code>empty</code>
</h3>
-
-<p><code>empty</code> returns no results. None at all. Not even <code>null</code>.</p>
-
-<p>It’s useful on occasion. You’ll know if you need it :)</p>
-
+ <p><code>empty</code> returns no results. None at all. Not even <code>null</code>.</p>
+<p>It's useful on occasion. You'll know if you need it :)</p>
<div>
@@ -2298,60 +2357,50 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="error(message)">
<h3>
-
-<code>error(message)</code>
-
+ <code>error(message)</code>
</h3>
-
-<p>Produces an error, just like <code>.a</code> applied to values other than null and objects would, but with the given message as the error’s value. Errors can be caught with try/catch; see below.</p>
-
+ <p>Produces an error, just like <code>.a</code> applied to values other than
+null and objects would, but with the given message as the
+error's value. Errors can be caught with try/catch; see below.</p>
</section>
<section id="halt">
<h3>
-
-<code>halt</code>
-
+ <code>halt</code>
</h3>
-
-<p>Stops the jq program with no further outputs. jq will exit with exit status <code>0</code>.</p>
-
+ <p>Stops the jq program with no further outputs. jq will exit
+with exit status <code>0</code>.</p>
</section>
<section id="halt_error,halt_error(exit_code)">
<h3>
-
-<code>halt_error</code>, <code>halt_error(exit_code)</code>
-
+ <code>halt_error</code>, <code>halt_error(exit_code)</code>
</h3>
-
-<p>Stops the jq program with no further outputs. The input will be printed on <code>stderr</code> as raw output (i.e., strings will not have double quotes) with no decoration, not even a newline.</p>
-
-<p>The given <code>exit_code</code> (defaulting to <code>5</code>) will be jq’s exit status.</p>
-
-<p>For example, <code>&quot;Error: somthing went wrong\n&quot;|halt_error(1)</code>.</p>
-
+ <p>Stops the jq program with no further outputs. The input will
+be printed on <code>stderr</code> as raw output (i.e., strings will not
+have double quotes) with no decoration, not even a newline.</p>
+<p>The given <code>exit_code</code> (defaulting to <code>5</code>) will be jq's exit
+status.</p>
+<p>For example, <code>"Error: somthing went wrong\n"|halt_error(1)</code>.</p>
</section>
<section id="$__loc__">
<h3>
-
-<code>$__loc__</code>
-
+ <code>$__loc__</code>
</h3>
-
-<p>Produces an object with a “file” key and a “line” key, with the filename and line number where <code>$__loc__</code> occurs, as values.</p>
-
+ <p>Produces an object with a "file" key and a "line" key, with
+the filename and line number where <code>$__loc__</code> occurs, as
+values.</p>
<div>
@@ -2363,7 +2412,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example31" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'try error(&quot;\($__loc__)&quot;) catch .'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'try error(&#34;\($__loc__)&#34;) catch .'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -2371,7 +2420,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;{\&quot;file\&quot;:\&quot;&lt;top-level&gt;\&quot;,\&quot;line\&quot;:1}&quot;</td>
+ <td>&#34;{\&#34;file\&#34;:\&#34;&lt;top-level&gt;\&#34;,\&#34;line\&#34;:1}&#34;</td>
</tr>
</table>
@@ -2383,18 +2432,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="paths,paths(node_filter),leaf_paths">
<h3>
-
-<code>paths</code>, <code>paths(node_filter)</code>, <code>leaf_paths</code>
-
+ <code>paths</code>, <code>paths(node_filter)</code>, <code>leaf_paths</code>
</h3>
-
-<p><code>paths</code> outputs the paths to all the elements in its input (except it does not output the empty list, representing . itself).</p>
-
-<p><code>paths(f)</code> outputs the paths to any values for which <code>f</code> is true. That is, <code>paths(numbers)</code> outputs the paths to all numeric values.</p>
-
-<p><code>leaf_paths</code> is an alias of <code>paths(scalars)</code>; <code>leaf_paths</code> is <em>deprecated</em> and will be removed in the next major release.</p>
-
+ <p><code>paths</code> outputs the paths to all the elements in its input
+(except it does not output the empty list, representing .
+itself).</p>
+<p><code>paths(f)</code> outputs the paths to any values for which <code>f</code> is true.
+That is, <code>paths(numbers)</code> outputs the paths to all numeric
+values.</p>
+<p><code>leaf_paths</code> is an alias of <code>paths(scalars)</code>; <code>leaf_paths</code> is
+<em>deprecated</em> and will be removed in the next major release.</p>
<div>
@@ -2407,28 +2455,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '[paths]'</td></tr>
- <tr><th>Input</th><td>[1,[[],{&quot;a&quot;:2}]]</td></tr>
+ <tr><th>Input</th><td>[1,[[],{&#34;a&#34;:2}]]</td></tr>
<tr>
<th>Output</th>
- <td>[[0],[1],[1,0],[1,1],[1,1,&quot;a&quot;]]</td>
+ <td>[[0],[1],[1,0],[1,1],[1,1,&#34;a&#34;]]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[paths(scalars)]'</td></tr>
- <tr><th>Input</th><td>[1,[[],{&quot;a&quot;:2}]]</td></tr>
+ <tr><th>Input</th><td>[1,[[],{&#34;a&#34;:2}]]</td></tr>
<tr>
<th>Output</th>
- <td>[[0],[1,1,&quot;a&quot;]]</td>
+ <td>[[0],[1,1,&#34;a&#34;]]</td>
</tr>
</table>
@@ -2440,17 +2488,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="add">
<h3>
-
-<code>add</code>
-
+ <code>add</code>
</h3>
-
-<p>The filter <code>add</code> takes as input an array, and produces as output the elements of the array added together. This might mean summed, concatenated or merged depending on the types of the elements of the input array - the rules are the same as those for the <code>+</code> operator (described above).</p>
-
+ <p>The filter <code>add</code> takes as input an array, and produces as
+output the elements of the array added together. This might
+mean summed, concatenated or merged depending on the types
+of the elements of the input array - the rules are the same
+as those for the <code>+</code> operator (described above).</p>
<p>If the input is an empty array, <code>add</code> returns <code>null</code>.</p>
-
<div>
@@ -2462,14 +2509,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'add'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b&#34;,&#34;c&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;abc&quot;</td>
+ <td>&#34;abc&#34;</td>
</tr>
</table>
@@ -2509,20 +2556,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="any,any(condition),any(generator;condition)">
<h3>
-
-<code>any</code>, <code>any(condition)</code>, <code>any(generator; condition)</code>
-
+ <code>any</code>, <code>any(condition)</code>, <code>any(generator; condition)</code>
</h3>
-
-<p>The filter <code>any</code> takes as input an array of boolean values, and produces <code>true</code> as output if any of the elements of the array are <code>true</code>.</p>
-
+ <p>The filter <code>any</code> takes as input an array of boolean values,
+and produces <code>true</code> as output if any of the elements of
+the array are <code>true</code>.</p>
<p>If the input is an empty array, <code>any</code> returns <code>false</code>.</p>
-
-<p>The <code>any(condition)</code> form applies the given condition to the elements of the input array.</p>
-
-<p>The <code>any(generator; condition)</code> form applies the given condition to all the outputs of the given generator.</p>
-
+<p>The <code>any(condition)</code> form applies the given condition to the
+elements of the input array.</p>
+<p>The <code>any(generator; condition)</code> form applies the given
+condition to all the outputs of the given generator.</p>
<div>
@@ -2582,21 +2626,18 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="all,all(condition),all(generator;condition)">
<h3>
-
-<code>all</code>, <code>all(condition)</code>, <code>all(generator; condition)</code>
-
+ <code>all</code>, <code>all(condition)</code>, <code>all(generator; condition)</code>
</h3>
-
-<p>The filter <code>all</code> takes as input an array of boolean values, and produces <code>true</code> as output if all of the elements of the array are <code>true</code>.</p>
-
-<p>The <code>all(condition)</code> form applies the given condition to the elements of the input array.</p>
-
-<p>The <code>all(generator; condition)</code> form applies the given condition to all the outputs of the given generator.</p>
-
+ <p>The filter <code>all</code> takes as input an array of boolean values,
+and produces <code>true</code> as output if all of the elements of
+the array are <code>true</code>.</p>
+<p>The <code>all(condition)</code> form applies the given condition to the
+elements of the input array.</p>
+<p>The <code>all(generator; condition)</code> form applies the given
+condition to all the outputs of the given generator.</p>
<p>If the input is an empty array, <code>all</code> returns <code>true</code>.</p>
-
<div>
@@ -2655,16 +2696,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="flatten,flatten(depth)">
<h3>
-
-<code>flatten</code>, <code>flatten(depth)</code>
-
+ <code>flatten</code>, <code>flatten(depth)</code>
</h3>
-
-<p>The filter <code>flatten</code> takes as input an array of nested arrays, and produces a flat array in which all arrays inside the original array have been recursively replaced by their values. You can pass an argument to it to specify how many levels of nesting to flatten.</p>
-
-<p><code>flatten(2)</code> is like <code>flatten</code>, but going only up to two levels deep.</p>
-
+ <p>The filter <code>flatten</code> takes as input an array of nested arrays,
+and produces a flat array in which all arrays inside the original
+array have been recursively replaced by their values. You can pass
+an argument to it to specify how many levels of nesting to flatten.</p>
+<p><code>flatten(2)</code> is like <code>flatten</code>, but going only up to two
+levels deep.</p>
<div>
@@ -2719,14 +2759,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'flatten'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;: &quot;bar&quot;}, [{&quot;foo&quot;: &quot;baz&quot;}]]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;: &#34;bar&#34;}, [{&#34;foo&#34;: &#34;baz&#34;}]]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;foo&quot;: &quot;bar&quot;}, {&quot;foo&quot;: &quot;baz&quot;}]</td>
+ <td>[{&#34;foo&#34;: &#34;bar&#34;}, {&#34;foo&#34;: &#34;baz&#34;}]</td>
</tr>
</table>
@@ -2738,20 +2778,19 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="range(upto),range(from;upto)range(from;upto;by)">
<h3>
-
-<code>range(upto)</code>, <code>range(from;upto)</code> <code>range(from;upto;by)</code>
-
+ <code>range(upto)</code>, <code>range(from;upto)</code> <code>range(from;upto;by)</code>
</h3>
-
-<p>The <code>range</code> function produces a range of numbers. <code>range(4;10)</code> produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers are produced as separate outputs. Use <code>[range(4;10)]</code> to get a range as an array.</p>
-
-<p>The one argument form generates numbers from 0 to the given number, with an increment of 1.</p>
-
-<p>The two argument form generates numbers from <code>from</code> to <code>upto</code> with an increment of 1.</p>
-
-<p>The three argument form generates numbers <code>from</code> to <code>upto</code> with an increment of <code>by</code>.</p>
-
+ <p>The <code>range</code> function produces a range of numbers. <code>range(4;10)</code>
+produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers
+are produced as separate outputs. Use <code>[range(4;10)]</code> to get a range as
+an array.</p>
+<p>The one argument form generates numbers from 0 to the given
+number, with an increment of 1.</p>
+<p>The two argument form generates numbers from <code>from</code> to <code>upto</code>
+with an increment of 1.</p>
+<p>The three argument form generates numbers <code>from</code> to <code>upto</code>
+with an increment of <code>by</code>.</p>
<div>
@@ -2860,14 +2899,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="floor">
<h3>
-
-<code>floor</code>
-
+ <code>floor</code>
</h3>
-
-<p>The <code>floor</code> function returns the floor of its numeric input.</p>
-
+ <p>The <code>floor</code> function returns the floor of its numeric input.</p>
<div>
@@ -2899,14 +2934,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="sqrt">
<h3>
-
-<code>sqrt</code>
-
+ <code>sqrt</code>
</h3>
-
-<p>The <code>sqrt</code> function returns the square root of its numeric input.</p>
-
+ <p>The <code>sqrt</code> function returns the square root of its numeric input.</p>
<div>
@@ -2938,14 +2969,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="tonumber">
<h3>
-
-<code>tonumber</code>
-
+ <code>tonumber</code>
</h3>
-
-<p>The <code>tonumber</code> function parses its input as a number. It will convert correctly-formatted strings to their numeric equivalent, leave numbers alone, and give an error on all other input.</p>
-
+ <p>The <code>tonumber</code> function parses its input as a number. It
+will convert correctly-formatted strings to their numeric
+equivalent, leave numbers alone, and give an error on all other input.</p>
<div>
@@ -2958,7 +2987,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[] | tonumber'</td></tr>
- <tr><th>Input</th><td>[1, &quot;1&quot;]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;1&#34;]</td></tr>
<tr>
@@ -2984,14 +3013,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="tostring">
<h3>
-
-<code>tostring</code>
-
+ <code>tostring</code>
</h3>
-
-<p>The <code>tostring</code> function prints its input as a string. Strings are left unchanged, and all other values are JSON-encoded.</p>
-
+ <p>The <code>tostring</code> function prints its input as a
+string. Strings are left unchanged, and all other values are
+JSON-encoded.</p>
<div>
@@ -3004,28 +3031,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq '.[] | tostring'</td></tr>
- <tr><th>Input</th><td>[1, &quot;1&quot;, [1]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;1&#34;, [1]]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;1&quot;</td>
+ <td>&#34;1&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;1&quot;</td>
+ <td>&#34;1&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;[1]&quot;</td>
+ <td>&#34;[1]&#34;</td>
</tr>
</table>
@@ -3037,14 +3064,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="type">
<h3>
-
-<code>type</code>
-
+ <code>type</code>
</h3>
-
-<p>The <code>type</code> function returns the type of its argument as a string, which is one of null, boolean, number, string, array or object.</p>
-
+ <p>The <code>type</code> function returns the type of its argument as a
+string, which is one of null, boolean, number, string, array
+or object.</p>
<div>
@@ -3057,14 +3082,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'map(type)'</td></tr>
- <tr><th>Input</th><td>[0, false, [], {}, null, &quot;hello&quot;]</td></tr>
+ <tr><th>Input</th><td>[0, false, [], {}, null, &#34;hello&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;number&quot;, &quot;boolean&quot;, &quot;array&quot;, &quot;object&quot;, &quot;null&quot;, &quot;string&quot;]</td>
+ <td>[&#34;number&#34;, &#34;boolean&#34;, &#34;array&#34;, &#34;object&#34;, &#34;null&#34;, &#34;string&#34;]</td>
</tr>
</table>
@@ -3076,18 +3101,19 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="infinite,nan,isinfinite,isnan,isfinite,isnormal">
<h3>
-
-<code>infinite</code>, <code>nan</code>, <code>isinfinite</code>, <code>isnan</code>, <code>isfinite</code>, <code>isnormal</code>
-
+ <code>infinite</code>, <code>nan</code>, <code>isinfinite</code>, <code>isnan</code>, <code>isfinite</code>, <code>isnormal</code>
</h3>
-
-<p>Some arithmetic operations can yield infinities and “not a number” (NaN) values. The <code>isinfinite</code> builtin returns <code>true</code> if its input is infinite. The <code>isnan</code> builtin returns <code>true</code> if its input is a NaN. The <code>infinite</code> builtin returns a positive infinite value. The <code>nan</code> builtin returns a NaN. The <code>isnormal</code> builtin returns true if its input is a normal number.</p>
-
+ <p>Some arithmetic operations can yield infinities and "not a
+number" (NaN) values. The <code>isinfinite</code> builtin returns <code>true</code>
+if its input is infinite. The <code>isnan</code> builtin returns <code>true</code>
+if its input is a NaN. The <code>infinite</code> builtin returns a
+positive infinite value. The <code>nan</code> builtin returns a NaN.
+The <code>isnormal</code> builtin returns true if its input is a normal
+number.</p>
<p>Note that division by zero raises an error.</p>
-
-<p>Currently most arithmetic operations operating on infinities, NaNs, and sub-normals do not raise errors.</p>
-
+<p>Currently most arithmetic operations operating on infinities,
+NaNs, and sub-normals do not raise errors.</p>
<div>
@@ -3128,14 +3154,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;number&quot;</td>
+ <td>&#34;number&#34;</td>
</tr>
<tr>
<th></th>
- <td>&quot;number&quot;</td>
+ <td>&#34;number&#34;</td>
</tr>
</table>
@@ -3147,36 +3173,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="sort,sort_by(path_expression)">
<h3>
-
-<code>sort, sort_by(path_expression)</code>
-
+ <code>sort, sort_by(path_expression)</code>
</h3>
-
-<p>The <code>sort</code> functions sorts its input, which must be an array. Values are sorted in the following order:</p>
-
+ <p>The <code>sort</code> functions sorts its input, which must be an
+array. Values are sorted in the following order:</p>
<ul>
<li><code>null</code></li>
-
<li><code>false</code></li>
-
<li><code>true</code></li>
-
<li>numbers</li>
-
<li>strings, in alphabetical order (by unicode codepoint value)</li>
-
<li>arrays, in lexical order</li>
-
<li>objects</li>
</ul>
-
-<p>The ordering for objects is a little complex: first they’re compared by comparing their sets of keys (as arrays in sorted order), and if their keys are equal then the values are compared key by key.</p>
-
-<p><code>sort</code> may be used to sort by a particular field of an object, or by applying any jq filter.</p>
-
-<p><code>sort_by(foo)</code> compares two elements by comparing the result of <code>foo</code> on each element.</p>
-
+<p>The ordering for objects is a little complex: first they're
+compared by comparing their sets of keys (as arrays in
+sorted order), and if their keys are equal then the values
+are compared key by key.</p>
+<p><code>sort</code> may be used to sort by a particular field of an
+object, or by applying any jq filter.</p>
+<p><code>sort_by(foo)</code> compares two elements by comparing the result of
+<code>foo</code> on each element.</p>
<div>
@@ -3203,14 +3221,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'sort_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:4, &quot;bar&quot;:10}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:2, &quot;bar&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:4, &#34;bar&#34;:10}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:2, &#34;bar&#34;:1}]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;foo&quot;:2, &quot;bar&quot;:1}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:4, &quot;bar&quot;:10}]</td>
+ <td>[{&#34;foo&#34;:2, &#34;bar&#34;:1}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:4, &#34;bar&#34;:10}]</td>
</tr>
</table>
@@ -3222,16 +3240,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="group_by(path_expression)">
<h3>
-
-<code>group_by(path_expression)</code>
-
+ <code>group_by(path_expression)</code>
</h3>
-
-<p><code>group_by(.foo)</code> takes as input an array, groups the elements having the same <code>.foo</code> field into separate arrays, and produces all of these arrays as elements of a larger array, sorted by the value of the <code>.foo</code> field.</p>
-
-<p>Any jq expression, not just a field access, may be used in place of <code>.foo</code>. The sorting order is the same as described in the <code>sort</code> function above.</p>
-
+ <p><code>group_by(.foo)</code> takes as input an array, groups the
+elements having the same <code>.foo</code> field into separate arrays,
+and produces all of these arrays as elements of a larger
+array, sorted by the value of the <code>.foo</code> field.</p>
+<p>Any jq expression, not just a field access, may be used in
+place of <code>.foo</code>. The sorting order is the same as described
+in the <code>sort</code> function above.</p>
<div>
@@ -3244,14 +3262,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'group_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:1, &quot;bar&quot;:10}, {&quot;foo&quot;:3, &quot;bar&quot;:100}, {&quot;foo&quot;:1, &quot;bar&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:1, &#34;bar&#34;:10}, {&#34;foo&#34;:3, &#34;bar&#34;:100}, {&#34;foo&#34;:1, &#34;bar&#34;:1}]</td></tr>
<tr>
<th>Output</th>
- <td>[[{&quot;foo&quot;:1, &quot;bar&quot;:10}, {&quot;foo&quot;:1, &quot;bar&quot;:1}], [{&quot;foo&quot;:3, &quot;bar&quot;:100}]]</td>
+ <td>[[{&#34;foo&#34;:1, &#34;bar&#34;:10}, {&#34;foo&#34;:1, &#34;bar&#34;:1}], [{&#34;foo&#34;:3, &#34;bar&#34;:100}]]</td>
</tr>
</table>
@@ -3263,16 +3281,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="min,max,min_by(path_exp),max_by(path_exp)">
<h3>
-
-<code>min</code>, <code>max</code>, <code>min_by(path_exp)</code>, <code>max_by(path_exp)</code>
-
+ <code>min</code>, <code>max</code>, <code>min_by(path_exp)</code>, <code>max_by(path_exp)</code>
</h3>
-
-<p>Find the minimum or maximum element of the input array.</p>
-
-<p>The <code>min_by(path_exp)</code> and <code>max_by(path_exp)</code> functions allow you to specify a particular field or property to examine, e.g. <code>min_by(.foo)</code> finds the object with the smallest <code>foo</code> field.</p>
-
+ <p>Find the minimum or maximum element of the input array.</p>
+<p>The <code>min_by(path_exp)</code> and <code>max_by(path_exp)</code> functions allow
+you to specify a particular field or property to examine, e.g.
+<code>min_by(.foo)</code> finds the object with the smallest <code>foo</code> field.</p>
<div>
@@ -3299,14 +3314,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'max_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;:1, &quot;bar&quot;:14}, {&quot;foo&quot;:2, &quot;bar&quot;:3}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;:1, &#34;bar&#34;:14}, {&#34;foo&#34;:2, &#34;bar&#34;:3}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;:2, &quot;bar&quot;:3}</td>
+ <td>{&#34;foo&#34;:2, &#34;bar&#34;:3}</td>
</tr>
</table>
@@ -3318,16 +3333,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="unique,unique_by(path_exp)">
<h3>
-
-<code>unique</code>, <code>unique_by(path_exp)</code>
-
+ <code>unique</code>, <code>unique_by(path_exp)</code>
</h3>
-
-<p>The <code>unique</code> function takes as input an array and produces an array of the same elements, in sorted order, with duplicates removed.</p>
-
-<p>The <code>unique_by(path_exp)</code> function will keep only one element for each value obtained by applying the argument. Think of it as making an array by taking one element out of every group produced by <code>group</code>.</p>
-
+ <p>The <code>unique</code> function takes as input an array and produces
+an array of the same elements, in sorted order, with
+duplicates removed.</p>
+<p>The <code>unique_by(path_exp)</code> function will keep only one element
+for each value obtained by applying the argument. Think of it
+as making an array by taking one element out of every group
+produced by <code>group</code>.</p>
<div>
@@ -3354,28 +3369,28 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'unique_by(.foo)'</td></tr>
- <tr><th>Input</th><td>[{&quot;foo&quot;: 1, &quot;bar&quot;: 2}, {&quot;foo&quot;: 1, &quot;bar&quot;: 3}, {&quot;foo&quot;: 4, &quot;bar&quot;: 5}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;foo&#34;: 1, &#34;bar&#34;: 2}, {&#34;foo&#34;: 1, &#34;bar&#34;: 3}, {&#34;foo&#34;: 4, &#34;bar&#34;: 5}]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;foo&quot;: 1, &quot;bar&quot;: 2}, {&quot;foo&quot;: 4, &quot;bar&quot;: 5}]</td>
+ <td>[{&#34;foo&#34;: 1, &#34;bar&#34;: 2}, {&#34;foo&#34;: 4, &#34;bar&#34;: 5}]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'unique_by(length)'</td></tr>
- <tr><th>Input</th><td>[&quot;chunky&quot;, &quot;bacon&quot;, &quot;kitten&quot;, &quot;cicada&quot;, &quot;asparagus&quot;]</td></tr>
+ <tr><th>Input</th><td>[&#34;chunky&#34;, &#34;bacon&#34;, &#34;kitten&#34;, &#34;cicada&#34;, &#34;asparagus&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;bacon&quot;, &quot;chunky&quot;, &quot;asparagus&quot;]</td>
+ <td>[&#34;bacon&#34;, &#34;chunky&#34;, &#34;asparagus&#34;]</td>
</tr>
</table>
@@ -3387,14 +3402,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="reverse">
<h3>
-
-<code>reverse</code>
-
+ <code>reverse</code>
</h3>
-
-<p>This function reverses an array.</p>
-
+ <p>This function reverses an array.</p>
<div>
@@ -3426,14 +3437,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="contains(element)">
<h3>
-
-<code>contains(element)</code>
-
+ <code>contains(element)</code>
</h3>
-
-<p>The filter <code>contains(b)</code> will produce true if b is completely contained within the input. A string B is contained in a string A if B is a substring of A. An array B is contained in an array A if all elements in B are contained in any element in A. An object B is contained in object A if all of the values in B are contained in the value in A with the same key. All other types are assumed to be contained in each other if they are equal.</p>
-
+ <p>The filter <code>contains(b)</code> will produce true if b is
+completely contained within the input. String B is
+contained in a string A if B is a substring of A. An array B
+is contained in an array A if all elements in B are
+contained in any element in A. An object B is contained in
+object A if all of the values in B are contained in the
+value in A with the same key. All other types are assumed to
+be contained in each other if they are equal.</p>
<div>
@@ -3445,8 +3459,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example49" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'contains(&quot;bar&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foobar&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains(&#34;bar&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foobar&#34;</td></tr>
<tr>
@@ -3459,8 +3473,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'contains([&quot;baz&quot;, &quot;bar&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains([&#34;baz&#34;, &#34;bar&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;]</td></tr>
<tr>
@@ -3473,8 +3487,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'contains([&quot;bazzzzz&quot;, &quot;bar&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'contains([&#34;bazzzzz&#34;, &#34;bar&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;]</td></tr>
<tr>
@@ -3488,7 +3502,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'contains({foo: 12, bar: [{barp: 12}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]}</td></tr>
<tr>
@@ -3502,7 +3516,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'contains({foo: 12, bar: [{barp: 15}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]}</td></tr>
<tr>
@@ -3521,14 +3535,13 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="indices(s)">
<h3>
-
-<code>indices(s)</code>
-
+ <code>indices(s)</code>
</h3>
-
-<p>Outputs an array containing the indices in <code>.</code> where <code>s</code> occurs. The input may be an array, in which case if <code>s</code> is an array then the indices output will be those where all elements in <code>.</code> match those of <code>s</code>.</p>
-
+ <p>Outputs an array containing the indices in <code>.</code> where <code>s</code>
+occurs. The input may be an array, in which case if <code>s</code> is an
+array then the indices output will be those where all elements
+in <code>.</code> match those of <code>s</code>.</p>
<div>
@@ -3540,8 +3553,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example50" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'indices(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a,b, cd, efg, hijk&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'indices(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a,b, cd, efg, hijk&#34;</td></tr>
<tr>
@@ -3588,14 +3601,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="index(s),rindex(s)">
<h3>
-
-<code>index(s)</code>, <code>rindex(s)</code>
-
+ <code>index(s)</code>, <code>rindex(s)</code>
</h3>
-
-<p>Outputs the index of the first (<code>index</code>) or last (<code>rindex</code>) occurrence of <code>s</code> in the input.</p>
-
+ <p>Outputs the index of the first (<code>index</code>) or last (<code>rindex</code>)
+occurrence of <code>s</code> in the input.</p>
<div>
@@ -3607,8 +3617,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example51" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'index(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a,b, cd, efg, hijk&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'index(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a,b, cd, efg, hijk&#34;</td></tr>
<tr>
@@ -3621,8 +3631,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'rindex(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a,b, cd, efg, hijk&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'rindex(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a,b, cd, efg, hijk&#34;</td></tr>
<tr>
@@ -3641,14 +3651,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="inside">
<h3>
-
-<code>inside</code>
-
+ <code>inside</code>
</h3>
-
-<p>The filter <code>inside(b)</code> will produce true if the input is completely contained within b. It is, essentially, an inversed version of <code>contains</code>.</p>
-
+ <p>The filter <code>inside(b)</code> will produce true if the input is
+completely contained within b. It is, essentially, an
+inversed version of <code>contains</code>.</p>
<div>
@@ -3660,8 +3668,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example52" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'inside(&quot;foobar&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;bar&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside(&#34;foobar&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;bar&#34;</td></tr>
<tr>
@@ -3674,8 +3682,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'inside([&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;baz&quot;, &quot;bar&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside([&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;baz&#34;, &#34;bar&#34;]</td></tr>
<tr>
@@ -3688,8 +3696,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'inside([&quot;foobar&quot;, &quot;foobaz&quot;, &quot;blarp&quot;])'</td></tr>
- <tr><th>Input</th><td>[&quot;bazzzzz&quot;, &quot;bar&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside([&#34;foobar&#34;, &#34;foobaz&#34;, &#34;blarp&#34;])'</td></tr>
+ <tr><th>Input</th><td>[&#34;bazzzzz&#34;, &#34;bar&#34;]</td></tr>
<tr>
@@ -3702,8 +3710,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'inside({&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;: [{&quot;barp&quot;: 12}]}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside({&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]})'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;: [{&#34;barp&#34;: 12}]}</td></tr>
<tr>
@@ -3716,8 +3724,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'inside({&quot;foo&quot;: 12, &quot;bar&quot;:[1,2,{&quot;barp&quot;:12, &quot;blip&quot;:13}]})'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 12, &quot;bar&quot;: [{&quot;barp&quot;: 15}]}</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'inside({&#34;foo&#34;: 12, &#34;bar&#34;:[1,2,{&#34;barp&#34;:12, &#34;blip&#34;:13}]})'</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 12, &#34;bar&#34;: [{&#34;barp&#34;: 15}]}</td></tr>
<tr>
@@ -3736,14 +3744,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="startswith(str)">
<h3>
-
-<code>startswith(str)</code>
-
+ <code>startswith(str)</code>
</h3>
-
-<p>Outputs <code>true</code> if . starts with the given string argument.</p>
-
+ <p>Outputs <code>true</code> if . starts with the given string argument.</p>
<div>
@@ -3755,8 +3759,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example53" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|startswith(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;fo&quot;, &quot;foo&quot;, &quot;barfoo&quot;, &quot;foobar&quot;, &quot;barfoob&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|startswith(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;fo&#34;, &#34;foo&#34;, &#34;barfoo&#34;, &#34;foobar&#34;, &#34;barfoob&#34;]</td></tr>
<tr>
@@ -3775,14 +3779,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="endswith(str)">
<h3>
-
-<code>endswith(str)</code>
-
+ <code>endswith(str)</code>
</h3>
-
-<p>Outputs <code>true</code> if . ends with the given string argument.</p>
-
+ <p>Outputs <code>true</code> if . ends with the given string argument.</p>
<div>
@@ -3794,8 +3794,8 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example54" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|endswith(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;foobar&quot;, &quot;barfoo&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|endswith(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;foobar&#34;, &#34;barfoo&#34;]</td></tr>
<tr>
@@ -3814,14 +3814,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="combinations,combinations(n)">
<h3>
-
-<code>combinations</code>, <code>combinations(n)</code>
-
+ <code>combinations</code>, <code>combinations(n)</code>
</h3>
-
-<p>Outputs all combinations of the elements of the arrays in the input array. If given an argument <code>n</code>, it outputs all combinations of <code>n</code> repetitions of the input array.</p>
-
+ <p>Outputs all combinations of the elements of the arrays in the
+input array. If given an argument <code>n</code>, it outputs all combinations
+of <code>n</code> repetitions of the input array.</p>
<div>
@@ -3909,14 +3907,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="ltrimstr(str)">
<h3>
-
-<code>ltrimstr(str)</code>
-
+ <code>ltrimstr(str)</code>
</h3>
-
-<p>Outputs its input with the given prefix string removed, if it starts with it.</p>
-
+ <p>Outputs its input with the given prefix string removed, if it
+starts with it.</p>
<div>
@@ -3928,15 +3923,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example56" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|ltrimstr(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;fo&quot;, &quot;foo&quot;, &quot;barfoo&quot;, &quot;foobar&quot;, &quot;afoo&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|ltrimstr(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;fo&#34;, &#34;foo&#34;, &#34;barfoo&#34;, &#34;foobar&#34;, &#34;afoo&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;fo&quot;,&quot;&quot;,&quot;barfoo&quot;,&quot;bar&quot;,&quot;afoo&quot;]</td>
+ <td>[&#34;fo&#34;,&#34;&#34;,&#34;barfoo&#34;,&#34;bar&#34;,&#34;afoo&#34;]</td>
</tr>
</table>
@@ -3948,14 +3943,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="rtrimstr(str)">
<h3>
-
-<code>rtrimstr(str)</code>
-
+ <code>rtrimstr(str)</code>
</h3>
-
-<p>Outputs its input with the given suffix string removed, if it ends with it.</p>
-
+ <p>Outputs its input with the given suffix string removed, if it
+ends with it.</p>
<div>
@@ -3967,15 +3959,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example57" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '[.[]|rtrimstr(&quot;foo&quot;)]'</td></tr>
- <tr><th>Input</th><td>[&quot;fo&quot;, &quot;foo&quot;, &quot;barfoo&quot;, &quot;foobar&quot;, &quot;foob&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[.[]|rtrimstr(&#34;foo&#34;)]'</td></tr>
+ <tr><th>Input</th><td>[&#34;fo&#34;, &#34;foo&#34;, &#34;barfoo&#34;, &#34;foobar&#34;, &#34;foob&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;fo&quot;,&quot;&quot;,&quot;bar&quot;,&quot;foobar&quot;,&quot;foob&quot;]</td>
+ <td>[&#34;fo&#34;,&#34;&#34;,&#34;bar&#34;,&#34;foobar&#34;,&#34;foob&#34;]</td>
</tr>
</table>
@@ -3987,14 +3979,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="explode">
<h3>
-
-<code>explode</code>
-
+ <code>explode</code>
</h3>
-
-<p>Converts an input string into an array of the string’s codepoint numbers.</p>
-
+ <p>Converts an input string into an array of the string's
+codepoint numbers.</p>
<div>
@@ -4007,7 +3996,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'explode'</td></tr>
- <tr><th>Input</th><td>&quot;foobar&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;foobar&#34;</td></tr>
<tr>
@@ -4026,14 +4015,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="implode">
<h3>
-
-<code>implode</code>
-
+ <code>implode</code>
</h3>
-
-<p>The inverse of explode.</p>
-
+ <p>The inverse of explode.</p>
<div>
@@ -4053,7 +4038,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;ABC&quot;</td>
+ <td>&#34;ABC&#34;</td>
</tr>
</table>
@@ -4065,14 +4050,10 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="split(str)">
<h3>
-
-<code>split(str)</code>
-
+ <code>split(str)</code>
</h3>
-
-<p>Splits an input string on the separator argument.</p>
-
+ <p>Splits an input string on the separator argument.</p>
<div>
@@ -4084,15 +4065,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example60" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'split(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;a, b,c,d, e, &quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'split(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;a, b,c,d, e, &#34;</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;a&quot;,&quot;b,c,d&quot;,&quot;e&quot;,&quot;&quot;]</td>
+ <td>[&#34;a&#34;,&#34;b,c,d&#34;,&#34;e&#34;,&#34;&#34;]</td>
</tr>
</table>
@@ -4104,16 +4085,16 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="join(str)">
<h3>
-
-<code>join(str)</code>
-
+ <code>join(str)</code>
</h3>
-
-<p>Joins the array of elements given as input, using the argument as separator. It is the inverse of <code>split</code>: that is, running <code>split(&quot;foo&quot;) | join(&quot;foo&quot;)</code> over any input string returns said input string.</p>
-
-<p>Numbers and booleans in the input are converted to strings. Null values are treated as empty strings. Arrays and objects in the input are not supported.</p>
-
+ <p>Joins the array of elements given as input, using the
+argument as separator. It is the inverse of <code>split</code>: that is,
+running <code>split("foo") | join("foo")</code> over any input string
+returns said input string.</p>
+<p>Numbers and booleans in the input are converted to strings.
+Null values are treated as empty strings. Arrays and objects
+in the input are not supported.</p>
<div>
@@ -4125,29 +4106,29 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example61" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'join(&quot;, &quot;)'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,&quot;b,c,d&quot;,&quot;e&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'join(&#34;, &#34;)'</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,&#34;b,c,d&#34;,&#34;e&#34;]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;a, b,c,d, e&quot;</td>
+ <td>&#34;a, b,c,d, e&#34;</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'join(&quot; &quot;)'</td></tr>
- <tr><th>Input</th><td>[&quot;a&quot;,1,2.3,true,null,false]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'join(&#34; &#34;)'</td></tr>
+ <tr><th>Input</th><td>[&#34;a&#34;,1,2.3,true,null,false]</td></tr>
<tr>
<th>Output</th>
- <td>&quot;a 1 2.3 true false&quot;</td>
+ <td>&#34;a 1 2.3 true false&#34;</td>
</tr>
</table>
@@ -4159,30 +4140,26 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="ascii_downcase,ascii_upcase">
<h3>
-
-<code>ascii_downcase</code>, <code>ascii_upcase</code>
-
+ <code>ascii_downcase</code>, <code>ascii_upcase</code>
</h3>
-
-<p>Emit a copy of the input string with its alphabetic characters (a-z and A-Z) converted to the specified case.</p>
-
+ <p>Emit a copy of the input string with its alphabetic characters (a-z and A-Z)
+converted to the specified case.</p>
</section>
<section id="while(cond;update)">
<h3>
-
-<code>while(cond; update)</code>
-
+ <code>while(cond; update)</code>
</h3>
-
-<p>The <code>while(cond; update)</code> function allows you to repeatedly apply an update to <code>.</code> until <code>cond</code> is false.</p>
-
-<p>Note that <code>while(cond; update)</code> is internally defined as a recursive jq function. Recursive calls within <code>while</code> will not consume additional memory if <code>update</code> produces at most one output for each input. See advanced topics below.</p>
-
+ <p>The <code>while(cond; update)</code> function allows you to repeatedly
+apply an update to <code>.</code> until <code>cond</code> is false.</p>
+<p>Note that <code>while(cond; update)</code> is internally defined as a
+recursive jq function. Recursive calls within <code>while</code> will
+not consume additional memory if <code>update</code> produces at most one
+output for each input. See advanced topics below.</p>
<div>
@@ -4214,16 +4191,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="until(cond;next)">
<h3>
-
-<code>until(cond; next)</code>
-
+ <code>until(cond; next)</code>
</h3>
-
-<p>The <code>until(cond; next)</code> function allows you to repeatedly apply the expression <code>next</code>, initially to <code>.</code> then to its own output, until <code>cond</code> is true. For example, this can be used to implement a factorial function (see below).</p>
-
-<p>Note that <code>until(cond; next)</code> is internally defined as a recursive jq function. Recursive calls within <code>until()</code> will not consume additional memory if <code>next</code> produces at most one output for each input. See advanced topics below.</p>
-
+ <p>The <code>until(cond; next)</code> function allows you to repeatedly
+apply the expression <code>next</code>, initially to <code>.</code> then to its own
+output, until <code>cond</code> is true. For example, this can be used
+to implement a factorial function (see below).</p>
+<p>Note that <code>until(cond; next)</code> is internally defined as a
+recursive jq function. Recursive calls within <code>until()</code> will
+not consume additional memory if <code>next</code> produces at most one
+output for each input. See advanced topics below.</p>
<div>
@@ -4255,36 +4233,41 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="recurse(f),recurse,recurse(f;condition),recurse_down">
<h3>
-
-<code>recurse(f)</code>, <code>recurse</code>, <code>recurse(f; condition)</code>, <code>recurse_down</code>
-
+ <code>recurse(f)</code>, <code>recurse</code>, <code>recurse(f; condition)</code>, <code>recurse_down</code>
</h3>
-
-<p>The <code>recurse(f)</code> function allows you to search through a recursive structure, and extract interesting data from all levels. Suppose your input represents a filesystem:</p>
-
-<pre><code>{&quot;name&quot;: &quot;/&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/bin&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/bin/ls&quot;, &quot;children&quot;: []},
- {&quot;name&quot;: &quot;/bin/sh&quot;, &quot;children&quot;: []}]},
- {&quot;name&quot;: &quot;/home&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/home/stephen&quot;, &quot;children&quot;: [
- {&quot;name&quot;: &quot;/home/stephen/jq&quot;, &quot;children&quot;: []}]}]}]}</code></pre>
-
-<p>Now suppose you want to extract all of the filenames present. You need to retrieve <code>.name</code>, <code>.children[].name</code>, <code>.children[].children[].name</code>, and so on. You can do this with:</p>
-
-<pre><code>recurse(.children[]) | .name</code></pre>
-
-<p>When called without an argument, <code>recurse</code> is equivalent to <code>recurse(.[]?)</code>.</p>
-
-<p><code>recurse(f)</code> is identical to <code>recurse(f; . != null)</code> and can be used without concerns about recursion depth.</p>
-
-<p><code>recurse(f; condition)</code> is a generator which begins by emitting . and then emits in turn .|f, .|f|f, .|f|f|f, … so long as the computed value satisfies the condition. For example, to generate all the integers, at least in principle, one could write <code>recurse(.+1; true)</code>.</p>
-
-<p>For legacy reasons, <code>recurse_down</code> exists as an alias to calling <code>recurse</code> without arguments. This alias is considered <em>deprecated</em> and will be removed in the next major release.</p>
-
-<p>The recursive calls in <code>recurse</code> will not consume additional memory whenever <code>f</code> produces at most a single output for each input.</p>
-
+ <p>The <code>recurse(f)</code> function allows you to search through a
+recursive structure, and extract interesting data from all
+levels. Suppose your input represents a filesystem:</p>
+<pre><code>{"name": "/", "children": [
+ {"name": "/bin", "children": [
+ {"name": "/bin/ls", "children": []},
+ {"name": "/bin/sh", "children": []}]},
+ {"name": "/home", "children": [
+ {"name": "/home/stephen", "children": [
+ {"name": "/home/stephen/jq", "children": []}]}]}]}
+</code></pre>
+<p>Now suppose you want to extract all of the filenames
+present. You need to retrieve <code>.name</code>, <code>.children[].name</code>,
+<code>.children[].children[].name</code>, and so on. You can do this
+with:</p>
+<pre><code>recurse(.children[]) | .name
+</code></pre>
+<p>When called without an argument, <code>recurse</code> is equivalent to
+<code>recurse(.[]?)</code>.</p>
+<p><code>recurse(f)</code> is identical to <code>recurse(f; . != null)</code> and can be
+used without concerns about recursion depth.</p>
+<p><code>recurse(f; condition)</code> is a generator which begins by
+emitting . and then emits in turn .|f, .|f|f, .|f|f|f, ... so long
+as the computed value satisfies the condition. For example,
+to generate all the integers, at least in principle, one
+could write <code>recurse(.+1; true)</code>.</p>
+<p>For legacy reasons, <code>recurse_down</code> exists as an alias to
+calling <code>recurse</code> without arguments. This alias is considered
+<em>deprecated</em> and will be removed in the next major release.</p>
+<p>The recursive calls in <code>recurse</code> will not consume additional
+memory whenever <code>f</code> produces at most a single output for each
+input.</p>
<div>
@@ -4297,49 +4280,49 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<table>
<tr><th></th><td class="jqprogram">jq 'recurse(.foo[])'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;:[{&quot;foo&quot;: []}, {&quot;foo&quot;:[{&quot;foo&quot;:[]}]}]}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;:[{&#34;foo&#34;: []}, {&#34;foo&#34;:[{&#34;foo&#34;:[]}]}]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;:[{&quot;foo&quot;:[]},{&quot;foo&quot;:[{&quot;foo&quot;:[]}]}]}</td>
+ <td>{&#34;foo&#34;:[{&#34;foo&#34;:[]},{&#34;foo&#34;:[{&#34;foo&#34;:[]}]}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[]}</td>
+ <td>{&#34;foo&#34;:[]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[{&quot;foo&quot;:[]}]}</td>
+ <td>{&#34;foo&#34;:[{&#34;foo&#34;:[]}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;foo&quot;:[]}</td>
+ <td>{&#34;foo&#34;:[]}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq 'recurse'</td></tr>
- <tr><th>Input</th><td>{&quot;a&quot;:0,&quot;b&quot;:[1]}</td></tr>
+ <tr><th>Input</th><td>{&#34;a&#34;:0,&#34;b&#34;:[1]}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;:0,&quot;b&quot;:[1]}</td>
+ <td>{&#34;a&#34;:0,&#34;b&#34;:[1]}</td>
</tr>
<tr>
@@ -4400,14 +4383,20 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="walk(f)">
<h3>
-
-<code>walk(f)</code>
-
+ <code>walk(f)</code>
</h3>
-
-<p>The <code>walk(f)</code> function applies f recursively to every component of the input entity. When an array is encountered, f is first applied to its elements and then to the array itself; when an object is encountered, f is first applied to all the values and then to the object. In practice, f will usually test the type of its input, as illustrated in the following examples. The first example highlights the usefulness of processing the elements of an array of arrays before processing the array itself. The second example shows how all the keys of all the objects within the input can be considered for alteration.</p>
-
+ <p>The <code>walk(f)</code> function applies f recursively to every
+component of the input entity. When an array is
+encountered, f is first applied to its elements and then to
+the array itself; when an object is encountered, f is first
+applied to all the values and then to the object. In
+practice, f will usually test the type of its input, as
+illustrated in the following examples. The first example
+highlights the usefulness of processing the elements of an
+array of arrays before processing the array itself. The second
+example shows how all the keys of all the objects within the
+input can be considered for alteration.</p>
<div>
@@ -4419,7 +4408,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<div id="example65" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'walk(if type == &quot;array&quot; then sort else . end)'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'walk(if type == &#34;array&#34; then sort else . end)'</td></tr>
<tr><th>Input</th><td>[[4, 1, 7], [8, 5, 2], [3, 6, 9]]</td></tr>
@@ -4433,15 +4422,15 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'walk( if type == &quot;object&quot; then with_entries( .key |= sub( &quot;^_+&quot;; &quot;&quot;) ) else . end )'</td></tr>
- <tr><th>Input</th><td>[ { &quot;_a&quot;: { &quot;__b&quot;: 2 } } ]</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'walk( if type == &#34;object&#34; then with_entries( .key |= sub( &#34;^_+&#34;; &#34;&#34;) ) else . end )'</td></tr>
+ <tr><th>Input</th><td>[ { &#34;_a&#34;: { &#34;__b&#34;: 2 } } ]</td></tr>
<tr>
<th>Output</th>
- <td>[{&quot;a&quot;:{&quot;b&quot;:2}}]</td>
+ <td>[{&#34;a&#34;:{&#34;b&#34;:2}}]</td>
</tr>
</table>
@@ -4453,18 +4442,14 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="$ENV,env">
<h3>
-
-<code>$ENV</code>, <code>env</code>
-
+ <code>$ENV</code>, <code>env</code>
</h3>
-
-<p><code>$ENV</code> is an object representing the environment variables as set when the jq program started.</p>
-
-<p><code>env</code> outputs an object representing jq’s current environment.</p>
-
-<p>At the moment there is no builtin for setting environment variables.</p>
-
+ <p><code>$ENV</code> is an object representing the environment variables as
+set when the jq program started.</p>
+<p><code>env</code> outputs an object representing jq's current environment.</p>
+<p>At the moment there is no builtin for setting environment
+variables.</p>
<div>
@@ -4484,7 +4469,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;less&quot;</td>
+ <td>&#34;less&#34;</td>
</tr>
</table>
@@ -4498,7 +4483,7 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<th>Output</th>
- <td>&quot;less&quot;</td>
+ <td>&#34;less&#34;</td>
</tr>
</table>
@@ -4510,14 +4495,11 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="transpose">
<h3>
-
-<code>transpose</code>
-
+ <code>transpose</code>
</h3>
-
-<p>Transpose a possibly jagged matrix (an array of arrays). Rows are padded with nulls so the result is always rectangular.</p>
-
+ <p>Transpose a possibly jagged matrix (an array of arrays).
+Rows are padded with nulls so the result is always rectangular.</p>
<div>
@@ -4549,14 +4531,17 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="bsearch(x)">
<h3>
-
-<code>bsearch(x)</code>
-
+ <code>bsearch(x)</code>
</h3>
-
-<p>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.</p>
-
+ <p>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.</p>
<div>
@@ -4616,14 +4601,12 @@ map(foo) | from_entries</code>, useful for doing some operation to all keys and
<section id="Stringinterpolation-\(foo)">
<h3>
-
-String interpolation - <code>\(foo)</code>
-
+ String interpolation - <code>\(foo)</code>
</h3>
-
-<p>Inside a string, you can put an expression inside parens after a backslash. Whatever the expression returns will be interpolated into the string.</p>
-
+ <p>Inside a string, you can put an expression inside parens
+after a backslash. Whatever the expression returns will be
+interpolated into the string.</p>
<div>
@@ -4635,7 +4618,7 @@ String interpolation - <code>\(foo)</code>
<div id="example69" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '&quot;The input was \(.), which is one less than \(.+1)&quot;'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '&#34;The input was \(.), which is one less than \(.+1)&#34;'</td></tr>
<tr><th>Input</th><td>42</td></tr>
@@ -4643,7 +4626,7 @@ String interpolation - <code>\(foo)</code>
<th>Output</th>
- <td>&quot;The input was 42, which is one less than 43&quot;</td>
+ <td>&#34;The input was 42, which is one less than 43&#34;</td>
</tr>
</table>
@@ -4655,14 +4638,13 @@ String interpolation - <code>\(foo)</code>
<section id="Convertto/fromJSON">
<h3>
-
-Convert to/from JSON
-
+ Convert to/from JSON
</h3>
-
-<p>The <code>tojson</code> and <code>fromjson</code> 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.</p>
-
+ <p>The <code>tojson</code> and <code>fromjson</code> 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.</p>
<div>
@@ -4675,42 +4657,42 @@ Convert to/from JSON
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|tostring]'</td></tr>
- <tr><th>Input</th><td>[1, &quot;foo&quot;, [&quot;foo&quot;]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;foo&#34;, [&#34;foo&#34;]]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;1&quot;,&quot;foo&quot;,&quot;[\&quot;foo\&quot;]&quot;]</td>
+ <td>[&#34;1&#34;,&#34;foo&#34;,&#34;[\&#34;foo\&#34;]&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|tojson]'</td></tr>
- <tr><th>Input</th><td>[1, &quot;foo&quot;, [&quot;foo&quot;]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;foo&#34;, [&#34;foo&#34;]]</td></tr>
<tr>
<th>Output</th>
- <td>[&quot;1&quot;,&quot;\&quot;foo\&quot;&quot;,&quot;[\&quot;foo\&quot;]&quot;]</td>
+ <td>[&#34;1&#34;,&#34;\&#34;foo\&#34;&#34;,&#34;[\&#34;foo\&#34;]&#34;]</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|tojson|fromjson]'</td></tr>
- <tr><th>Input</th><td>[1, &quot;foo&quot;, [&quot;foo&quot;]]</td></tr>
+ <tr><th>Input</th><td>[1, &#34;foo&#34;, [&#34;foo&#34;]]</td></tr>
<tr>
<th>Output</th>
- <td>[1,&quot;foo&quot;,[&quot;foo&quot;]]</td>
+ <td>[1,&#34;foo&#34;,[&#34;foo&#34;]]</td>
</tr>
</table>
@@ -4722,80 +4704,76 @@ Convert to/from JSON
<section id="Formatstringsandescaping">
<h3>
-
-Format strings and escaping
-
+ Format strings and escaping
</h3>
-
-<p>The <code>@foo</code> syntax is used to format and escape strings, which is useful for building URLs, documents in a language like HTML or XML, and so forth. <code>@foo</code> can be used as a filter on its own, the possible escapings are:</p>
-
+ <p>The <code>@foo</code> syntax is used to format and escape strings,
+which is useful for building URLs, documents in a language
+like HTML or XML, and so forth. <code>@foo</code> can be used as a
+filter on its own, the possible escapings are:</p>
<ul>
-<li>
-<p><code>@text</code>:</p>
-
+<li><code>@text</code>:</li>
+</ul>
<p>Calls <code>tostring</code>, see that function for details.</p>
-</li>
-
-<li>
-<p><code>@json</code>:</p>
-
+<ul>
+<li><code>@json</code>:</li>
+</ul>
<p>Serializes the input as JSON.</p>
-</li>
-
-<li>
-<p><code>@html</code>:</p>
-
-<p>Applies HTML/XML escaping, by mapping the characters <code>&lt;&gt;&amp;'&quot;</code> to their entity equivalents <code>&amp;lt;</code>, <code>&amp;gt;</code>, <code>&amp;amp;</code>, <code>&amp;apos;</code>, <code>&amp;quot;</code>.</p>
-</li>
-
-<li>
-<p><code>@uri</code>:</p>
-
-<p>Applies percent-encoding, by mapping all reserved URI characters to a <code>%XX</code> sequence.</p>
-</li>
-
-<li>
-<p><code>@csv</code>:</p>
-
-<p>The input must be an array, and it is rendered as CSV with double quotes for strings, and quotes escaped by repetition.</p>
-</li>
-
-<li>
-<p><code>@tsv</code>:</p>
-
-<p>The input must be an array, and it is rendered as TSV (tab-separated values). Each input array will be printed as a single line. Fields are separated by a single tab (ascii <code>0x09</code>). Input characters line-feed (ascii <code>0x0a</code>), carriage-return (ascii <code>0x0d</code>), tab (ascii <code>0x09</code>) and backslash (ascii <code>0x5c</code>) will be output as escape sequences <code>\n</code>, <code>\r</code>, <code>\t</code>, <code>\\</code> respectively.</p>
-</li>
-
-<li>
-<p><code>@sh</code>:</p>
-
-<p>The input is escaped suitable for use in a command-line for a POSIX shell. If the input is an array, the output will be a series of space-separated strings.</p>
-</li>
-
-<li>
-<p><code>@base64</code>:</p>
-
+<ul>
+<li><code>@html</code>:</li>
+</ul>
+<p>Applies HTML/XML escaping, by mapping the characters
+ <code>&lt;&gt;&amp;'"</code> to their entity equivalents <code>&amp;lt;</code>, <code>&amp;gt;</code>,
+ <code>&amp;amp;</code>, <code>&amp;apos;</code>, <code>&amp;quot;</code>.</p>
+<ul>
+<li><code>@uri</code>:</li>
+</ul>
+<p>Applies percent-encoding, by mapping all reserved URI
+ characters to a <code>%XX</code> sequence.</p>
+<ul>
+<li><code>@csv</code>:</li>
+</ul>
+<p>The input must be an array, and it is rendered as CSV
+ with double quotes for strings, and quotes escaped by
+ repetition.</p>
+<ul>
+<li><code>@tsv</code>:</li>
+</ul>
+<p>The input must be an array, and it is rendered as TSV
+ (tab-separated values). Each input array will be printed as
+ a single line. Fields are separated by a single
+ tab (ascii <code>0x09</code>). Input characters line-feed (ascii <code>0x0a</code>),
+ carriage-return (ascii <code>0x0d</code>), tab (ascii <code>0x09</code>) and
+ backslash (ascii <code>0x5c</code>) will be output as escape sequences
+ <code>\n</code>, <code>\r</code>, <code>\t</code>, <code>\\</code> respectively.</p>
+<ul>
+<li><code>@sh</code>:</li>
+</ul>
+<p>The input is escaped suitable for use in a command-line
+ for a POSIX shell. If the input is an array, the output
+ will be a series of space-separated strings.</p>
+<ul>
+<li><code>@base64</code>:</li>
+</ul>
<p>The input is converted to base64 as specified by RFC 4648.</p>
-</li>
-
-<li>
-<p><code>@base64d</code>:</p>
-
-<p>The inverse of <code>@base64</code>, input is decoded as specified by RFC 4648. Note: If the decoded string is not UTF-8, the results are undefined.</p>
-</li>
+<ul>
+<li><code>@base64d</code>:</li>
</ul>
-
-<p>This syntax can be combined with string interpolation in a useful way. You can follow a <code>@foo</code> token with a string literal. The contents of the string literal will <em>not</em> be escaped. However, all interpolations made inside that string literal will be escaped. For instance,</p>
-
-<pre><code>@uri &quot;https://www.google.com/search?q=\(.search)&quot;</code></pre>
-
-<p>will produce the following output for the input <code>{&quot;search&quot;:&quot;what is jq?&quot;}</code>:</p>
-
-<pre><code>&quot;https://www.google.com/search?q=what%20is%20jq%3F&quot;</code></pre>
-
-<p>Note that the slashes, question mark, etc. in the URL are not escaped, as they were part of the string literal.</p>
-
+<p>The inverse of <code>@base64</code>, input is decoded as specified by RFC 4648.
+ Note\: If the decoded string is not UTF-8, the results are undefined.</p>
+<p>This syntax can be combined with string interpolation in a
+useful way. You can follow a <code>@foo</code> token with a string
+literal. The contents of the string literal will <em>not</em> be
+escaped. However, all interpolations made inside that string
+literal will be escaped. For instance,</p>
+<pre><code>@uri "https://www.google.com/search?q=\(.search)"
+</code></pre>
+<p>will produce the following output for the input
+<code>{"search":"what is jq?"}</code>:</p>
+<pre><code>"https://www.google.com/search?q=what%20is%20jq%3F"
+</code></pre>
+<p>Note that the slashes, question mark, etc. in the URL are
+not escaped, as they were part of the string literal.</p>
<div>
@@ -4808,56 +4786,56 @@ Format strings and escaping
<table>
<tr><th></th><td class="jqprogram">jq '@html'</td></tr>
- <tr><th>Input</th><td>&quot;This works if x &lt; y&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;This works if x &lt; y&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;This works if x &amp;lt; y&quot;</td>
+ <td>&#34;This works if x &amp;lt; y&#34;</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '@sh &quot;echo \(.)&quot;'</td></tr>
- <tr><th>Input</th><td>&quot;O'Hara's Ale&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq '@sh &#34;echo \(.)&#34;'</td></tr>
+ <tr><th>Input</th><td>&#34;O&#39;Hara&#39;s Ale&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;echo 'O'\\''Hara'\\''s Ale'&quot;</td>
+ <td>&#34;echo &#39;O&#39;\\&#39;&#39;Hara&#39;\\&#39;&#39;s Ale&#39;&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '@base64'</td></tr>
- <tr><th>Input</th><td>&quot;This is a message&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;This is a message&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;VGhpcyBpcyBhIG1lc3NhZ2U=&quot;</td>
+ <td>&#34;VGhpcyBpcyBhIG1lc3NhZ2U=&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '@base64d'</td></tr>
- <tr><th>Input</th><td>&quot;VGhpcyBpcyBhIG1lc3NhZ2U=&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;VGhpcyBpcyBhIG1lc3NhZ2U=&#34;</td></tr>
<tr>
<th>Output</th>
- <td>&quot;This is a message&quot;</td>
+ <td>&#34;This is a message&#34;</td>
</tr>
</table>
@@ -4869,38 +4847,55 @@ Format strings and escaping
<section id="Dates">
<h3>
-
-Dates
-
+ Dates
</h3>
-
-<p>jq provides some basic date handling functionality, with some high-level and low-level builtins. In all cases these builtins deal exclusively with time in UTC.</p>
-
-<p>The <code>fromdateiso8601</code> builtin parses datetimes in the ISO 8601 format to a number of seconds since the Unix epoch (1970-01-01T00:00:00Z). The <code>todateiso8601</code> builtin does the inverse.</p>
-
-<p>The <code>fromdate</code> builtin parses datetime strings. Currently <code>fromdate</code> only supports ISO 8601 datetime strings, but in the future it will attempt to parse datetime strings in more formats.</p>
-
+ <p>jq provides some basic date handling functionality, with some
+high-level and low-level builtins. In all cases these
+builtins deal exclusively with time in UTC.</p>
+<p>The <code>fromdateiso8601</code> builtin parses datetimes in the ISO 8601
+format to a number of seconds since the Unix epoch
+(1970-01-01T00:00:00Z). The <code>todateiso8601</code> builtin does the
+inverse.</p>
+<p>The <code>fromdate</code> builtin parses datetime strings. Currently
+<code>fromdate</code> only supports ISO 8601 datetime strings, but in the
+future it will attempt to parse datetime strings in more
+formats.</p>
<p>The <code>todate</code> builtin is an alias for <code>todateiso8601</code>.</p>
-
-<p>The <code>now</code> builtin outputs the current time, in seconds since the Unix epoch.</p>
-
-<p>Low-level jq interfaces to the C-library time functions are also provided: <code>strptime</code>, <code>strftime</code>, <code>strflocaltime</code>, <code>mktime</code>, <code>gmtime</code>, and <code>localtime</code>. Refer to your host operating system’s documentation for the format strings used by <code>strptime</code> and <code>strftime</code>. Note: these are not necessarily stable interfaces in jq, particularly as to their localization functionality.</p>
-
-<p>The <code>gmtime</code> builtin consumes a number of seconds since the Unix epoch and outputs a “broken down time” representation of Greenwhich Meridian time as an array of numbers representing (in this order): the year, the month (zero-based), the day of the month (one-based), the hour of the day, the minute of the hour, the second of the minute, the day of the week, and the day of the year – all one-based unless otherwise stated. The day of the week number may be wrong on some systems for dates before March 1st 1900, or after December 31 2099.</p>
-
-<p>The <code>localtime</code> builtin works like the <code>gmtime</code> builtin, but using the local timezone setting.</p>
-
-<p>The <code>mktime</code> builtin consumes “broken down time” representations of time output by <code>gmtime</code> and <code>strptime</code>.</p>
-
-<p>The <code>strptime(fmt)</code> builtin parses input strings matching the <code>fmt</code> argument. The output is in the “broken down time” representation consumed by <code>gmtime</code> and output by <code>mktime</code>.</p>
-
-<p>The <code>strftime(fmt)</code> builtin formats a time (GMT) with the given format. The <code>strflocaltime</code> does the same, but using the local timezone setting.</p>
-
-<p>The format strings for <code>strptime</code> and <code>strftime</code> are described in typical C library documentation. The format string for ISO 8601 datetime is <code>&quot;%Y-%m-%dT%H:%M:%SZ&quot;</code>.</p>
-
-<p>jq may not support some or all of this date functionality on some systems. In particular, the <code>%u</code> and <code>%j</code> specifiers for <code>strptime(fmt)</code> are not supported on macOS.</p>
-
+<p>The <code>now</code> builtin outputs the current time, in seconds since
+the Unix epoch.</p>
+<p>Low-level jq interfaces to the C-library time functions are
+also provided: <code>strptime</code>, <code>strftime</code>, <code>strflocaltime</code>,
+<code>mktime</code>, <code>gmtime</code>, and <code>localtime</code>. Refer to your host
+operating system's documentation for the format strings used
+by <code>strptime</code> and <code>strftime</code>. Note: these are not necessarily
+stable interfaces in jq, particularly as to their localization
+functionality.</p>
+<p>The <code>gmtime</code> builtin consumes a number of seconds since the
+Unix epoch and outputs a "broken down time" representation of
+Greenwhich Meridian time as an array of numbers representing
+(in this order): the year, the month (zero-based), the day of
+the month (one-based), the hour of the day, the minute of the
+hour, the second of the minute, the day of the week, and the
+day of the year -- all one-based unless otherwise stated. The
+day of the week number may be wrong on some systems for dates
+before March 1st 1900, or after December 31 2099.</p>
+<p>The <code>localtime</code> builtin works like the <code>gmtime</code> builtin, but
+using the local timezone setting.</p>
+<p>The <code>mktime</code> builtin consumes "broken down time"
+representations of time output by <code>gmtime</code> and <code>strptime</code>.</p>
+<p>The <code>strptime(fmt)</code> builtin parses input strings matching the
+<code>fmt</code> argument. The output is in the "broken down time"
+representation consumed by <code>gmtime</code> and output by <code>mktime</code>.</p>
+<p>The <code>strftime(fmt)</code> builtin formats a time (GMT) with the
+given format. The <code>strflocaltime</code> does the same, but using
+the local timezone setting.</p>
+<p>The format strings for <code>strptime</code> and <code>strftime</code> are described
+in typical C library documentation. The format string for ISO
+8601 datetime is <code>"%Y-%m-%dT%H:%M:%SZ"</code>.</p>
+<p>jq may not support some or all of this date functionality on
+some systems. In particular, the <code>%u</code> and <code>%j</code> specifiers for
+<code>strptime(fmt)</code> are not supported on macOS.</p>
<div>
@@ -4913,7 +4908,7 @@ Dates
<table>
<tr><th></th><td class="jqprogram">jq 'fromdate'</td></tr>
- <tr><th>Input</th><td>&quot;2015-03-05T23:51:47Z&quot;</td></tr>
+ <tr><th>Input</th><td>&#34;2015-03-05T23:51:47Z&#34;</td></tr>
<tr>
@@ -4926,8 +4921,8 @@ Dates
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'strptime(&quot;%Y-%m-%dT%H:%M:%SZ&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;2015-03-05T23:51:47Z&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'strptime(&#34;%Y-%m-%dT%H:%M:%SZ&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;2015-03-05T23:51:47Z&#34;</td></tr>
<tr>
@@ -4940,8 +4935,8 @@ Dates
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'strptime(&quot;%Y-%m-%dT%H:%M:%SZ&quot;)|mktime'</td></tr>
- <tr><th>Input</th><td>&quot;2015-03-05T23:51:47Z&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'strptime(&#34;%Y-%m-%dT%H:%M:%SZ&#34;)|mktime'</td></tr>
+ <tr><th>Input</th><td>&#34;2015-03-05T23:51:47Z&#34;</td></tr>
<tr>
@@ -4960,66 +4955,58 @@ Dates
<section id="SQL-StyleOperators">
<h3>
-
-SQL-Style Operators
-
+ SQL-Style Operators
</h3>
-
-<p>jq provides a few SQL-style operators.</p>
-
+ <p>jq provides a few SQL-style operators.</p>
<ul>
-<li>
-<p>INDEX(stream; index_expression):</p>
-
-<p>This builtin produces an object whose keys are computed by the given index expression applied to each value from the given stream.</p>
-</li>
-
-<li>
-<p>JOIN($idx; stream; idx_expr; join_expr):</p>
-
-<p>This builtin joins the values from the given stream to the given index. The index’s keys are computed by applying the given index expression to each value from the given stream. An array of the value in the stream and the corresponding value from the index is fed to the given join expression to produce each result.</p>
-</li>
-
-<li>
-<p>JOIN($idx; stream; idx_expr):</p>
-
+<li>INDEX(stream; index_expression):</li>
+</ul>
+<p>This builtin produces an object whose keys are computed by
+ the given index expression applied to each value from the
+ given stream.</p>
+<ul>
+<li>JOIN($idx; stream; idx_expr; join_expr):</li>
+</ul>
+<p>This builtin joins the values from the given stream to the
+ given index. The index's keys are computed by applying the
+ given index expression to each value from the given stream.
+ An array of the value in the stream and the corresponding
+ value from the index is fed to the given join expression to
+ produce each result.</p>
+<ul>
+<li>JOIN($idx; stream; idx_expr):</li>
+</ul>
<p>Same as <code>JOIN($idx; stream; idx_expr; .)</code>.</p>
-</li>
-
-<li>
-<p>JOIN($idx; idx_expr):</p>
-
-<p>This builtin joins the input <code>.</code> to the given index, applying the given index expression to <code>.</code> to compute the index key. The join operation is as described above.</p>
-</li>
-
-<li>
-<p>IN(s):</p>
-
-<p>This builtin outputs <code>true</code> if <code>.</code> appears in the given stream, otherwise it outputs <code>false</code>.</p>
-</li>
-
-<li>
-<p>IN(source; s):</p>
-
-<p>This builtin outputs <code>true</code> if any value in the source stream appears in the second stream, otherwise it outputs <code>false</code>.</p>
-</li>
+<ul>
+<li>JOIN($idx; idx_expr):</li>
</ul>
-
+<p>This builtin joins the input <code>.</code> to the given index, applying
+ the given index expression to <code>.</code> to compute the index key.
+ The join operation is as described above.</p>
+<ul>
+<li>IN(s):</li>
+</ul>
+<p>This builtin outputs <code>true</code> if <code>.</code> appears in the given
+ stream, otherwise it outputs <code>false</code>.</p>
+<ul>
+<li>IN(source; s):</li>
+</ul>
+<p>This builtin outputs <code>true</code> if any value in the source stream
+ appears in the second stream, otherwise it outputs <code>false</code>.</p>
</section>
<section id="builtins">
<h3>
-
-<code>builtins</code>
-
+ <code>builtins</code>
</h3>
-
-<p>Returns a list of all builtin functions in the format <code>name/arity</code>. Since functions with the same name but different arities are considered separate functions, <code>all/0</code>, <code>all/1</code>, and <code>all/2</code> would all be present in the list.</p>
-
+ <p>Returns a list of all builtin functions in the format <code>name/arity</code>.
+Since functions with the same name but different arities are considered
+separate functions, <code>all/0</code>, <code>all/1</code>, and <code>all/2</code> would all be present
+in the list.</p>
</section>
@@ -5032,16 +5019,16 @@ SQL-Style Operators
<section id="==,!=">
<h3>
-
-<code>==</code>, <code>!=</code>
-
+ <code>==</code>, <code>!=</code>
</h3>
-
-<p>The expression ‘a == b’ will produce ‘true’ if the result of a and b are equal (that is, if they represent equivalent JSON documents) and ‘false’ otherwise. In particular, strings are never considered equal to numbers. If you’re coming from Javascript, jq’s == is like Javascript’s === - considering values equal only when they have the same type as well as the same value.</p>
-
-<p>!= is “not equal”, and ‘a != b’ returns the opposite value of ‘a == b’</p>
-
+ <p>The expression 'a == b' will produce 'true' if the result of a and b
+are equal (that is, if they represent equivalent JSON documents) and
+'false' otherwise. In particular, strings are never considered equal
+to numbers. If you're coming from Javascript, jq's == is like
+Javascript's === - considering values equal only when they have the
+same type as well as the same value.</p>
+<p>!= is "not equal", and 'a != b' returns the opposite value of 'a == b'</p>
<div>
@@ -5054,7 +5041,7 @@ SQL-Style Operators
<table>
<tr><th></th><td class="jqprogram">jq '.[] == 1'</td></tr>
- <tr><th>Input</th><td>[1, 1.0, &quot;1&quot;, &quot;banana&quot;]</td></tr>
+ <tr><th>Input</th><td>[1, 1.0, &#34;1&#34;, &#34;banana&#34;]</td></tr>
<tr>
@@ -5094,22 +5081,24 @@ SQL-Style Operators
<section id="if-then-else">
<h3>
-
-if-then-else
-
+ if-then-else
</h3>
-
-<p><code>if A then B else C end</code> will act the same as <code>B</code> if <code>A</code> produces a value other than false or null, but act the same as <code>C</code> otherwise.</p>
-
-<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 <code>if .name then A else B end</code>, you’ll need something more like <code>if (.name | length) &gt; 0 then A else
+ <p><code>if A then B else C end</code> will act the same as <code>B</code> if <code>A</code>
+produces a value other than false or null, but act the same
+as <code>C</code> otherwise.</p>
+<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 <code>if .name then A else B end</code>, you'll
+need something more like <code>if (.name | length) &gt; 0 then A else
B end</code> instead.</p>
-
-<p>If the condition <code>A</code> produces multiple results, then <code>B</code> is evaluated once for each result that is not false or null, and <code>C</code> is evaluated once for each false or null.</p>
-
+<p>If the condition <code>A</code> produces multiple results, then <code>B</code> is evaluated
+once for each result that is not false or null, and <code>C</code> is evaluated
+once for each false or null.</p>
<p>More cases can be added to an if using <code>elif A then B</code> syntax.</p>
-
<div>
@@ -5121,11 +5110,11 @@ B end</code> instead.</p>
<table>
<tr><th></th><td class="jqprogram">jq 'if . == 0 then
- &quot;zero&quot;
+ &#34;zero&#34;
elif . == 1 then
- &quot;one&quot;
+ &#34;one&#34;
else
- &quot;many&quot;
+ &#34;many&#34;
end'</td></tr>
<tr><th>Input</th><td>2</td></tr>
@@ -5134,7 +5123,7 @@ end'</td></tr>
<th>Output</th>
- <td>&quot;many&quot;</td>
+ <td>&#34;many&#34;</td>
</tr>
</table>
@@ -5144,19 +5133,17 @@ end'</td></tr>
</section>
- <section id=">,>=,<=,<">
+ <section id="&gt;,&gt;=,&lt;=,&lt;">
<h3>
-
-<code>&gt;, &gt;=, &lt;=, &lt;</code>
-
+ <code>&gt;, &gt;=, &lt;=, &lt;</code>
</h3>
-
-<p>The comparison operators <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;=</code>, <code>&lt;</code> 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).</p>
-
+ <p>The comparison operators <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;=</code>, <code>&lt;</code> 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).</p>
<p>The ordering is the same as that described for <code>sort</code>, above.</p>
-
<div>
@@ -5187,21 +5174,24 @@ end'</td></tr>
<section id="and/or/not">
<h3>
-
-and/or/not
-
+ and/or/not
</h3>
-
-<p>jq supports the normal Boolean operators and/or/not. They have the same standard of truth as if expressions - false and null are considered “false values”, and anything else is a “true value”.</p>
-
-<p>If an operand of one of these operators produces multiple results, the operator itself will produce a result for each input.</p>
-
-<p><code>not</code> is in fact a builtin function rather than an operator, so it is called as a filter to which things can be piped rather than with special syntax, as in <code>.foo and .bar |
+ <p>jq supports the normal Boolean operators and/or/not. They have the
+same standard of truth as if expressions - false and null are
+considered "false values", and anything else is a "true value".</p>
+<p>If an operand of one of these operators produces multiple
+results, the operator itself will produce a result for each input.</p>
+<p><code>not</code> is in fact a builtin function rather than an operator,
+so it is called as a filter to which things can be piped
+rather than with special syntax, as in <code>.foo and .bar |
not</code>.</p>
-
-<p>These three only produce the values “true” and “false”, and so are only useful for genuine Boolean operations, rather than the common Perl/Python/Ruby idiom of “value_that_may_be_null or default”. If you want to use this form of “or”, picking between two values rather than evaluating a condition, see the “//” operator below.</p>
-
+<p>These three only produce the values "true" and "false", and
+so are only useful for genuine Boolean operations, rather
+than the common Perl/Python/Ruby idiom of
+"value_that_may_be_null or default". If you want to use this
+form of "or", picking between two values rather than
+evaluating a condition, see the "//" operator below.</p>
<div>
@@ -5213,7 +5203,7 @@ not</code>.</p>
<div id="example76" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '42 and &quot;a string&quot;'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '42 and &#34;a string&#34;'</td></tr>
<tr><th>Input</th><td>null</td></tr>
@@ -5303,16 +5293,17 @@ not</code>.</p>
<section id="Alternativeoperator://">
<h3>
-
-Alternative operator: <code>//</code>
-
+ Alternative operator: <code>//</code>
</h3>
-
-<p>A filter of the form <code>a // b</code> produces the same results as <code>a</code>, if <code>a</code> produces results other than <code>false</code> and <code>null</code>. Otherwise, <code>a // b</code> produces the same results as <code>b</code>.</p>
-
-<p>This is useful for providing defaults: <code>.foo // 1</code> will evaluate to <code>1</code> if there’s no <code>.foo</code> element in the input. It’s similar to how <code>or</code> is sometimes used in Python (jq’s <code>or</code> operator is reserved for strictly Boolean operations).</p>
-
+ <p>A filter of the form <code>a // b</code> produces the same
+results as <code>a</code>, if <code>a</code> produces results other than <code>false</code>
+and <code>null</code>. Otherwise, <code>a // b</code> produces the same results as <code>b</code>.</p>
+<p>This is useful for providing defaults: <code>.foo // 1</code> will
+evaluate to <code>1</code> if there's no <code>.foo</code> element in the
+input. It's similar to how <code>or</code> is sometimes used in Python
+(jq's <code>or</code> operator is reserved for strictly Boolean
+operations).</p>
<div>
@@ -5325,7 +5316,7 @@ Alternative operator: <code>//</code>
<table>
<tr><th></th><td class="jqprogram">jq '.foo // 42'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 19}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 19}</td></tr>
<tr>
@@ -5358,17 +5349,16 @@ Alternative operator: <code>//</code>
<section id="try-catch">
<h3>
-
-try-catch
-
+ try-catch
</h3>
-
-<p>Errors can be caught by using <code>try EXP catch EXP</code>. The first expression is executed, and if it fails then the second is executed with the error message. The output of the handler, if any, is output as if it had been the output of the expression to try.</p>
-
+ <p>Errors can be caught by using <code>try EXP catch EXP</code>. The first
+expression is executed, and if it fails then the second is
+executed with the error message. The output of the handler,
+if any, is output as if it had been the output of the
+expression to try.</p>
<p>The <code>try EXP</code> form uses <code>empty</code> as the exception handler.</p>
-
<div>
@@ -5379,7 +5369,7 @@ try-catch
<div id="example78" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'try .a catch &quot;. is not an object&quot;'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'try .a catch &#34;. is not an object&#34;'</td></tr>
<tr><th>Input</th><td>true</td></tr>
@@ -5387,14 +5377,14 @@ try-catch
<th>Output</th>
- <td>&quot;. is not an object&quot;</td>
+ <td>&#34;. is not an object&#34;</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|try .a]'</td></tr>
- <tr><th>Input</th><td>[{}, true, {&quot;a&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{}, true, {&#34;a&#34;:1}]</td></tr>
<tr>
@@ -5407,7 +5397,7 @@ try-catch
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'try error(&quot;some exception&quot;) catch .'</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'try error(&#34;some exception&#34;) catch .'</td></tr>
<tr><th>Input</th><td>true</td></tr>
@@ -5415,7 +5405,7 @@ try-catch
<th>Output</th>
- <td>&quot;some exception&quot;</td>
+ <td>&#34;some exception&#34;</td>
</tr>
</table>
@@ -5427,53 +5417,42 @@ try-catch
<section id="Breakingoutofcontrolstructures">
<h3>
-
-Breaking out of control structures
-
+ Breaking out of control structures
</h3>
-
-<p>A convenient use of try/catch is to break out of control structures like <code>reduce</code>, <code>foreach</code>, <code>while</code>, and so on.</p>
-
+ <p>A convenient use of try/catch is to break out of control
+structures like <code>reduce</code>, <code>foreach</code>, <code>while</code>, and so on.</p>
<p>For example:</p>
-
-<pre><code># Repeat an expression until it raises &quot;break&quot; as an
+<pre><code># Repeat an expression until it raises "break" as an
# error, then stop repeating without re-raising the error.
-# But if the error caught is not &quot;break&quot; then re-raise it.
-try repeat(exp) catch .==&quot;break&quot; then empty else error;</code></pre>
-
-<p>jq has a syntax for named lexical labels to “break” or “go (back) to”:</p>
-
-<pre><code>label $out | ... break $out ...</code></pre>
-
-<p>The <code>break $label_name</code> expression will cause the program to to act as though the nearest (to the left) <code>label $label_name</code> produced <code>empty</code>.</p>
-
-<p>The relationship between the <code>break</code> and corresponding <code>label</code> is lexical: the label has to be “visible” from the break.</p>
-
+# But if the error caught is not "break" then re-raise it.
+try repeat(exp) catch .=="break" then empty else error;
+</code></pre>
+<p>jq has a syntax for named lexical labels to "break" or "go (back) to":</p>
+<pre><code>label $out | ... break $out ...
+</code></pre>
+<p>The <code>break $label_name</code> expression will cause the program to
+to act as though the nearest (to the left) <code>label $label_name</code>
+produced <code>empty</code>.</p>
+<p>The relationship between the <code>break</code> and corresponding <code>label</code>
+is lexical: the label has to be "visible" from the break.</p>
<p>To break out of a <code>reduce</code>, for example:</p>
-
-<pre><code>label $out | reduce .[] as $item (null; if .==false then break $out else ... end)</code></pre>
-
+<pre><code>label $out | reduce .[] as $item (null; if .==false then break $out else ... end)
+</code></pre>
<p>The following jq program produces a syntax error:</p>
-
-<pre><code>break $out</code></pre>
-
+<pre><code>break $out
+</code></pre>
<p>because no label <code>$out</code> is visible.</p>
-
</section>
<section id="ErrorSuppression/OptionalOperator:?">
<h3>
-
-Error Suppression / Optional Operator: <code>?</code>
-
+ Error Suppression / Optional Operator: <code>?</code>
</h3>
-
-<p>The <code>?</code> operator, used as <code>EXP?</code>, is shorthand for <code>try EXP</code>.</p>
-
+ <p>The <code>?</code> operator, used as <code>EXP?</code>, is shorthand for <code>try EXP</code>.</p>
<div>
@@ -5486,7 +5465,7 @@ Error Suppression / Optional Operator: <code>?</code>
<table>
<tr><th></th><td class="jqprogram">jq '[.[]|(.a)?]'</td></tr>
- <tr><th>Input</th><td>[{}, true, {&quot;a&quot;:1}]</td></tr>
+ <tr><th>Input</th><td>[{}, true, {&#34;a&#34;:1}]</td></tr>
<tr>
@@ -5507,71 +5486,48 @@ Error Suppression / Optional Operator: <code>?</code>
<section id="RegularexpressionsPCRE">
<h2>Regular expressions (PCRE)</h2>
-
-<p>jq uses the Oniguruma regular expression library, as do php, ruby, TextMate, Sublime Text, etc, so the description here will focus on jq specifics.</p>
-
-<p>The jq regex filters are defined so that they can be used using one of these patterns:</p>
-
+ <p>jq uses the Oniguruma regular expression library, as do php,
+ruby, TextMate, Sublime Text, etc, so the description here
+will focus on jq specifics.</p>
+<p>The jq regex filters are defined so that they can be used using
+one of these patterns:</p>
<pre><code>STRING | FILTER( REGEX )
STRING | FILTER( REGEX; FLAGS )
STRING | FILTER( [REGEX] )
-STRING | FILTER( [REGEX, FLAGS] )</code></pre>
-
-<p>where:</p>
-
-<ul>
-<li>STRING, REGEX and FLAGS are jq strings and subject to jq string interpolation;</li>
-
-<li>REGEX, after string interpolation, should be a valid PCRE regex;</li>
-
-<li>FILTER is one of <code>test</code>, <code>match</code>, or <code>capture</code>, as described below.</li>
-</ul>
-
+STRING | FILTER( [REGEX, FLAGS] )
+</code></pre>
+<p>where:
+<em> STRING, REGEX and FLAGS are jq strings and subject to jq string interpolation;
+</em> REGEX, after string interpolation, should be a valid PCRE regex;
+* FILTER is one of <code>test</code>, <code>match</code>, or <code>capture</code>, as described below.</p>
<p>FLAGS is a string consisting of one of more of the supported flags:</p>
-
<ul>
<li><code>g</code> - Global search (find all matches, not just the first)</li>
-
<li><code>i</code> - Case insensitive search</li>
-
-<li><code>m</code> - Multi line mode (‘.’ will match newlines)</li>
-
+<li><code>m</code> - Multi line mode ('.' will match newlines)</li>
<li><code>n</code> - Ignore empty matches</li>
-
<li><code>p</code> - Both s and m modes are enabled</li>
-
-<li><code>s</code> - Single line mode (‘^’ -&gt; ‘\A’, ‘$’ -&gt; ‘\Z’)</li>
-
+<li><code>s</code> - Single line mode ('^' -&gt; '\A', '$' -&gt; '\Z')</li>
<li><code>l</code> - Find longest possible matches</li>
-
<li><code>x</code> - Extended regex format (ignore whitespace and comments)</li>
</ul>
-
<p>To match whitespace in an x pattern use an escape such as \s, e.g.</p>
-
<ul>
-<li>test( “a\sb”, “x” ).</li>
+<li>test( "a\sb", "x" ).</li>
</ul>
-
<p>Note that certain flags may also be specified within REGEX, e.g.</p>
-
<ul>
-<li>jq -n ‘(“test”, “TEst”, “teST”, “TEST”) | test( “(?i)te(?-i)st” )’</li>
+<li>jq -n '("test", "TEst", "teST", "TEST") | test( "(?i)te(?-i)st" )'</li>
</ul>
-
<p>evaluates to: true, true, false, false.</p>
-
<section id="test(val),test(regex;flags)">
<h3>
-
-<code>test(val)</code>, <code>test(regex; flags)</code>
-
+ <code>test(val)</code>, <code>test(regex; flags)</code>
</h3>
-
-<p>Like <code>match</code>, but does not return match objects, only <code>true</code> or <code>false</code> for whether or not the regex matches the input.</p>
-
+ <p>Like <code>match</code>, but does not return match objects, only <code>true</code> or <code>false</code>
+for whether or not the regex matches the input.</p>
<div>
@@ -5583,8 +5539,8 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<div id="example80" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'test(&quot;foo&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foo&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'test(&#34;foo&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foo&#34;</td></tr>
<tr>
@@ -5597,8 +5553,8 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[] | test(&quot;a b c # spaces are ignored&quot;; &quot;ix&quot;)'</td></tr>
- <tr><th>Input</th><td>[&quot;xabcd&quot;, &quot;ABC&quot;]</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[] | test(&#34;a b c # spaces are ignored&#34;; &#34;ix&#34;)'</td></tr>
+ <tr><th>Input</th><td>[&#34;xabcd&#34;, &#34;ABC&#34;]</td></tr>
<tr>
@@ -5624,39 +5580,26 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<section id="match(val),match(regex;flags)">
<h3>
-
-<code>match(val)</code>, <code>match(regex; flags)</code>
-
+ <code>match(val)</code>, <code>match(regex; flags)</code>
</h3>
-
-<p><strong>match</strong> outputs an object for each match it finds. Matches have the following fields:</p>
-
+ <p><strong>match</strong> outputs an object for each match it finds. Matches have
+the following fields:</p>
<ul>
<li><code>offset</code> - offset in UTF-8 codepoints from the beginning of the input</li>
-
<li><code>length</code> - length in UTF-8 codepoints of the match</li>
-
<li><code>string</code> - the string that it matched</li>
-
<li><code>captures</code> - an array of objects representing capturing groups.</li>
</ul>
-
<p>Capturing group objects have the following fields:</p>
-
<ul>
<li><code>offset</code> - offset in UTF-8 codepoints from the beginning of the input</li>
-
<li><code>length</code> - length in UTF-8 codepoints of this capturing group</li>
-
<li><code>string</code> - the string that was captured</li>
-
<li><code>name</code> - the name of the capturing group (or <code>null</code> if it was unnamed)</li>
</ul>
-
<p>Capturing groups that did not match anything return an offset of -1</p>
-
<div>
@@ -5667,85 +5610,85 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<div id="example81" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'match(&quot;(abc)+&quot;; &quot;g&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;abc abc&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'match(&#34;(abc)+&#34;; &#34;g&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;abc abc&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;offset&quot;: 0, &quot;length&quot;: 3, &quot;string&quot;: &quot;abc&quot;, &quot;captures&quot;: [{&quot;offset&quot;: 0, &quot;length&quot;: 3, &quot;string&quot;: &quot;abc&quot;, &quot;name&quot;: null}]}</td>
+ <td>{&#34;offset&#34;: 0, &#34;length&#34;: 3, &#34;string&#34;: &#34;abc&#34;, &#34;captures&#34;: [{&#34;offset&#34;: 0, &#34;length&#34;: 3, &#34;string&#34;: &#34;abc&#34;, &#34;name&#34;: null}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;offset&quot;: 4, &quot;length&quot;: 3, &quot;string&quot;: &quot;abc&quot;, &quot;captures&quot;: [{&quot;offset&quot;: 4, &quot;length&quot;: 3, &quot;string&quot;: &quot;abc&quot;, &quot;name&quot;: null}]}</td>
+ <td>{&#34;offset&#34;: 4, &#34;length&#34;: 3, &#34;string&#34;: &#34;abc&#34;, &#34;captures&#34;: [{&#34;offset&#34;: 4, &#34;length&#34;: 3, &#34;string&#34;: &#34;abc&#34;, &#34;name&#34;: null}]}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'match(&quot;foo&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foo bar foo&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'match(&#34;foo&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foo bar foo&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;offset&quot;: 0, &quot;length&quot;: 3, &quot;string&quot;: &quot;foo&quot;, &quot;captures&quot;: []}</td>
+ <td>{&#34;offset&#34;: 0, &#34;length&#34;: 3, &#34;string&#34;: &#34;foo&#34;, &#34;captures&#34;: []}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'match([&quot;foo&quot;, &quot;ig&quot;])'</td></tr>
- <tr><th>Input</th><td>&quot;foo bar FOO&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'match([&#34;foo&#34;, &#34;ig&#34;])'</td></tr>
+ <tr><th>Input</th><td>&#34;foo bar FOO&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;offset&quot;: 0, &quot;length&quot;: 3, &quot;string&quot;: &quot;foo&quot;, &quot;captures&quot;: []}</td>
+ <td>{&#34;offset&#34;: 0, &#34;length&#34;: 3, &#34;string&#34;: &#34;foo&#34;, &#34;captures&#34;: []}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;offset&quot;: 8, &quot;length&quot;: 3, &quot;string&quot;: &quot;FOO&quot;, &quot;captures&quot;: []}</td>
+ <td>{&#34;offset&#34;: 8, &#34;length&#34;: 3, &#34;string&#34;: &#34;FOO&#34;, &#34;captures&#34;: []}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq 'match(&quot;foo (?&lt;bar123&gt;bar)? foo&quot;; &quot;ig&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;foo bar foo foo foo&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'match(&#34;foo (?&lt;bar123&gt;bar)? foo&#34;; &#34;ig&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;foo bar foo foo foo&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;offset&quot;: 0, &quot;length&quot;: 11, &quot;string&quot;: &quot;foo bar foo&quot;, &quot;captures&quot;: [{&quot;offset&quot;: 4, &quot;length&quot;: 3, &quot;string&quot;: &quot;bar&quot;, &quot;name&quot;: &quot;bar123&quot;}]}</td>
+ <td>{&#34;offset&#34;: 0, &#34;length&#34;: 11, &#34;string&#34;: &#34;foo bar foo&#34;, &#34;captures&#34;: [{&#34;offset&#34;: 4, &#34;length&#34;: 3, &#34;string&#34;: &#34;bar&#34;, &#34;name&#34;: &#34;bar123&#34;}]}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;offset&quot;: 12, &quot;length&quot;: 8, &quot;string&quot;: &quot;foo foo&quot;, &quot;captures&quot;: [{&quot;offset&quot;: -1, &quot;length&quot;: 0, &quot;string&quot;: null, &quot;name&quot;: &quot;bar123&quot;}]}</td>
+ <td>{&#34;offset&#34;: 12, &#34;length&#34;: 8, &#34;string&#34;: &#34;foo foo&#34;, &#34;captures&#34;: [{&#34;offset&#34;: -1, &#34;length&#34;: 0, &#34;string&#34;: null, &#34;name&#34;: &#34;bar123&#34;}]}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '[ match(&quot;.&quot;; &quot;g&quot;)] | length'</td></tr>
- <tr><th>Input</th><td>&quot;abc&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq '[ match(&#34;.&#34;; &#34;g&#34;)] | length'</td></tr>
+ <tr><th>Input</th><td>&#34;abc&#34;</td></tr>
<tr>
@@ -5764,14 +5707,12 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<section id="capture(val),capture(regex;flags)">
<h3>
-
-<code>capture(val)</code>, <code>capture(regex; flags)</code>
-
+ <code>capture(val)</code>, <code>capture(regex; flags)</code>
</h3>
-
-<p>Collects the named captures in a JSON object, with the name of each capture as the key, and the matched string as the corresponding value.</p>
-
+ <p>Collects the named captures in a JSON object, with the name
+of each capture as the key, and the matched string as the
+corresponding value.</p>
<div>
@@ -5783,15 +5724,15 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<div id="example82" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq 'capture(&quot;(?&lt;a&gt;[a-z]+)-(?&lt;n&gt;[0-9]+)&quot;)'</td></tr>
- <tr><th>Input</th><td>&quot;xyzzy-14&quot;</td></tr>
+ <tr><th></th><td class="jqprogram">jq 'capture(&#34;(?&lt;a&gt;[a-z]+)-(?&lt;n&gt;[0-9]+)&#34;)'</td></tr>
+ <tr><th>Input</th><td>&#34;xyzzy-14&#34;</td></tr>
<tr>
<th>Output</th>
- <td>{ &quot;a&quot;: &quot;xyzzy&quot;, &quot;n&quot;: &quot;14&quot; }</td>
+ <td>{ &#34;a&#34;: &#34;xyzzy&#34;, &#34;n&#34;: &#34;14&#34; }</td>
</tr>
</table>
@@ -5803,70 +5744,61 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<section id="scan(regex),scan(regex;flags)">
<h3>
-
-<code>scan(regex)</code>, <code>scan(regex; flags)</code>
-
+ <code>scan(regex)</code>, <code>scan(regex; flags)</code>
</h3>
-
-<p>Emit a stream of the non-overlapping substrings of the input that match the regex in accordance with the flags, if any have been specified. If there is no match, the stream is empty. To capture all the matches for each input string, use the idiom <code>[ expr ]</code>, e.g. <code>[ scan(regex) ]</code>.</p>
-
+ <p>Emit a stream of the non-overlapping substrings of the input
+that match the regex in accordance with the flags, if any
+have been specified. If there is no match, the stream is empty.
+To capture all the matches for each input string, use the idiom
+<code>[ expr ]</code>, e.g. <code>[ scan(regex) ]</code>.</p>
</section>
<section id="split(regex;flags)">
<h3>
-
-<code>split(regex; flags)</code>
-
+ <code>split(regex; flags)</code>
</h3>
-
-<p>For backwards compatibility, <code>split</code> splits on a string, not a regex.</p>
-
+ <p>For backwards compatibility, <code>split</code> splits on a string, not a regex.</p>
</section>
<section id="splits(regex),splits(regex;flags)">
<h3>
-
-<code>splits(regex)</code>, <code>splits(regex; flags)</code>
-
+ <code>splits(regex)</code>, <code>splits(regex; flags)</code>
</h3>
-
-<p>These provide the same results as their <code>split</code> counterparts, but as a stream instead of an array.</p>
-
+ <p>These provide the same results as their <code>split</code> counterparts,
+but as a stream instead of an array.</p>
</section>
<section id="sub(regex;tostring)sub(regex;string;flags)">
<h3>
-
-<code>sub(regex; tostring)</code> <code>sub(regex; string; flags)</code>
-
+ <code>sub(regex; tostring)</code> <code>sub(regex; string; flags)</code>
</h3>
-
-<p>Emit the string obtained by replacing the first match of regex in the input string with <code>tostring</code>, after interpolation. <code>tostring</code> 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 <code>capture</code>) to <code>tostring</code>, so a reference to a captured variable named “x” would take the form: “(.x)”.</p>
-
+ <p>Emit the string obtained by replacing the first match of regex in the
+input string with <code>tostring</code>, after interpolation. <code>tostring</code> 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 <code>capture</code>) to <code>tostring</code>, so a reference to a captured
+variable named "x" would take the form: "(.x)".</p>
</section>
<section id="gsub(regex;string),gsub(regex;string;flags)">
<h3>
-
-<code>gsub(regex; string)</code>, <code>gsub(regex; string; flags)</code>
-
+ <code>gsub(regex; string)</code>, <code>gsub(regex; string; flags)</code>
</h3>
-
-<p><code>gsub</code> is like <code>sub</code> but all the non-overlapping occurrences of the regex are replaced by the string, after interpolation.</p>
-
+ <p><code>gsub</code> is like <code>sub</code> but all the non-overlapping occurrences of the regex are
+replaced by the string, after interpolation.</p>
</section>
@@ -5875,79 +5807,100 @@ STRING | FILTER( [REGEX, FLAGS] )</code></pre>
<section id="Advancedfeatures">
<h2>Advanced features</h2>
-
-<p>Variables are an absolute necessity in most programming languages, but they’re relegated to an “advanced feature” in jq.</p>
-
-<p>In most languages, variables are the only means of passing around data. If you calculate a value, and you want to use it more than once, you’ll need to store it in a variable. To pass a value to another part of the program, you’ll need that part of the program to define a variable (as a function parameter, object member, or whatever) in which to place the data.</p>
-
-<p>It is also possible to define functions in jq, although this is is a feature whose biggest use is defining jq’s standard library (many jq functions such as <code>map</code> and <code>find</code> are in fact written in jq).</p>
-
-<p>jq has reduction operators, which are very powerful but a bit tricky. Again, these are mostly used internally, to define some useful bits of jq’s standard library.</p>
-
-<p>It may not be obvious at first, but jq is all about generators (yes, as often found in other languages). Some utilities are provided to help deal with generators.</p>
-
-<p>Some minimal I/O support (besides reading JSON from standard input, and writing JSON to standard output) is available.</p>
-
+ <p>Variables are an absolute necessity in most programming languages, but
+they're relegated to an "advanced feature" in jq.</p>
+<p>In most languages, variables are the only means of passing around
+data. If you calculate a value, and you want to use it more than once,
+you'll need to store it in a variable. To pass a value to another part
+of the program, you'll need that part of the program to define a
+variable (as a function parameter, object member, or whatever) in
+which to place the data.</p>
+<p>It is also possible to define functions in jq, although this is
+is a feature whose biggest use is defining jq's standard library
+(many jq functions such as <code>map</code> and <code>find</code> are in fact written
+in jq).</p>
+<p>jq has reduction operators, which are very powerful but a bit
+tricky. Again, these are mostly used internally, to define some
+useful bits of jq's standard library.</p>
+<p>It may not be obvious at first, but jq is all about generators
+(yes, as often found in other languages). Some utilities are
+provided to help deal with generators.</p>
+<p>Some minimal I/O support (besides reading JSON from standard
+input, and writing JSON to standard output) is available.</p>
<p>Finally, there is a module/library system.</p>
-
<section id="Variable/SymbolicBindingOperator:...as$identifier|...">
<h3>
-
-Variable / Symbolic Binding Operator: <code>... as $identifier | ...</code>
-
+ Variable / Symbolic Binding Operator: <code>... as $identifier | ...</code>
</h3>
-
-<p>In jq, all filters have an input and an output, so manual plumbing is not necessary to pass a value from one part of a program to the next. Many expressions, for instance <code>a + b</code>, pass their input to two distinct subexpressions (here <code>a</code> and <code>b</code> are both passed the same input), so variables aren’t usually necessary in order to use a value twice.</p>
-
-<p>For instance, calculating the average value of an array of numbers requires a few variables in most languages - at least one to hold the array, perhaps one for each element or for a loop counter. In jq, it’s simply <code>add / length</code> - the <code>add</code> expression is given the array and produces its sum, and the <code>length</code> expression is given the array and produces its length.</p>
-
-<p>So, there’s generally a cleaner way to solve most problems in jq than defining variables. Still, sometimes they do make things easier, so jq lets you define variables using <code>expression as $variable</code>. All variable names start with <code>$</code>. Here’s a slightly uglier version of the array-averaging example:</p>
-
-<pre><code>length as $array_length | add / $array_length</code></pre>
-
-<p>We’ll need a more complicated problem to find a situation where using variables actually makes our lives easier.</p>
-
-<p>Suppose we have an array of blog posts, with “author” and “title” fields, and another object which is used to map author usernames to real names. Our input looks like:</p>
-
-<pre><code>{&quot;posts&quot;: [{&quot;title&quot;: &quot;Frist psot&quot;, &quot;author&quot;: &quot;anon&quot;},
- {&quot;title&quot;: &quot;A well-written article&quot;, &quot;author&quot;: &quot;person1&quot;}],
- &quot;realnames&quot;: {&quot;anon&quot;: &quot;Anonymous Coward&quot;,
- &quot;person1&quot;: &quot;Person McPherson&quot;}}</code></pre>
-
-<p>We want to produce the posts with the author field containing a real name, as in:</p>
-
-<pre><code>{&quot;title&quot;: &quot;Frist psot&quot;, &quot;author&quot;: &quot;Anonymous Coward&quot;}
-{&quot;title&quot;: &quot;A well-written article&quot;, &quot;author&quot;: &quot;Person McPherson&quot;}</code></pre>
-
-<p>We use a variable, $names, to store the realnames object, so that we can refer to it later when looking up author usernames:</p>
-
-<pre><code>.realnames as $names | .posts[] | {title, author: $names[.author]}</code></pre>
-
-<p>The expression <code>exp as $x | ...</code> means: for each value of expression <code>exp</code>, run the rest of the pipeline with the entire original input, and with <code>$x</code> set to that value. Thus <code>as</code> functions as something of a foreach loop.</p>
-
-<p>Just as <code>{foo}</code> is a handy way of writing <code>{foo: .foo}</code>, so <code>{$foo}</code> is a handy way of writing <code>{foo:$foo}</code>.</p>
-
-<p>Multiple variables may be declared using a single <code>as</code> expression by providing a pattern that matches the structure of the input (this is known as “destructuring”):</p>
-
-<pre><code>. as {realnames: $names, posts: [$first, $second]} | ...</code></pre>
-
+ <p>In jq, all filters have an input and an output, so manual
+plumbing is not necessary to pass a value from one part of a program
+to the next. Many expressions, for instance <code>a + b</code>, pass their input
+to two distinct subexpressions (here <code>a</code> and <code>b</code> are both passed the
+same input), so variables aren't usually necessary in order to use a
+value twice.</p>
+<p>For instance, calculating the average value of an array of numbers
+requires a few variables in most languages - at least one to hold the
+array, perhaps one for each element or for a loop counter. In jq, it's
+simply <code>add / length</code> - the <code>add</code> expression is given the array and
+produces its sum, and the <code>length</code> expression is given the array and
+produces its length.</p>
+<p>So, there's generally a cleaner way to solve most problems in jq than
+defining variables. Still, sometimes they do make things easier, so jq
+lets you define variables using <code>expression as $variable</code>. All
+variable names start with <code>$</code>. Here's a slightly uglier version of the
+array-averaging example:</p>
+<pre><code>length as $array_length | add / $array_length
+</code></pre>
+<p>We'll need a more complicated problem to find a situation where using
+variables actually makes our lives easier.</p>
+<p>Suppose we have an array of blog posts, with "author" and "title"
+fields, and another object which is used to map author usernames to
+real names. Our input looks like:</p>
+<pre><code>{"posts": [{"title": "Frist psot", "author": "anon"},
+ {"title": "A well-written article", "author": "person1"}],
+ "realnames": {"anon": "Anonymous Coward",
+ "person1": "Person McPherson"}}
+</code></pre>
+<p>We want to produce the posts with the author field containing a real
+name, as in:</p>
+<pre><code>{"title": "Frist psot", "author": "Anonymous Coward"}
+{"title": "A well-written article", "author": "Person McPherson"}
+</code></pre>
+<p>We use a variable, $names, to store the realnames object, so that we
+can refer to it later when looking up author usernames:</p>
+<pre><code>.realnames as $names | .posts[] | {title, author: $names[.author]}
+</code></pre>
+<p>The expression <code>exp as $x | ...</code> means: for each value of expression
+<code>exp</code>, run the rest of the pipeline with the entire original input, and
+with <code>$x</code> set to that value. Thus <code>as</code> functions as something of a
+foreach loop.</p>
+<p>Just as <code>{foo}</code> is a handy way of writing <code>{foo: .foo}</code>, so
+<code>{$foo}</code> is a handy way of writing <code>{foo:$foo}</code>.</p>
+<p>Multiple variables may be declared using a single <code>as</code> expression by
+providing a pattern that matches the structure of the input
+(this is known as "destructuring"):</p>
+<pre><code>. as {realnames: $names, posts: [$first, $second]} | ...
+</code></pre>
<p>The variable declarations in array patterns (e.g., <code>. as
-[$first, $second]</code>) bind to the elements of the array in from the element at index zero on up, in order. When there is no value at the index for an array pattern element, <code>null</code> is bound to that variable.</p>
-
-<p>Variables are scoped over the rest of the expression that defines them, so</p>
-
-<pre><code>.realnames as $names | (.posts[] | {title, author: $names[.author]})</code></pre>
-
+[$first, $second]</code>) bind to the elements of the array in from
+the element at index zero on up, in order. When there is no
+value at the index for an array pattern element, <code>null</code> is
+bound to that variable.</p>
+<p>Variables are scoped over the rest of the expression that defines
+them, so</p>
+<pre><code>.realnames as $names | (.posts[] | {title, author: $names[.author]})
+</code></pre>
<p>will work, but</p>
-
-<pre><code>(.realnames as $names | .posts[]) | {title, author: $names[.author]}</code></pre>
-
-<p>won’t.</p>
-
-<p>For programming language theorists, it’s more accurate to say that jq variables are lexically-scoped bindings. In particular there’s no way to change the value of a binding; one can only setup a new binding with the same name, but which will not be visible where the old one was.</p>
-
+<pre><code>(.realnames as $names | .posts[]) | {title, author: $names[.author]}
+</code></pre>
+<p>won't.</p>
+<p>For programming language theorists, it's more accurate to
+say that jq variables are lexically-scoped bindings. In
+particular there's no way to change the value of a binding;
+one can only setup a new binding with the same name, but which
+will not be visible where the old one was.</p>
<div>
@@ -5960,7 +5913,7 @@ Variable / Symbolic Binding Operator: <code>... as $identifier | ...</code>
<table>
<tr><th></th><td class="jqprogram">jq '.bar as $x | .foo | . + $x'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;:10, &quot;bar&quot;:200}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;:10, &#34;bar&#34;:200}</td></tr>
<tr>
@@ -5988,7 +5941,7 @@ Variable / Symbolic Binding Operator: <code>... as $identifier | ...</code>
<table>
<tr><th></th><td class="jqprogram">jq '. as [$a, $b, {c: $c}] | $a + $b + $c'</td></tr>
- <tr><th>Input</th><td>[2, 3, {&quot;c&quot;: 4, &quot;d&quot;: 5}]</td></tr>
+ <tr><th>Input</th><td>[2, 3, {&#34;c&#34;: 4, &#34;d&#34;: 5}]</td></tr>
<tr>
@@ -6009,21 +5962,21 @@ Variable / Symbolic Binding Operator: <code>... as $identifier | ...</code>
<th>Output</th>
- <td>{&quot;a&quot;:0,&quot;b&quot;:null}</td>
+ <td>{&#34;a&#34;:0,&#34;b&#34;:null}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;a&quot;:0,&quot;b&quot;:1}</td>
+ <td>{&#34;a&#34;:0,&#34;b&#34;:1}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;a&quot;:2,&quot;b&quot;:1}</td>
+ <td>{&#34;a&#34;:2,&#34;b&#34;:1}</td>
</tr>
</table>
@@ -6035,35 +5988,35 @@ Variable / Symbolic Binding Operator: <code>... as $identifier | ...</code>
<section id="DestructuringAlternativeOperator:?//">
<h3>
-
-Destructuring Alternative Operator: <code>?//</code>
-
+ Destructuring Alternative Operator: <code>?//</code>
</h3>
-
-<p>The destructuring alternative operator provides a concise mechanism for destructuring an input that can take one of several forms.</p>
-
-<p>Suppose we have an API that returns a list of resources and events associated with them, and we want to get the user_id and timestamp of the first event for each resource. The API (having been clumsily converted from XML) will only wrap the events in an array if the resource has multiple events:</p>
-
-<pre><code>{&quot;resources&quot;: [{&quot;id&quot;: 1, &quot;kind&quot;: &quot;widget&quot;, &quot;events&quot;: {&quot;action&quot;: &quot;create&quot;, &quot;user_id&quot;: 1, &quot;ts&quot;: 13}},
- {&quot;id&quot;: 2, &quot;kind&quot;: &quot;widget&quot;, &quot;events&quot;: [{&quot;action&quot;: &quot;create&quot;, &quot;user_id&quot;: 1, &quot;ts&quot;: 14}, {&quot;action&quot;: &quot;destroy&quot;, &quot;user_id&quot;: 1, &quot;ts&quot;: 15}]}]}</code></pre>
-
+ <p>The destructuring alternative operator provides a concise mechanism
+for destructuring an input that can take one of several forms.</p>
+<p>Suppose we have an API that returns a list of resources and events
+associated with them, and we want to get the user_id and timestamp of
+the first event for each resource. The API (having been clumsily
+converted from XML) will only wrap the events in an array if the resource
+has multiple events:</p>
+<pre><code>{"resources": [{"id": 1, "kind": "widget", "events": {"action": "create", "user_id": 1, "ts": 13}},
+ {"id": 2, "kind": "widget", "events": [{"action": "create", "user_id": 1, "ts": 14}, {"action": "destroy", "user_id": 1, "ts": 15}]}]}
+</code></pre>
<p>We can use the destructuring alternative operator to handle this structural change simply:</p>
-
-<pre><code>.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}</code></pre>
-
-<p>Or, if we aren’t sure if the input is an array of values or an object:</p>
-
-<pre><code>.[] as [$id, $kind, $user_id, $ts] ?// {$id, $kind, $user_id, $ts} | ...</code></pre>
-
-<p>Each alternative need not define all of the same variables, but all named variables will be available to the subsequent expression. Variables not matched in the alternative that succeeded will be <code>null</code>:</p>
-
-<pre><code>.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$first_user_id, $first_ts}]} | {$user_id, $first_user_id, $kind, $id, $ts, $first_ts}</code></pre>
-
-<p>Additionally, if the subsequent expression returns an error, the alternative operator will attempt to try the next binding. Errors that occur during the final alternative are passed through.</p>
-
-<pre><code>[[3]] | .[] as [$a] ?// [$b] | if $a != null then error(&quot;err: \($a)&quot;) else {$a,$b} end</code></pre>
-
+<pre><code>.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$user_id, $ts}]} | {$user_id, $kind, $id, $ts}
+</code></pre>
+<p>Or, if we aren't sure if the input is an array of values or an object:</p>
+<pre><code>.[] as [$id, $kind, $user_id, $ts] ?// {$id, $kind, $user_id, $ts} | ...
+</code></pre>
+<p>Each alternative need not define all of the same variables, but all named
+variables will be available to the subsequent expression. Variables not
+matched in the alternative that succeeded will be <code>null</code>:</p>
+<pre><code>.resources[] as {$id, $kind, events: {$user_id, $ts}} ?// {$id, $kind, events: [{$first_user_id, $first_ts}]} | {$user_id, $first_user_id, $kind, $id, $ts, $first_ts}
+</code></pre>
+<p>Additionally, if the subsequent expression returns an error, the
+alternative operator will attempt to try the next binding. Errors
+that occur during the final alternative are passed through.</p>
+<pre><code>[[3]] | .[] as [$a] ?// [$b] | if $a != null then error("err: \($a)") else {$a,$b} end
+</code></pre>
<div>
@@ -6076,48 +6029,48 @@ Destructuring Alternative Operator: <code>?//</code>
<table>
<tr><th></th><td class="jqprogram">jq '.[] as {$a, $b, c: {$d, $e}} ?// {$a, $b, c: [{$d, $e}]} | {$a, $b, $d, $e}'</td></tr>
- <tr><th>Input</th><td>[{&quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: {&quot;d&quot;: 3, &quot;e&quot;: 4}}, {&quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: [{&quot;d&quot;: 3, &quot;e&quot;: 4}]}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;a&#34;: 1, &#34;b&#34;: 2, &#34;c&#34;: {&#34;d&#34;: 3, &#34;e&#34;: 4}}, {&#34;a&#34;: 1, &#34;b&#34;: 2, &#34;c&#34;: [{&#34;d&#34;: 3, &#34;e&#34;: 4}]}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;:1,&quot;b&quot;:2,&quot;d&quot;:3,&quot;e&quot;:4}</td>
+ <td>{&#34;a&#34;:1,&#34;b&#34;:2,&#34;d&#34;:3,&#34;e&#34;:4}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;a&quot;:1,&quot;b&quot;:2,&quot;d&quot;:3,&quot;e&quot;:4}</td>
+ <td>{&#34;a&#34;:1,&#34;b&#34;:2,&#34;d&#34;:3,&#34;e&#34;:4}</td>
</tr>
</table>
<table>
<tr><th></th><td class="jqprogram">jq '.[] as {$a, $b, c: {$d}} ?// {$a, $b, c: [{$e}]} | {$a, $b, $d, $e}'</td></tr>
- <tr><th>Input</th><td>[{&quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: {&quot;d&quot;: 3, &quot;e&quot;: 4}}, {&quot;a&quot;: 1, &quot;b&quot;: 2, &quot;c&quot;: [{&quot;d&quot;: 3, &quot;e&quot;: 4}]}]</td></tr>
+ <tr><th>Input</th><td>[{&#34;a&#34;: 1, &#34;b&#34;: 2, &#34;c&#34;: {&#34;d&#34;: 3, &#34;e&#34;: 4}}, {&#34;a&#34;: 1, &#34;b&#34;: 2, &#34;c&#34;: [{&#34;d&#34;: 3, &#34;e&#34;: 4}]}]</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;a&quot;:1,&quot;b&quot;:2,&quot;d&quot;:3,&quot;e&quot;:null}</td>
+ <td>{&#34;a&#34;:1,&#34;b&#34;:2,&#34;d&#34;:3,&#34;e&#34;:null}</td>
</tr>
<tr>
<th></th>
- <td>{&quot;a&quot;:1,&quot;b&quot;:2,&quot;d&quot;:null,&quot;e&quot;:4}</td>
+ <td>{&#34;a&#34;:1,&#34;b&#34;:2,&#34;d&#34;:null,&#34;e&#34;:4}</td>
</tr>
</table>
<table>
- <tr><th></th><td class="jqprogram">jq '.[] as [$a] ?// [$b] | if $a != null then error(&quot;err: \($a)&quot;) else {$a,$b} end'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '.[] as [$a] ?// [$b] | if $a != null then error(&#34;err: \($a)&#34;) else {$a,$b} end'</td></tr>
<tr><th>Input</th><td>[[3]]</td></tr>
@@ -6125,7 +6078,7 @@ Destructuring Alternative Operator: <code>?//</code>
<th>Output</th>
- <td>{&quot;a&quot;:null,&quot;b&quot;:3}</td>
+ <td>{&#34;a&#34;:null,&#34;b&#34;:3}</td>
</tr>
</table>
@@ -6137,39 +6090,48 @@ Destructuring Alternative Operator: <code>?//</code>
<section id="DefiningFunctions">
<h3>
-
-Defining Functions
-
+ Defining Functions
</h3>
-
-<p>You can give a filter a name using “def” syntax:</p>
-
-<pre><code>def increment: . + 1;</code></pre>
-
-<p>From then on, <code>increment</code> is usable as a filter just like a builtin function (in fact, this is how many of the builtins are defined). A function may take arguments:</p>
-
-<pre><code>def map(f): [.[] | f];</code></pre>
-
-<p>Arguments are passed as <em>filters</em> (functions with no arguments), <em>not</em> as values. The same argument may be referenced multiple times with different inputs (here <code>f</code> is run for each element of the input array). Arguments to a function work more like callbacks than like value arguments. This is important to understand. Consider:</p>
-
+ <p>You can give a filter a name using "def" syntax:</p>
+<pre><code>def increment: . + 1;
+</code></pre>
+<p>From then on, <code>increment</code> is usable as a filter just like a
+builtin function (in fact, this is how many of the builtins
+are defined). A function may take arguments:</p>
+<pre><code>def map(f): [.[] | f];
+</code></pre>
+<p>Arguments are passed as <em>filters</em> (functions with no
+arguments), <em>not</em> as values. The same argument may be
+referenced multiple times with different inputs (here <code>f</code> is
+run for each element of the input array). Arguments to a
+function work more like callbacks than like value arguments.
+This is important to understand. Consider:</p>
<pre><code>def foo(f): f|f;
-5|foo(.*2)</code></pre>
-
-<p>The result will be 20 because <code>f</code> is <code>.*2</code>, and during the first invocation of <code>f</code> <code>.</code> will be 5, and the second time it will be 10 (5 * 2), so the result will be 20. Function arguments are filters, and filters expect an input when invoked.</p>
-
-<p>If you want the value-argument behaviour for defining simple functions, you can just use a variable:</p>
-
-<pre><code>def addvalue(f): f as $f | map(. + $f);</code></pre>
-
+5|foo(.*2)
+</code></pre>
+<p>The result will be 20 because <code>f</code> is <code>.*2</code>, and during the
+first invocation of <code>f</code> <code>.</code> will be 5, and the second time it
+will be 10 (5 * 2), so the result will be 20. Function
+arguments are filters, and filters expect an input when
+invoked.</p>
+<p>If you want the value-argument behaviour for defining simple
+functions, you can just use a variable:</p>
+<pre><code>def addvalue(f): f as $f | map(. + $f);
+</code></pre>
<p>Or use the short-hand:</p>
-
-<pre><code>def addvalue($f): ...;</code></pre>
-
-<p>With either definition, <code>addvalue(.foo)</code> will add the current input’s <code>.foo</code> field to each element of the array. Do note that calling <code>addvalue(.[])</code> will cause the <code>map(. + $f)</code> part to be evaluated once per value in the value of <code>.</code> at the call site.</p>
-
-<p>Multiple definitions using the same function name are allowed. Each re-definition replaces the previous one for the same number of function arguments, but only for references from functions (or main program) subsequent to the re-definition. See also the section below on scoping.</p>
-
+<pre><code>def addvalue($f): ...;
+</code></pre>
+<p>With either definition, <code>addvalue(.foo)</code> will add the current
+input's <code>.foo</code> field to each element of the array. Do note
+that calling <code>addvalue(.[])</code> will cause the <code>map(. + $f)</code> part
+to be evaluated once per value in the value of <code>.</code> at the call
+site.</p>
+<p>Multiple definitions using the same function name are allowed.
+Each re-definition replaces the previous one for the same
+number of function arguments, but only for references from
+functions (or main program) subsequent to the re-definition.
+See also the section below on scoping.</p>
<div>
@@ -6215,40 +6177,43 @@ Defining Functions
<section id="Scoping">
<h3>
-
-Scoping
-
+ Scoping
</h3>
-
-<p>There are two types of symbols in jq: value bindings (a.k.a., “variables”), and functions. Both are scoped lexically, with expressions being able to refer only to symbols that have been defined “to the left” of them. The only exception to this rule is that functions can refer to themselves so as to be able to create recursive functions.</p>
-
-<p>For example, in the following expression there is a binding which is visible “to the right” of it, <code>... | .*3 as
-$times_three | [. + $times_three] | ...</code>, but not “to the left”. Consider this expression now, <code>... | (.*3 as
-$times_three | [.+ $times_three]) | ...</code>: here the binding <code>$times_three</code> is <em>not</em> visible past the closing parenthesis.</p>
-
+ <p>There are two types of symbols in jq: value bindings (a.k.a.,
+"variables"), and functions. Both are scoped lexically,
+with expressions being able to refer only to symbols that
+have been defined "to the left" of them. The only exception
+to this rule is that functions can refer to themselves so as
+to be able to create recursive functions.</p>
+<p>For example, in the following expression there is a binding
+which is visible "to the right" of it, <code>... | .*3 as
+$times_three | [. + $times_three] | ...</code>, but not "to the
+left". Consider this expression now, <code>... | (.*3 as
+$times_three | [.+ $times_three]) | ...</code>: here the binding
+<code>$times_three</code> is <em>not</em> visible past the closing parenthesis.</p>
</section>
<section id="Reduce">
<h3>
-
-Reduce
-
+ Reduce
</h3>
-
-<p>The <code>reduce</code> syntax in jq allows you to combine all of the results of an expression by accumulating them into a single answer. As an example, we’ll pass <code>[3,2,1]</code> to this expression:</p>
-
-<pre><code>reduce .[] as $item (0; . + $item)</code></pre>
-
-<p>For each result that <code>.[]</code> produces, <code>. + $item</code> is run to accumulate a running total, starting from 0. In this example, <code>.[]</code> produces the results 3, 2, and 1, so the effect is similar to running something like this:</p>
-
+ <p>The <code>reduce</code> syntax in jq allows you to combine all of the
+results of an expression by accumulating them into a single
+answer. As an example, we'll pass <code>[3,2,1]</code> to this expression:</p>
+<pre><code>reduce .[] as $item (0; . + $item)
+</code></pre>
+<p>For each result that <code>.[]</code> produces, <code>. + $item</code> is run to
+accumulate a running total, starting from 0. In this
+example, <code>.[]</code> produces the results 3, 2, and 1, so the
+effect is similar to running something like this:</p>
<pre><code>0 | (3 as $item | . + $item) |
(2 as $item | . + $item) |
- (1 as $item | . + $item)</code></pre>
-
+ (1 as $item | . + $item)
+</code></pre>
<div>
@@ -6280,14 +6245,10 @@ Reduce
<section id="isempty(exp)">
<h3>
-
-<code>isempty(exp)</code>
-
+ <code>isempty(exp)</code>
</h3>
-
-<p>Returns true if <code>exp</code> produces no outputs, false otherwise.</p>
-
+ <p>Returns true if <code>exp</code> produces no outputs, false otherwise.</p>
<div>
@@ -6319,14 +6280,10 @@ Reduce
<section id="limit(n;exp)">
<h3>
-
-<code>limit(n; exp)</code>
-
+ <code>limit(n; exp)</code>
</h3>
-
-<p>The <code>limit</code> function extracts up to <code>n</code> outputs from <code>exp</code>.</p>
-
+ <p>The <code>limit</code> function extracts up to <code>n</code> outputs from <code>exp</code>.</p>
<div>
@@ -6358,17 +6315,15 @@ Reduce
<section id="first(expr),last(expr),nth(n;expr)">
<h3>
-
-<code>first(expr)</code>, <code>last(expr)</code>, <code>nth(n; expr)</code>
-
+ <code>first(expr)</code>, <code>last(expr)</code>, <code>nth(n; expr)</code>
</h3>
-
-<p>The <code>first(expr)</code> and <code>last(expr)</code> functions extract the first and last values from <code>expr</code>, respectively.</p>
-
-<p>The <code>nth(n; expr)</code> function extracts the nth value output by <code>expr</code>. This can be defined as <code>def nth(n; expr):
-last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t support negative values of <code>n</code>.</p>
-
+ <p>The <code>first(expr)</code> and <code>last(expr)</code> functions extract the first
+and last values from <code>expr</code>, respectively.</p>
+<p>The <code>nth(n; expr)</code> function extracts the nth value output by
+<code>expr</code>. This can be defined as <code>def nth(n; expr):
+last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn't
+support negative values of <code>n</code>.</p>
<div>
@@ -6400,17 +6355,13 @@ last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t
<section id="first,last,nth(n)">
<h3>
-
-<code>first</code>, <code>last</code>, <code>nth(n)</code>
-
+ <code>first</code>, <code>last</code>, <code>nth(n)</code>
</h3>
-
-<p>The <code>first</code> and <code>last</code> functions extract the first and last values from any array at <code>.</code>.</p>
-
+ <p>The <code>first</code> and <code>last</code> functions extract the first
+and last values from any array at <code>.</code>.</p>
<p>The <code>nth(n)</code> function extracts the nth value of any array at <code>.</code>.</p>
-
<div>
@@ -6441,18 +6392,22 @@ last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t
<section id="foreach">
<h3>
-
-<code>foreach</code>
-
+ <code>foreach</code>
</h3>
-
-<p>The <code>foreach</code> syntax is similar to <code>reduce</code>, but intended to allow the construction of <code>limit</code> and reducers that produce intermediate results (see example).</p>
-
-<p>The form is <code>foreach EXP as $var (INIT; UPDATE; EXTRACT)</code>. Like <code>reduce</code>, <code>INIT</code> is evaluated once to produce a state value, then each output of <code>EXP</code> is bound to <code>$var</code>, <code>UPDATE</code> is evaluated for each output of <code>EXP</code> with the current state and with <code>$var</code> visible. Each value output by <code>UPDATE</code> replaces the previous state. Finally, <code>EXTRACT</code> is evaluated for each new state to extract an output of <code>foreach</code>.</p>
-
-<p>This is mostly useful only for constructing <code>reduce</code>- and <code>limit</code>-like functions. But it is much more general, as it allows for partial reductions (see the example below).</p>
-
+ <p>The <code>foreach</code> syntax is similar to <code>reduce</code>, but intended to
+allow the construction of <code>limit</code> and reducers that produce
+intermediate results (see example).</p>
+<p>The form is <code>foreach EXP as $var (INIT; UPDATE; EXTRACT)</code>.
+Like <code>reduce</code>, <code>INIT</code> is evaluated once to produce a state
+value, then each output of <code>EXP</code> is bound to <code>$var</code>, <code>UPDATE</code>
+is evaluated for each output of <code>EXP</code> with the current state
+and with <code>$var</code> visible. Each value output by <code>UPDATE</code>
+replaces the previous state. Finally, <code>EXTRACT</code> is evaluated
+for each new state to extract an output of <code>foreach</code>.</p>
+<p>This is mostly useful only for constructing <code>reduce</code>- and
+<code>limit</code>-like functions. But it is much more general, as it
+allows for partial reductions (see the example below).</p>
<div>
@@ -6465,14 +6420,14 @@ last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t
<table>
<tr><th></th><td class="jqprogram">jq '[foreach .[] as $item ([[],[]]; if $item == null then [[],.[0]] else [(.[0] + [$item]),[]] end; if $item == null then .[1] else empty end)]'</td></tr>
- <tr><th>Input</th><td>[1,2,3,4,null,&quot;a&quot;,&quot;b&quot;,null]</td></tr>
+ <tr><th>Input</th><td>[1,2,3,4,null,&#34;a&#34;,&#34;b&#34;,null]</td></tr>
<tr>
<th>Output</th>
- <td>[[1,2,3,4],[&quot;a&quot;,&quot;b&quot;]]</td>
+ <td>[[1,2,3,4],[&#34;a&#34;,&#34;b&#34;]]</td>
</tr>
</table>
@@ -6484,18 +6439,17 @@ last(limit(n + 1; expr));</code>. Note that <code>nth(n; expr)</code> doesn’t
<section id="Recursion">
<h3>
-
-Recursion
-
+ Recursion
</h3>
-
-<p>As described above, <code>recurse</code> uses recursion, and any jq function can be recursive. The <code>while</code> builtin is also implemented in terms of recursion.</p>
-
-<p>Tail calls are optimized whenever the expression to the left of the recursive call outputs its last value. In practice this means that the expression to the left of the recursive call should not produce more than one output for each input.</p>
-
+ <p>As described above, <code>recurse</code> uses recursion, and any jq
+function can be recursive. The <code>while</code> builtin is also
+implemented in terms of recursion.</p>
+<p>Tail calls are optimized whenever the expression to the left of
+the recursive call outputs its last value. In practice this
+means that the expression to the left of the recursive call
+should not produce more than one output for each input.</p>
<p>For example:</p>
-
<pre><code>def recurse(f): def r: ., (f | select(. != null) | r); r;
def while(cond; update):
@@ -6506,28 +6460,39 @@ def while(cond; update):
def repeat(exp):
def _repeat:
exp, _repeat;
- _repeat;</code></pre>
-
+ _repeat;
+</code></pre>
</section>
<section id="Generatorsanditerators">
<h3>
-
-Generators and iterators
-
+ Generators and iterators
</h3>
-
-<p>Some jq operators and functions are actually generators in that they can produce zero, one, or more values for each input, just as one might expect in other programming languages that have generators. For example, <code>.[]</code> generates all the values in its input (which must be an array or an object), <code>range(0; 10)</code> generates the integers between 0 and 10, and so on.</p>
-
-<p>Even the comma operator is a generator, generating first the values generated by the expression to the left of the comma, then for each of those, the values generate by the expression on the right of the comma.</p>
-
-<p>The <code>empty</code> builtin is the generator that produces zero outputs. The <code>empty</code> builtin backtracks to the preceding generator expression.</p>
-
-<p>All jq functions can be generators just by using builtin generators. It is also possible to define new generators using only recursion and the comma operator. If the recursive call(s) is(are) “in tail position” then the generator will be efficient. In the example below the recursive call by <code>_range</code> to itself is in tail position. The example shows off three advanced topics: tail recursion, generator construction, and sub-functions.</p>
-
+ <p>Some jq operators and functions are actually generators in
+that they can produce zero, one, or more values for each
+input, just as one might expect in other programming
+languages that have generators. For example, <code>.[]</code>
+generates all the values in its input (which must be an
+array or an object), <code>range(0; 10)</code> generates the integers
+between 0 and 10, and so on.</p>
+<p>Even the comma operator is a generator, generating first the
+values generated by the expression to the left of the comma,
+then for each of those, the values generate by the
+expression on the right of the comma.</p>
+<p>The <code>empty</code> builtin is the generator that produces zero
+outputs. The <code>empty</code> builtin backtracks to the preceding
+generator expression.</p>
+<p>All jq functions can be generators just by using builtin
+generators. It is also possible to define new generators
+using only recursion and the comma operator. If the
+recursive call(s) is(are) "in tail position" then the
+generator will be efficient. In the example below the
+recursive call by <code>_range</code> to itself is in tail position.
+The example shows off three advanced topics: tail recursion,
+generator construction, and sub-functions.</p>
<div>
@@ -6596,116 +6561,117 @@ Generators and iterators
<section id="Math">
<h2>Math</h2>
-
-<p>jq currently only has IEEE754 double-precision (64-bit) floating point number support.</p>
-
-<p>Besides simple arithmetic operators such as <code>+</code>, jq also has most standard math functions from the C math library. C math functions that take a single input argument (e.g., <code>sin()</code>) are available as zero-argument jq functions. C math functions that take two input arguments (e.g., <code>pow()</code>) are available as two-argument jq functions that ignore <code>.</code>. C math functions that take three input arguments are available as three-argument jq functions that ignore <code>.</code>.</p>
-
-<p>Availability of standard math functions depends on the availability of the corresponding math functions in your operating system and C math library. Unavailable math functions will be defined but will raise an error.</p>
-
-<p>One-input C math functions: <code>acos</code> <code>acosh</code> <code>asin</code> <code>asinh</code> <code>atan</code> <code>atanh</code> <code>cbrt</code> <code>ceil</code> <code>cos</code> <code>cosh</code> <code>erf</code> <code>erfc</code> <code>exp</code> <code>exp10</code> <code>exp2</code> <code>expm1</code> <code>fabs</code> <code>floor</code> <code>gamma</code> <code>j0</code> <code>j1</code> <code>lgamma</code> <code>log</code> <code>log10</code> <code>log1p</code> <code>log2</code> <code>logb</code> <code>nearbyint</code> <code>pow10</code> <code>rint</code> <code>round</code> <code>significand</code> <code>sin</code> <code>sinh</code> <code>sqrt</code> <code>tan</code> <code>tanh</code> <code>tgamma</code> <code>trunc</code> <code>y0</code> <code>y1</code>.</p>
-
-<p>Two-input C math functions: <code>atan2</code> <code>copysign</code> <code>drem</code> <code>fdim</code> <code>fmax</code> <code>fmin</code> <code>fmod</code> <code>frexp</code> <code>hypot</code> <code>jn</code> <code>ldexp</code> <code>modf</code> <code>nextafter</code> <code>nexttoward</code> <code>pow</code> <code>remainder</code> <code>scalb</code> <code>scalbln</code> <code>yn</code>.</p>
-
+ <p>jq currently only has IEEE754 double-precision (64-bit) floating
+point number support.</p>
+<p>Besides simple arithmetic operators such as <code>+</code>, jq also has most
+standard math functions from the C math library. C math functions
+that take a single input argument (e.g., <code>sin()</code>) are available as
+zero-argument jq functions. C math functions that take two input
+arguments (e.g., <code>pow()</code>) are available as two-argument jq
+functions that ignore <code>.</code>. C math functions that take three input
+arguments are available as three-argument jq functions that ignore
+<code>.</code>.</p>
+<p>Availability of standard math functions depends on the
+availability of the corresponding math functions in your operating
+system and C math library. Unavailable math functions will be
+defined but will raise an error.</p>
+<p>One-input C math functions: <code>acos</code> <code>acosh</code> <code>asin</code> <code>asinh</code> <code>atan</code>
+<code>atanh</code> <code>cbrt</code> <code>ceil</code> <code>cos</code> <code>cosh</code> <code>erf</code> <code>erfc</code> <code>exp</code> <code>exp10</code>
+<code>exp2</code> <code>expm1</code> <code>fabs</code> <code>floor</code> <code>gamma</code> <code>j0</code> <code>j1</code> <code>lgamma</code> <code>log</code>
+<code>log10</code> <code>log1p</code> <code>log2</code> <code>logb</code> <code>nearbyint</code> <code>pow10</code> <code>rint</code> <code>round</code>
+<code>significand</code> <code>sin</code> <code>sinh</code> <code>sqrt</code> <code>tan</code> <code>tanh</code> <code>tgamma</code> <code>trunc</code>
+<code>y0</code> <code>y1</code>.</p>
+<p>Two-input C math functions: <code>atan2</code> <code>copysign</code> <code>drem</code> <code>fdim</code>
+<code>fmax</code> <code>fmin</code> <code>fmod</code> <code>frexp</code> <code>hypot</code> <code>jn</code> <code>ldexp</code> <code>modf</code>
+<code>nextafter</code> <code>nexttoward</code> <code>pow</code> <code>remainder</code> <code>scalb</code> <code>scalbln</code> <code>yn</code>.</p>
<p>Three-input C math functions: <code>fma</code>.</p>
-
-<p>See your system’s manual for more information on each of these.</p>
-
+<p>See your system's manual for more information on each of these.</p>
</section>
<section id="IO">
<h2>I/O</h2>
-
-<p>At this time jq has minimal support for I/O, mostly in the form of control over when inputs are read. Two builtins functions are provided for this, <code>input</code> and <code>inputs</code>, that read from the same sources (e.g., <code>stdin</code>, files named on the command-line) as jq itself. These two builtins, and jq’s own reading actions, can be interleaved with each other.</p>
-
-<p>Two builtins provide minimal output capabilities, <code>debug</code>, and <code>stderr</code>. (Recall that a jq program’s output values are always output as JSON texts on <code>stdout</code>.) The <code>debug</code> builtin can have application-specific behavior, such as for executables that use the libjq C API but aren’t the jq executable itself. The <code>stderr</code> builtin outputs its input in raw mode to stder with no additional decoration, not even a newline.</p>
-
-<p>Most jq builtins are referentially transparent, and yield constant and repeatable value streams when applied to constant inputs. This is not true of I/O builtins.</p>
-
+ <p>At this time jq has minimal support for I/O, mostly in the
+form of control over when inputs are read. Two builtins functions
+are provided for this, <code>input</code> and <code>inputs</code>, that read from the
+same sources (e.g., <code>stdin</code>, files named on the command-line) as
+jq itself. These two builtins, and jq's own reading actions, can
+be interleaved with each other.</p>
+<p>Two builtins provide minimal output capabilities, <code>debug</code>, and
+<code>stderr</code>. (Recall that a jq program's output values are always
+output as JSON texts on <code>stdout</code>.) The <code>debug</code> builtin can have
+application-specific behavior, such as for executables that use
+the libjq C API but aren't the jq executable itself. The <code>stderr</code>
+builtin outputs its input in raw mode to stder with no additional
+decoration, not even a newline.</p>
+<p>Most jq builtins are referentially transparent, and yield constant
+and repeatable value streams when applied to constant inputs.
+This is not true of I/O builtins.</p>
<section id="input">
<h3>
-
-<code>input</code>
-
+ <code>input</code>
</h3>
-
-<p>Outputs one new input.</p>
-
+ <p>Outputs one new input.</p>
</section>
<section id="inputs">
<h3>
-
-<code>inputs</code>
-
+ <code>inputs</code>
</h3>
-
-<p>Outputs all remaining inputs, one by one.</p>
-
-<p>This is primarily useful for reductions over a program’s inputs.</p>
-
+ <p>Outputs all remaining inputs, one by one.</p>
+<p>This is primarily useful for reductions over a program's
+inputs.</p>
</section>
<section id="debug">
<h3>
-
-<code>debug</code>
-
+ <code>debug</code>
</h3>
-
-<p>Causes a debug message based on the input value to be produced. The jq executable wraps the input value with <code>[&quot;DEBUG:&quot;, &lt;input-value&gt;]</code> and prints that and a newline on stderr, compactly. This may change in the future.</p>
-
+ <p>Causes a debug message based on the input value to be
+produced. The jq executable wraps the input value with
+<code>["DEBUG:", &lt;input-value&gt;]</code> and prints that and a newline on
+stderr, compactly. This may change in the future.</p>
</section>
<section id="stderr">
<h3>
-
-<code>stderr</code>
-
+ <code>stderr</code>
</h3>
-
-<p>Prints its input in raw and compact mode to stderr with no additional decoration, not even a newline.</p>
-
+ <p>Prints its input in raw and compact mode to stderr with no
+additional decoration, not even a newline.</p>
</section>
<section id="input_filename">
<h3>
-
-<code>input_filename</code>
-
+ <code>input_filename</code>
</h3>
-
-<p>Returns the name of the file whose input is currently being filtered. Note that this will not work well unless jq is running in a UTF-8 locale.</p>
-
+ <p>Returns the name of the file whose input is currently being
+filtered. Note that this will not work well unless jq is
+running in a UTF-8 locale.</p>
</section>
<section id="input_line_number">
<h3>
-
-<code>input_line_number</code>
-
+ <code>input_line_number</code>
</h3>
-
-<p>Returns the line number of the input currently being filtered.</p>
-
+ <p>Returns the line number of the input currently being filtered.</p>
</section>
@@ -6714,28 +6680,30 @@ Generators and iterators
<section id="Streaming">
<h2>Streaming</h2>
-
-<p>With the <code>--stream</code> option jq can parse input texts in a streaming fashion, allowing jq programs to start processing large JSON texts immediately rather than after the parse completes. If you have a single JSON text that is 1GB in size, streaming it will allow you to process it much more quickly.</p>
-
-<p>However, streaming isn’t easy to deal with as the jq program will have <code>[&lt;path&gt;, &lt;leaf-value&gt;]</code> (and a few other forms) as inputs.</p>
-
+ <p>With the <code>--stream</code> option jq can parse input texts in a streaming
+fashion, allowing jq programs to start processing large JSON texts
+immediately rather than after the parse completes. If you have a
+single JSON text that is 1GB in size, streaming it will allow you
+to process it much more quickly.</p>
+<p>However, streaming isn't easy to deal with as the jq program will
+have <code>[&lt;path&gt;, &lt;leaf-value&gt;]</code> (and a few other forms) as inputs.</p>
<p>Several builtins are provided to make handling streams easier.</p>
-
-<p>The examples below use the streamed form of <code>[0,[1]]</code>, which is <code>[[0],0],[[1,0],1],[[1,0]],[[1]]</code>.</p>
-
-<p>Streaming forms include <code>[&lt;path&gt;, &lt;leaf-value&gt;]</code> (to indicate any scalar value, empty array, or empty object), and <code>[&lt;path&gt;]</code> (to indicate the end of an array or object). Future versions of jq run with <code>--stream</code> and <code>-seq</code> may output additional forms such as <code>[&quot;error message&quot;]</code> when an input text fails to parse.</p>
-
+<p>The examples below use the streamed form of <code>[0,[1]]</code>, which is
+<code>[[0],0],[[1,0],1],[[1,0]],[[1]]</code>.</p>
+<p>Streaming forms include <code>[&lt;path&gt;, &lt;leaf-value&gt;]</code> (to indicate any
+scalar value, empty array, or empty object), and <code>[&lt;path&gt;]</code> (to
+indicate the end of an array or object). Future versions of jq
+run with <code>--stream</code> and <code>-seq</code> may output additional forms such as
+<code>["error message"]</code> when an input text fails to parse.</p>
<section id="truncate_stream(stream_expression)">
<h3>
-
-<code>truncate_stream(stream_expression)</code>
-
+ <code>truncate_stream(stream_expression)</code>
</h3>
-
-<p>Consumes a number as input and truncates the corresponding number of path elements from the left of the outputs of the given streaming expression.</p>
-
+ <p>Consumes a number as input and truncates the corresponding
+number of path elements from the left of the outputs of the
+given streaming expression.</p>
<div>
@@ -6767,14 +6735,11 @@ Generators and iterators
<section id="fromstream(stream_expression)">
<h3>
-
-<code>fromstream(stream_expression)</code>
-
+ <code>fromstream(stream_expression)</code>
</h3>
-
-<p>Outputs values corresponding to the stream expression’s outputs.</p>
-
+ <p>Outputs values corresponding to the stream expression's
+outputs.</p>
<div>
@@ -6806,14 +6771,10 @@ Generators and iterators
<section id="tostream">
<h3>
-
-<code>tostream</code>
-
+ <code>tostream</code>
</h3>
-
-<p>The <code>tostream</code> builtin outputs the streamed form of its input.</p>
-
+ <p>The <code>tostream</code> builtin outputs the streamed form of its input.</p>
<div>
@@ -6826,7 +6787,7 @@ Generators and iterators
<table>
<tr><th></th><td class="jqprogram">jq '. as $dot|fromstream($dot|tostream)|.==$dot'</td></tr>
- <tr><th>Input</th><td>[0,[1,{&quot;a&quot;:1},{&quot;b&quot;:2}]]</td></tr>
+ <tr><th>Input</th><td>[0,[1,{&#34;a&#34;:1},{&#34;b&#34;:2}]]</td></tr>
<tr>
@@ -6847,44 +6808,64 @@ Generators and iterators
<section id="Assignment">
<h2>Assignment</h2>
-
-<p>Assignment works a little differently in jq than in most programming languages. jq doesn’t distinguish between references to and copies of something - two objects or arrays are either equal or not equal, without any further notion of being “the same object” or “not the same object”.</p>
-
-<p>If an object has two fields which are arrays, <code>.foo</code> and <code>.bar</code>, and you append something to <code>.foo</code>, then <code>.bar</code> will not get bigger, even if you’ve previously set <code>.bar = .foo</code>. If you’re used to programming in languages like Python, Java, Ruby, Javascript, etc. then you can think of it as though jq does a full deep copy of every object before it does the assignment (for performance it doesn’t actually do that, but that’s the general idea).</p>
-
-<p>This means that it’s impossible to build circular values in jq (such as an array whose first element is itself). This is quite intentional, and ensures that anything a jq program can produce can be represented in JSON.</p>
-
-<p>All the assignment operators in jq have path expressions on the left-hand side (LHS). The right-hand side (RHS) provides values to set to the paths named by the LHS path expressions.</p>
-
-<p>Values in jq are always immutable. Internally, assignment works by using a reduction to compute new, replacement values for <code>.</code> that have had all the desired assignments applied to <code>.</code>, then outputting the modified value. This might be made clear by this example: <code>{a:{b:{c:1}}} | (.a.b|=3), .</code>. This will output <code>{&quot;a&quot;:{&quot;b&quot;:3}}</code> and <code>{&quot;a&quot;:{&quot;b&quot;:{&quot;c&quot;:1}}}</code> because the last sub-expression, <code>.</code>, sees the original value, not the modified value.</p>
-
-<p>Most users will want to use modification assignment operators, such as <code>|=</code> or <code>+=</code>, rather than <code>=</code>.</p>
-
-<p>Note that the LHS of assignment operators refers to a value in <code>.</code>. Thus <code>$var.foo = 1</code> won’t work as expected (<code>$var.foo</code> is not a valid or useful path expression in <code>.</code>); use <code>$var | .foo =
+ <p>Assignment works a little differently in jq than in most
+programming languages. jq doesn't distinguish between references
+to and copies of something - two objects or arrays are either
+equal or not equal, without any further notion of being "the
+same object" or "not the same object".</p>
+<p>If an object has two fields which are arrays, <code>.foo</code> and <code>.bar</code>,
+and you append something to <code>.foo</code>, then <code>.bar</code> will not get
+bigger, even if you've previously set <code>.bar = .foo</code>. If you're
+used to programming in languages like Python, Java, Ruby,
+Javascript, etc. then you can think of it as though jq does a full
+deep copy of every object before it does the assignment (for
+performance it doesn't actually do that, but that's the general
+idea).</p>
+<p>This means that it's impossible to build circular values in jq
+(such as an array whose first element is itself). This is quite
+intentional, and ensures that anything a jq program can produce
+can be represented in JSON.</p>
+<p>All the assignment operators in jq have path expressions on the
+left-hand side (LHS). The right-hand side (RHS) provides values
+to set to the paths named by the LHS path expressions.</p>
+<p>Values in jq are always immutable. Internally, assignment works
+by using a reduction to compute new, replacement values for <code>.</code> that
+have had all the desired assignments applied to <code>.</code>, then
+outputting the modified value. This might be made clear by this
+example: <code>{a:{b:{c:1}}} | (.a.b|=3), .</code>. This will output
+<code>{"a":{"b":3}}</code> and <code>{"a":{"b":{"c":1}}}</code> because the last
+sub-expression, <code>.</code>, sees the original value, not the modified
+value.</p>
+<p>Most users will want to use modification assignment operators,
+such as <code>|=</code> or <code>+=</code>, rather than <code>=</code>.</p>
+<p>Note that the LHS of assignment operators refers to a value in
+<code>.</code>. Thus <code>$var.foo = 1</code> won't work as expected (<code>$var.foo</code> is
+not a valid or useful path expression in <code>.</code>); use <code>$var | .foo =
1</code> instead.</p>
-
-<p>Note too that <code>.a,.b=0</code> does not set <code>.a</code> and <code>.b</code>, but <code>(.a,.b)=0</code> sets both.</p>
-
+<p>Note too that <code>.a,.b=0</code> does not set <code>.a</code> and <code>.b</code>, but
+<code>(.a,.b)=0</code> sets both.</p>
<section id="Update-assignment:|=">
<h3>
-
-Update-assignment: <code>|=</code>
-
+ Update-assignment: <code>|=</code>
</h3>
-
-<p>This is the “update” operator ‘|=’. It takes a filter on the right-hand side and works out the new value for the property of <code>.</code> being assigned to by running the old value through this expression. For instance, (.foo, .bar) |= .+1 will build an object with the “foo” field set to the input’s “foo” plus 1, and the “bar” field set to the input’s “bar” plus 1.</p>
-
+ <p>This is the "update" operator '|='. It takes a filter on the
+right-hand side and works out the new value for the property
+of <code>.</code> being assigned to by running the old value through this
+expression. For instance, (.foo, .bar) |= .+1 will build an
+object with the "foo" field set to the input's "foo" plus 1,
+and the "bar" field set to the input's "bar" plus 1.</p>
<p>The left-hand side can be any general path expression; see <code>path()</code>.</p>
-
-<p>Note that the left-hand side of ‘|=’ refers to a value in <code>.</code>. Thus <code>$var.foo |= . + 1</code> won’t work as expected (<code>$var.foo</code> is not a valid or useful path expression in <code>.</code>); use <code>$var |
+<p>Note that the left-hand side of '|=' refers to a value in <code>.</code>.
+Thus <code>$var.foo |= . + 1</code> won't work as expected (<code>$var.foo</code> is
+not a valid or useful path expression in <code>.</code>); use <code>$var |
.foo |= . + 1</code> instead.</p>
-
-<p>If the right-hand side outputs no values (i.e., <code>empty</code>), then the left-hand side path will be deleted, as with <code>del(path)</code>.</p>
-
-<p>If the right-hand side outputs multiple values, only the first one will be used (COMPATIBILITY NOTE: in jq 1.5 and earlier releases, it used to be that only the last one was used).</p>
-
+<p>If the right-hand side outputs no values (i.e., <code>empty</code>), then
+the left-hand side path will be deleted, as with <code>del(path)</code>.</p>
+<p>If the right-hand side outputs multiple values, only the first
+one will be used (COMPATIBILITY NOTE: in jq 1.5 and earlier
+releases, it used to be that only the last one was used).</p>
<div>
@@ -6896,7 +6877,7 @@ Update-assignment: <code>|=</code>
<div id="example96" class="manual-example collapse">
<table>
- <tr><th></th><td class="jqprogram">jq '(..|select(type==&quot;boolean&quot;)) |= if . then 1 else 0 end'</td></tr>
+ <tr><th></th><td class="jqprogram">jq '(..|select(type==&#34;boolean&#34;)) |= if . then 1 else 0 end'</td></tr>
<tr><th>Input</th><td>[true,false,[5,true,[true,[false]],false]]</td></tr>
@@ -6916,14 +6897,12 @@ Update-assignment: <code>|=</code>
<section id="Arithmeticupdate-assignment:+=,-=,*=,/=,%=,//=">
<h3>
-
-Arithmetic update-assignment: <code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>, <code>%=</code>, <code>//=</code>
-
+ Arithmetic update-assignment: <code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>, <code>%=</code>, <code>//=</code>
</h3>
-
-<p>jq has a few operators of the form <code>a op= b</code>, which are all equivalent to <code>a |= . op b</code>. So, <code>+= 1</code> can be used to increment values, being the same as <code>|= . + 1</code>.</p>
-
+ <p>jq has a few operators of the form <code>a op= b</code>, which are all
+equivalent to <code>a |= . op b</code>. So, <code>+= 1</code> can be used to
+increment values, being the same as <code>|= . + 1</code>.</p>
<div>
@@ -6936,14 +6915,14 @@ Arithmetic update-assignment: <code>+=</code>, <code>-=</code>, <code>*=</code>,
<table>
<tr><th></th><td class="jqprogram">jq '.foo += 1'</td></tr>
- <tr><th>Input</th><td>{&quot;foo&quot;: 42}</td></tr>
+ <tr><th>Input</th><td>{&#34;foo&#34;: 42}</td></tr>
<tr>
<th>Output</th>
- <td>{&quot;foo&quot;: 43}</td>
+ <td>{&#34;foo&#34;: 43}</td>
</tr>
</table>
@@ -6955,69 +6934,75 @@ Arithmetic update-assignment: <code>+=</code>, <code>-=</code>, <code>*=</code>,
<section id="Plainassignment:=">
<h3>
-
-Plain assignment: <code>=</code>
-
+ Plain assignment: <code>=</code>
</h3>
-
-<p>This is the plain assignment operator. Unlike the others, the input to the right-hand-side (RHS) is the same as the input to the left-hand-side (LHS) rather than the value at the LHS path, and all values output by the RHS will be used (as shown below).</p>
-
-<p>If the RHS of ‘=’ produces multiple values, then for each such value jq will set the paths on the left-hand side to the value and then it will output the modified <code>.</code>. For example, <code>(.a,.b)=range(2)</code> outputs <code>{&quot;a&quot;:0,&quot;b&quot;:0}</code>, then <code>{&quot;a&quot;:1,&quot;b&quot;:1}</code>. The “update” assignment forms (see above) do not do this.</p>
-
-<p>This example should show the difference between ‘=’ and ‘|=’:</p>
-
-<p>Provide input ‘{“a”: {“b”: 10}, “b”: 20}’ to the programs:</p>
-
+ <p>This is the plain assignment operator. Unlike the others, the
+input to the right-hand-side (RHS) is the same as the input to
+the left-hand-side (LHS) rather than the value at the LHS
+path, and all values output by the RHS will be used (as shown
+below).</p>
+<p>If the RHS of '=' produces multiple values, then for each such
+value jq will set the paths on the left-hand side to the value
+and then it will output the modified <code>.</code>. For example,
+<code>(.a,.b)=range(2)</code> outputs <code>{"a":0,"b":0}</code>, then
+<code>{"a":1,"b":1}</code>. The "update" assignment forms (see above) do
+not do this.</p>
+<p>This example should show the difference between '=' and '|=':</p>
+<p>Provide input '{"a": {"b": 10}, "b": 20}' to the programs:</p>
<p>.a = .b</p>
-
<p>.a |= .b</p>
-
-<p>The former will set the “a” field of the input to the “b” field of the input, and produce the output {“a”: 20, “b”: 20}. The latter will set the “a” field of the input to the “a” field’s “b” field, producing {“a”: 10, “b”: 20}.</p>
-
-<p>Another example of the difference between ‘=’ and ‘|=’:</p>
-
+<p>The former will set the "a" field of the input to the "b"
+field of the input, and produce the output {"a": 20, "b": 20}.
+The latter will set the "a" field of the input to the "a"
+field's "b" field, producing {"a": 10, "b": 20}.</p>
+<p>Another example of the difference between '=' and '|=':</p>
<p>null|(.a,.b)=range(3)</p>
-
-<p>outputs ‘{“a”:0,“b”:0}’, ‘{“a”:1,“b”:1}’, and ‘{“a”:2,“b”:2}’, while</p>
-
+<p>outputs '{"a":0,"b":0}', '{"a":1,"b":1}', and '{"a":2,"b":2}',
+while</p>
<p>null|(.a,.b)|=range(3)</p>
-
-<p>outputs just ‘{“a”:0,“b”:0}’.</p>
-
+<p>outputs just '{"a":0,"b":0}'.</p>
</section>
<section id="Complexassignments">
<h3>
-
-Complex assignments
-
+ Complex assignments
</h3>
-
-<p>Lots more things are allowed on the left-hand side of a jq assignment than in most languages. We’ve already seen simple field accesses on the left hand side, and it’s no surprise that array accesses work just as well:</p>
-
-<pre><code>.posts[0].title = &quot;JQ Manual&quot;</code></pre>
-
-<p>What may come as a surprise is that the expression on the left may produce multiple results, referring to different points in the input document:</p>
-
-<pre><code>.posts[].comments |= . + [&quot;this is great&quot;]</code></pre>
-
-<p>That example appends the string “this is great” to the “comments” array of each post in the input (where the input is an object with a field “posts” which is an array of posts).</p>
-
-<p>When jq encounters an assignment like ‘a = b’, it records the “path” taken to select a part of the input document while executing a. This path is then used to find which part of the input to change while executing the assignment. Any filter may be used on the left-hand side of an equals - whichever paths it selects from the input will be where the assignment is performed.</p>
-
-<p>This is a very powerful operation. Suppose we wanted to add a comment to blog posts, using the same “blog” input above. This time, we only want to comment on the posts written by “stedolan”. We can find those posts using the “select” function described earlier:</p>
-
-<pre><code>.posts[] | select(.author == &quot;stedolan&quot;)</code></pre>
-
-<p>The paths provided by this operation point to each of the posts that “stedolan” wrote, and we can comment on each of them in the same way that we did before:</p>
-
-<pre><code>(.posts[] | select(.author == &quot;stedolan&quot;) | .comments) |=
- . + [&quot;terrible.&quot;]</code></pre>
-
+ <p>Lots more things are allowed on the left-hand side of a jq assignment
+than in most languages. We've already seen simple field accesses on
+the left hand side, and it's no surprise that array accesses work just
+as well:</p>
+<pre><code>.posts[0].title = "JQ Manual"
+</code></pre>
+<p>What may come as a surprise is that the expression on the left may
+produce multiple results, referring to different points in the input
+document:</p>
+<pre><code>.posts[].comments |= . + ["this is great"]
+</code></pre>
+<p>That example appends the string "this is great" to the "comments"
+array of each post in the input (where the input is an object with a
+field "posts" which is an array of posts).</p>
+<p>When jq encounters an assignment like 'a = b', it records the "path"
+taken to select a part of the input document while executing a. This
+path is then used to find which part of the input to change while
+executing the assignment. Any filter may be used on the
+left-hand side of an equals - whichever paths it selects from the
+input will be where the assignment is performed.</p>
+<p>This is a very powerful operation. Suppose we wanted to add a comment
+to blog posts, using the same "blog" input above. This time, we only
+want to comment on the posts written by "stedolan". We can find those
+posts using the "select" function described earlier:</p>
+<pre><code>.posts[] | select(.author == "stedolan")
+</code></pre>
+<p>The paths provided by this operation point to each of the posts that
+"stedolan" wrote, and we can comment on each of them in the same way
+that we did before:</p>
+<pre><code>(.posts[] | select(.author == "stedolan") | .comments) |=
+ . + ["terrible."]
+</code></pre>
</section>
@@ -7026,115 +7011,125 @@ Complex assignments
<section id="Modules">
<h2>Modules</h2>
-
-<p>jq has a library/module system. Modules are files whose names end in <code>.jq</code>.</p>
-
-<p>Modules imported by a program are searched for in a default search path (see below). The <code>import</code> and <code>include</code> directives allow the importer to alter this path.</p>
-
+ <p>jq has a library/module system. Modules are files whose names end
+in <code>.jq</code>.</p>
+<p>Modules imported by a program are searched for in a default search
+path (see below). The <code>import</code> and <code>include</code> directives allow the
+importer to alter this path.</p>
<p>Paths in the a search path are subject to various substitutions.</p>
-
-<p>For paths starting with “~/”, the user’s home directory is substituted for “~”.</p>
-
-<p>For paths starting with “$ORIGIN/”, the path of the jq executable is substituted for “$ORIGIN”.</p>
-
-<p>For paths starting with “./” or paths that are “.”, the path of the including file is substituted for “.”. For top-level programs given on the command-line, the current directory is used.</p>
-
-<p>Import directives can optionally specify a search path to which the default is appended.</p>
-
-<p>The default search path is the search path given to the <code>-L</code> command-line option, else <code>[&quot;~/.jq&quot;, &quot;$ORIGIN/../lib/jq&quot;,
-&quot;$ORIGIN/../lib&quot;]</code>.</p>
-
-<p>Null and empty string path elements terminate search path processing.</p>
-
-<p>A dependency with relative path “foo/bar” would be searched for in “foo/bar.jq” and “foo/bar/bar.jq” in the given search path. This is intended to allow modules to be placed in a directory along with, for example, version control files, README files, and so on, but also to allow for single-file modules.</p>
-
-<p>Consecutive components with the same name are not allowed to avoid ambiguities (e.g., “foo/foo”).</p>
-
-<p>For example, with <code>-L$HOME/.jq</code> a module <code>foo</code> can be found in <code>$HOME/.jq/foo.jq</code> and <code>$HOME/.jq/foo/foo.jq</code>.</p>
-
-<p>If “$HOME/.jq” is a file, it is sourced into the main program.</p>
-
-
- <section id="importRelativePathStringasNAME[<metadata>];">
+<p>For paths starting with "~/", the user's home directory is
+substituted for "~".</p>
+<p>For paths starting with "$ORIGIN/", the path of the jq executable
+is substituted for "$ORIGIN".</p>
+<p>For paths starting with "./" or paths that are ".", the path of
+the including file is substituted for ".". For top-level programs
+given on the command-line, the current directory is used.</p>
+<p>Import directives can optionally specify a search path to which
+the default is appended.</p>
+<p>The default search path is the search path given to the <code>-L</code>
+command-line option, else <code>["~/.jq", "$ORIGIN/../lib/jq",
+"$ORIGIN/../lib"]</code>.</p>
+<p>Null and empty string path elements terminate search path
+processing.</p>
+<p>A dependency with relative path "foo/bar" would be searched for in
+"foo/bar.jq" and "foo/bar/bar.jq" in the given search path. This
+is intended to allow modules to be placed in a directory along
+with, for example, version control files, README files, and so on,
+but also to allow for single-file modules.</p>
+<p>Consecutive components with the same name are not allowed to avoid
+ambiguities (e.g., "foo/foo").</p>
+<p>For example, with <code>-L$HOME/.jq</code> a module <code>foo</code> can be found in
+<code>$HOME/.jq/foo.jq</code> and <code>$HOME/.jq/foo/foo.jq</code>.</p>
+<p>If "$HOME/.jq" is a file, it is sourced into the main program.</p>
+
+ <section id="importRelativePathStringasNAME[&lt;metadata&gt;];">
<h3>
-
-<code>import RelativePathString as NAME [&lt;metadata&gt;];</code>
-
+ <code>import RelativePathString as NAME [&lt;metadata&gt;];</code>
</h3>
-
-<p>Imports a module found at the given path relative to a directory in a search path. A “.jq” suffix will be added to the relative path string. The module’s symbols are prefixed with “NAME::”.</p>
-
-<p>The optional metadata must be a constant jq expression. It should be an object with keys like “homepage” and so on. At this time jq only uses the “search” key/value of the metadata. The metadata is also made available to users via the <code>modulemeta</code> builtin.</p>
-
-<p>The “search” key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top-level search path.</p>
-
+ <p>Imports a module found at the given path relative to a
+directory in a search path. A ".jq" suffix will be added to
+the relative path string. The module's symbols are prefixed
+with "NAME::".</p>
+<p>The optional metadata must be a constant jq expression. It
+should be an object with keys like "homepage" and so on. At
+this time jq only uses the "search" key/value of the metadata.
+The metadata is also made available to users via the
+<code>modulemeta</code> builtin.</p>
+<p>The "search" key in the metadata, if present, should have a
+string or array value (array of strings); this is the search
+path to be prefixed to the top-level search path.</p>
</section>
- <section id="includeRelativePathString[<metadata>];">
+ <section id="includeRelativePathString[&lt;metadata&gt;];">
<h3>
-
-<code>include RelativePathString [&lt;metadata&gt;];</code>
-
+ <code>include RelativePathString [&lt;metadata&gt;];</code>
</h3>
-
-<p>Imports a module found at the given path relative to a directory in a search path as if it were included in place. A “.jq” suffix will be added to the relative path string. The module’s symbols are imported into the caller’s namespace as if the module’s content had been included directly.</p>
-
-<p>The optional metadata must be a constant jq expression. It should be an object with keys like “homepage” and so on. At this time jq only uses the “search” key/value of the metadata. The metadata is also made available to users via the <code>modulemeta</code> builtin.</p>
-
+ <p>Imports a module found at the given path relative to a
+directory in a search path as if it were included in place. A
+".jq" suffix will be added to the relative path string. The
+module's symbols are imported into the caller's namespace as
+if the module's content had been included directly.</p>
+<p>The optional metadata must be a constant jq expression. It
+should be an object with keys like "homepage" and so on. At
+this time jq only uses the "search" key/value of the metadata.
+The metadata is also made available to users via the
+<code>modulemeta</code> builtin.</p>
</section>
- <section id="importRelativePathStringas$NAME[<metadata>];">
+ <section id="importRelativePathStringas$NAME[&lt;metadata&gt;];">
<h3>
-
-<code>import RelativePathString as $NAME [&lt;metadata&gt;];</code>
-
+ <code>import RelativePathString as $NAME [&lt;metadata&gt;];</code>
</h3>
-
-<p>Imports a JSON file found at the given path relative to a directory in a search path. A “.json” suffix will be added to the relative path string. The file’s data will be available as <code>$NAME::NAME</code>.</p>
-
-<p>The optional metadata must be a constant jq expression. It should be an object with keys like “homepage” and so on. At this time jq only uses the “search” key/value of the metadata. The metadata is also made available to users via the <code>modulemeta</code> builtin.</p>
-
-<p>The “search” key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top-level search path.</p>
-
+ <p>Imports a JSON file found at the given path relative to a
+directory in a search path. A ".json" suffix will be added to
+the relative path string. The file's data will be available
+as <code>$NAME::NAME</code>.</p>
+<p>The optional metadata must be a constant jq expression. It
+should be an object with keys like "homepage" and so on. At
+this time jq only uses the "search" key/value of the metadata.
+The metadata is also made available to users via the
+<code>modulemeta</code> builtin.</p>
+<p>The "search" key in the metadata, if present, should have a
+string or array value (array of strings); this is the search
+path to be prefixed to the top-level search path.</p>
</section>
- <section id="module<metadata>;">
+ <section id="module&lt;metadata&gt;;">
<h3>
-
-<code>module &lt;metadata&gt;;</code>
-
+ <code>module &lt;metadata&gt;;</code>
</h3>
-
-<p>This directive is entirely optional. It’s not required for proper operation. It serves only the purpose of providing metadata that can be read with the <code>modulemeta</code> builtin.</p>
-
-<p>The metadata must be a constant jq expression. It should be an object with keys like “homepage”. At this time jq doesn’t use this metadata, but it is made available to users via the <code>modulemeta</code> builtin.</p>
-
+ <p>This directive is entirely optional. It's not required for
+proper operation. It serves only the purpose of providing
+metadata that can be read with the <code>modulemeta</code> builtin.</p>
+<p>The metadata must be a constant jq expression. It should be
+an object with keys like "homepage". At this time jq doesn't
+use this metadata, but it is made available to users via the
+<code>modulemeta</code> builtin.</p>
</section>
<section id="modulemeta">
<h3>
-
-<code>modulemeta</code>
-
+ <code>modulemeta</code>
</h3>
-
-<p>Takes a module name as input and outputs the module’s metadata as an object, with the module’s imports (including metadata) as an array value for the “deps” key.</p>
-
-<p>Programs can use this to query a module’s metadata, which they could then use to, for example, search for, download, and install missing dependencies.</p>
-
+ <p>Takes a module name as input and outputs the module's metadata
+as an object, with the module's imports (including metadata)
+as an array value for the "deps" key.</p>
+<p>Programs can use this to query a module's metadata, which they
+could then use to, for example, search for, download, and
+install missing dependencies.</p>
</section>
@@ -7143,63 +7138,42 @@ Complex assignments
<section id="Colors">
<h2>Colors</h2>
-
-<p>To configure alternative colors just set the <code>JQ_COLORS</code> environment variable to colon-delimited list of partial terminal escape sequences like <code>&quot;1;31&quot;</code>, in this order:</p>
-
+ <p>To configure alternative colors just set the <code>JQ_COLORS</code>
+environment variable to colon-delimited list of partial terminal
+escape sequences like <code>"1;31"</code>, in this order:</p>
<ul>
<li>color for <code>null</code></li>
-
<li>color for <code>false</code></li>
-
<li>color for <code>true</code></li>
-
<li>color for numbers</li>
-
<li>color for strings</li>
-
<li>color for arrays</li>
-
<li>color for objects</li>
</ul>
-
-<p>The default color scheme is the same as setting <code>&quot;JQ_COLORS=1;30:0;39:0;39:0;39:0;32:1;39:1;39&quot;</code>.</p>
-
-<p>This is not a manual for VT100/ANSI escapes. However, each of these color specifications should consist of two numbers separated by a semi-colon, where the first number is one of these:</p>
-
+<p>The default color scheme is the same as setting
+<code>"JQ_COLORS=1;30:0;37:0;37:0;37:0;32:1;37:1;37"</code>.</p>
+<p>This is not a manual for VT100/ANSI escapes. However, each of
+these color specifications should consist of two numbers separated
+by a semi-colon, where the first number is one of these:</p>
<ul>
<li>1 (bright)</li>
-
<li>2 (dim)</li>
-
<li>4 (underscore)</li>
-
<li>5 (blink)</li>
-
<li>7 (reverse)</li>
-
<li>8 (hidden)</li>
</ul>
-
<p>and the second is one of these:</p>
-
<ul>
<li>30 (black)</li>
-
<li>31 (red)</li>
-
<li>32 (green)</li>
-
<li>33 (yellow)</li>
-
<li>34 (blue)</li>
-
<li>35 (magenta)</li>
-
<li>36 (cyan)</li>
-
<li>37 (white)</li>
</ul>
-
</section>
@@ -7209,7 +7183,7 @@ Complex assignments
<footer>
<div class="container">
- <p>This website is made with <a href="http://www.tinytree.info">Bonsai</a> and <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
+ <p>This website is made with <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
<p>jq is licensed under the MIT license (code) and the <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a> license (docs).</p>
</div>
</footer>
@@ -7217,7 +7191,6 @@ Complex assignments
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<script src="https://twitter.github.io/typeahead.js/releases/0.11.1/typeahead.bundle.js"></script>
-
<script>
var section_map = {
@@ -7232,7 +7205,7 @@ Complex assignments
"Optional Object Identifier-Index: .foo?" : "OptionalObjectIdentifier-Index:.foo?",
- "Generic Object Index: .[<string>]" : "GenericObjectIndex:.[<string>]",
+ "Generic Object Index: .[\u003cstring\u003e]" : "GenericObjectIndex:.[\u003cstring\u003e]",
"Array Index: .[2]" : "ArrayIndex:.[2]",
@@ -7402,7 +7375,7 @@ Complex assignments
"if-then-else" : "if-then-else",
- ">, >=, <=, <" : ">,>=,<=,<",
+ "\u003e, \u003e=, \u003c=, \u003c" : "\u003e,\u003e=,\u003c=,\u003c",
"and/or/not" : "and/or/not",
@@ -7508,13 +7481,13 @@ Complex assignments
,
- "import RelativePathString as NAME [<metadata>];" : "importRelativePathStringasNAME[<metadata>];",
+ "import RelativePathString as NAME [\u003cmetadata\u003e];" : "importRelativePathStringasNAME[\u003cmetadata\u003e];",
- "include RelativePathString [<metadata>];" : "includeRelativePathString[<metadata>];",
+ "include RelativePathString [\u003cmetadata\u003e];" : "includeRelativePathString[\u003cmetadata\u003e];",
- "import RelativePathString as $NAME [<metadata>];" : "importRelativePathStringas$NAME[<metadata>];",
+ "import RelativePathString as $NAME [\u003cmetadata\u003e];" : "importRelativePathStringas$NAME[\u003cmetadata\u003e];",
- "module <metadata>;" : "module<metadata>;",
+ "module \u003cmetadata\u003e;" : "module\u003cmetadata\u003e;",
"modulemeta" : "modulemeta",
@@ -7529,4 +7502,4 @@ Complex assignments
</script>
<script src="/jq/js/manual-search.js"></script>
</body>
-</html>
+</html> \ No newline at end of file
diff --git a/tutorial/index.html b/tutorial/index.html
index e906b6d..e694a0a 100644
--- a/tutorial/index.html
+++ b/tutorial/index.html
@@ -18,7 +18,6 @@
<![endif]-->
</head>
-
<body id="tutorial">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
@@ -56,15 +55,13 @@
</div>
</div>
-
<div class="container">
<div class="row">
<h1>Tutorial</h1>
-
-<p>GitHub has a JSON API, so let’s play with that. This URL gets us the last 5 commits from the jq repo.</p>
-
+ <p>GitHub has a JSON API, so let's play with that. This URL gets us the last
+5 commits from the jq repo.</p>
@@ -75,37 +72,37 @@
<div class="tutorial-example">
<div class="accordion-heading">
- <pre>curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5'</pre>
+ <pre>curl &#39;https://api.github.com/repos/stedolan/jq/commits?per_page=5&#39;</pre>
<a data-toggle="collapse" href="#result1">Show result</a>
</div>
<div id="result1" class="accordion-body collapse">
<pre>[
{
- "sha": "d25341478381063d1c76e81b3a52e0592a7c997f",
- "commit": {
- "author": {
- "name": "Stephen Dolan",
- "email": "mu@netsoc.tcd.ie",
- "date": "2013-06-22T16:30:59Z"
+ &#34;sha&#34;: &#34;d25341478381063d1c76e81b3a52e0592a7c997f&#34;,
+ &#34;commit&#34;: {
+ &#34;author&#34;: {
+ &#34;name&#34;: &#34;Stephen Dolan&#34;,
+ &#34;email&#34;: &#34;mu@netsoc.tcd.ie&#34;,
+ &#34;date&#34;: &#34;2013-06-22T16:30:59Z&#34;
},
- "committer": {
- "name": "Stephen Dolan",
- "email": "mu@netsoc.tcd.ie",
- "date": "2013-06-22T16:30:59Z"
+ &#34;committer&#34;: {
+ &#34;name&#34;: &#34;Stephen Dolan&#34;,
+ &#34;email&#34;: &#34;mu@netsoc.tcd.ie&#34;,
+ &#34;date&#34;: &#34;2013-06-22T16:30:59Z&#34;
},
- "message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161",
- "tree": {
- "sha": "6ab697a8dfb5a96e124666bf6d6213822599fb40",
- "url": "https://api.github.com/repos/stedolan/jq/git/trees/6ab697a8dfb5a96e124666bf6d6213822599fb40"
+ &#34;message&#34;: &#34;Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161&#34;,
+ &#34;tree&#34;: {
+ &#34;sha&#34;: &#34;6ab697a8dfb5a96e124666bf6d6213822599fb40&#34;,
+ &#34;url&#34;: &#34;https://api.github.com/repos/stedolan/jq/git/trees/6ab697a8dfb5a96e124666bf6d6213822599fb40&#34;
},
- "url": "https://api.github.com/repos/stedolan/jq/git/commits/d25341478381063d1c76e81b3a52e0592a7c997f",
- "comment_count": 0
+ &#34;url&#34;: &#34;https://api.github.com/repos/stedolan/jq/git/commits/d25341478381063d1c76e81b3a52e0592a7c997f&#34;,
+ &#34;comment_count&#34;: 0
},
- "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",
- "author": {
- "login": "stedolan",
+ &#34;url&#34;: &#34;https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f&#34;,
+ &#34;html_url&#34;: &#34;https://github.com/stedolan/jq/commit/d25341478381063d1c76e81b3a52e0592a7c997f&#34;,
+ &#34;comments_url&#34;: &#34;https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f/comments&#34;,
+ &#34;author&#34;: {
+ &#34;login&#34;: &#34;stedolan&#34;,
...
</pre>
</div>
@@ -113,9 +110,10 @@
-
-<p>GitHub returns nicely formatted JSON. For servers that don’t, it can be helpful to pipe the response through jq to pretty-print it. The simplest jq program is the expression <code>.</code>, which takes the input and produces it unchanged as output.</p>
-
+ <p>GitHub returns nicely formatted JSON. For servers that don't, it can be
+helpful to pipe the response through jq to pretty-print it. The simplest
+jq program is the expression <code>.</code>, which takes the input and produces it
+unchanged as output.</p>
@@ -126,37 +124,37 @@
<div class="tutorial-example">
<div class="accordion-heading">
- <pre>curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | jq '.'</pre>
+ <pre>curl &#39;https://api.github.com/repos/stedolan/jq/commits?per_page=5&#39; | jq &#39;.&#39;</pre>
<a data-toggle="collapse" href="#result2">Show result</a>
</div>
<div id="result2" class="accordion-body collapse">
<pre>[
{
- "sha": "d25341478381063d1c76e81b3a52e0592a7c997f",
- "commit": {
- "author": {
- "name": "Stephen Dolan",
- "email": "mu@netsoc.tcd.ie",
- "date": "2013-06-22T16:30:59Z"
+ &#34;sha&#34;: &#34;d25341478381063d1c76e81b3a52e0592a7c997f&#34;,
+ &#34;commit&#34;: {
+ &#34;author&#34;: {
+ &#34;name&#34;: &#34;Stephen Dolan&#34;,
+ &#34;email&#34;: &#34;mu@netsoc.tcd.ie&#34;,
+ &#34;date&#34;: &#34;2013-06-22T16:30:59Z&#34;
},
- "committer": {
- "name": "Stephen Dolan",
- "email": "mu@netsoc.tcd.ie",
- "date": "2013-06-22T16:30:59Z"
+ &#34;committer&#34;: {
+ &#34;name&#34;: &#34;Stephen Dolan&#34;,
+ &#34;email&#34;: &#34;mu@netsoc.tcd.ie&#34;,
+ &#34;date&#34;: &#34;2013-06-22T16:30:59Z&#34;
},
- "message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161",
- "tree": {
- "sha": "6ab697a8dfb5a96e124666bf6d6213822599fb40",
- "url": "https://api.github.com/repos/stedolan/jq/git/trees/6ab697a8dfb5a96e124666bf6d6213822599fb40"
+ &#34;message&#34;: &#34;Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161&#34;,
+ &#34;tree&#34;: {
+ &#34;sha&#34;: &#34;6ab697a8dfb5a96e124666bf6d6213822599fb40&#34;,
+ &#34;url&#34;: &#34;https://api.github.com/repos/stedolan/jq/git/trees/6ab697a8dfb5a96e124666bf6d6213822599fb40&#34;
},
- "url": "https://api.github.com/repos/stedolan/jq/git/commits/d25341478381063d1c76e81b3a52e0592a7c997f",
- "comment_count": 0
+ &#34;url&#34;: &#34;https://api.github.com/repos/stedolan/jq/git/commits/d25341478381063d1c76e81b3a52e0592a7c997f&#34;,
+ &#34;comment_count&#34;: 0
},
- "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",
- "author": {
- "login": "stedolan",
+ &#34;url&#34;: &#34;https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f&#34;,
+ &#34;html_url&#34;: &#34;https://github.com/stedolan/jq/commit/d25341478381063d1c76e81b3a52e0592a7c997f&#34;,
+ &#34;comments_url&#34;: &#34;https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f/comments&#34;,
+ &#34;author&#34;: {
+ &#34;login&#34;: &#34;stedolan&#34;,
...
</pre>
</div>
@@ -164,9 +162,7 @@
-
-<p>We can use jq to extract just the first commit.</p>
-
+ <p>We can use jq to extract just the first commit.</p>
@@ -177,82 +173,82 @@
<div class="tutorial-example">
<div class="accordion-heading">
- <pre>curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | jq '.[0]'</pre>
+ <pre>curl &#39;https://api.github.com/repos/stedolan/jq/commits?per_page=5&#39; | jq &#39;.[0]&#39;</pre>
<a data-toggle="collapse" href="#result3">Show result</a>
</div>
<div id="result3" class="accordion-body collapse">
<pre>{
- "sha": "d25341478381063d1c76e81b3a52e0592a7c997f",
- "commit": {
- "author": {
- "name": "Stephen Dolan",
- "email": "mu@netsoc.tcd.ie",
- "date": "2013-06-22T16:30:59Z"
+ &#34;sha&#34;: &#34;d25341478381063d1c76e81b3a52e0592a7c997f&#34;,
+ &#34;commit&#34;: {
+ &#34;author&#34;: {
+ &#34;name&#34;: &#34;Stephen Dolan&#34;,
+ &#34;email&#34;: &#34;mu@netsoc.tcd.ie&#34;,
+ &#34;date&#34;: &#34;2013-06-22T16:30:59Z&#34;
},
- "committer": {
- "name": "Stephen Dolan",
- "email": "mu@netsoc.tcd.ie",
- "date": "2013-06-22T16:30:59Z"
+ &#34;committer&#34;: {
+ &#34;name&#34;: &#34;Stephen Dolan&#34;,
+ &#34;email&#34;: &#34;mu@netsoc.tcd.ie&#34;,
+ &#34;date&#34;: &#34;2013-06-22T16:30:59Z&#34;
},
- "message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161",
- "tree": {
- "sha": "6ab697a8dfb5a96e124666bf6d6213822599fb40",
- "url": "https://api.github.com/repos/stedolan/jq/git/trees/6ab697a8dfb5a96e124666bf6d6213822599fb40"
+ &#34;message&#34;: &#34;Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161&#34;,
+ &#34;tree&#34;: {
+ &#34;sha&#34;: &#34;6ab697a8dfb5a96e124666bf6d6213822599fb40&#34;,
+ &#34;url&#34;: &#34;https://api.github.com/repos/stedolan/jq/git/trees/6ab697a8dfb5a96e124666bf6d6213822599fb40&#34;
},
- "url": "https://api.github.com/repos/stedolan/jq/git/commits/d25341478381063d1c76e81b3a52e0592a7c997f",
- "comment_count": 0
+ &#34;url&#34;: &#34;https://api.github.com/repos/stedolan/jq/git/commits/d25341478381063d1c76e81b3a52e0592a7c997f&#34;,
+ &#34;comment_count&#34;: 0
},
- "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",
- "author": {
- "login": "stedolan",
- "id": 79765,
- "avatar_url": "https://avatars.githubusercontent.com/u/79765?v=3",
- "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",
- "type": "User",
- "site_admin": false
+ &#34;url&#34;: &#34;https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f&#34;,
+ &#34;html_url&#34;: &#34;https://github.com/stedolan/jq/commit/d25341478381063d1c76e81b3a52e0592a7c997f&#34;,
+ &#34;comments_url&#34;: &#34;https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f/comments&#34;,
+ &#34;author&#34;: {
+ &#34;login&#34;: &#34;stedolan&#34;,
+ &#34;id&#34;: 79765,
+ &#34;avatar_url&#34;: &#34;https://avatars.githubusercontent.com/u/79765?v=3&#34;,
+ &#34;gravatar_id&#34;: &#34;&#34;,
+ &#34;url&#34;: &#34;https://api.github.com/users/stedolan&#34;,
+ &#34;html_url&#34;: &#34;https://github.com/stedolan&#34;,
+ &#34;followers_url&#34;: &#34;https://api.github.com/users/stedolan/followers&#34;,
+ &#34;following_url&#34;: &#34;https://api.github.com/users/stedolan/following{/other_user}&#34;,
+ &#34;gists_url&#34;: &#34;https://api.github.com/users/stedolan/gists{/gist_id}&#34;,
+ &#34;starred_url&#34;: &#34;https://api.github.com/users/stedolan/starred{/owner}{/repo}&#34;,
+ &#34;subscriptions_url&#34;: &#34;https://api.github.com/users/stedolan/subscriptions&#34;,
+ &#34;organizations_url&#34;: &#34;https://api.github.com/users/stedolan/orgs&#34;,
+ &#34;repos_url&#34;: &#34;https://api.github.com/users/stedolan/repos&#34;,
+ &#34;events_url&#34;: &#34;https://api.github.com/users/stedolan/events{/privacy}&#34;,
+ &#34;received_events_url&#34;: &#34;https://api.github.com/users/stedolan/received_events&#34;,
+ &#34;type&#34;: &#34;User&#34;,
+ &#34;site_admin&#34;: false
},
- "committer": {
- "login": "stedolan",
- "id": 79765,
- "avatar_url": "https://avatars.githubusercontent.com/u/79765?v=3",
- "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",
- "type": "User",
- "site_admin": false
+ &#34;committer&#34;: {
+ &#34;login&#34;: &#34;stedolan&#34;,
+ &#34;id&#34;: 79765,
+ &#34;avatar_url&#34;: &#34;https://avatars.githubusercontent.com/u/79765?v=3&#34;,
+ &#34;gravatar_id&#34;: &#34;&#34;,
+ &#34;url&#34;: &#34;https://api.github.com/users/stedolan&#34;,
+ &#34;html_url&#34;: &#34;https://github.com/stedolan&#34;,
+ &#34;followers_url&#34;: &#34;https://api.github.com/users/stedolan/followers&#34;,
+ &#34;following_url&#34;: &#34;https://api.github.com/users/stedolan/following{/other_user}&#34;,
+ &#34;gists_url&#34;: &#34;https://api.github.com/users/stedolan/gists{/gist_id}&#34;,
+ &#34;starred_url&#34;: &#34;https://api.github.com/users/stedolan/starred{/owner}{/repo}&#34;,
+ &#34;subscriptions_url&#34;: &#34;https://api.github.com/users/stedolan/subscriptions&#34;,
+ &#34;organizations_url&#34;: &#34;https://api.github.com/users/stedolan/orgs&#34;,
+ &#34;repos_url&#34;: &#34;https://api.github.com/users/stedolan/repos&#34;,
+ &#34;events_url&#34;: &#34;https://api.github.com/users/stedolan/events{/privacy}&#34;,
+ &#34;received_events_url&#34;: &#34;https://api.github.com/users/stedolan/received_events&#34;,
+ &#34;type&#34;: &#34;User&#34;,
+ &#34;site_admin&#34;: false
},
- "parents": [
+ &#34;parents&#34;: [
{
- "sha": "54b9c9bdb225af5d886466d72f47eafc51acb4f7",
- "url": "https://api.github.com/repos/stedolan/jq/commits/54b9c9bdb225af5d886466d72f47eafc51acb4f7",
- "html_url": "https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7"
+ &#34;sha&#34;: &#34;54b9c9bdb225af5d886466d72f47eafc51acb4f7&#34;,
+ &#34;url&#34;: &#34;https://api.github.com/repos/stedolan/jq/commits/54b9c9bdb225af5d886466d72f47eafc51acb4f7&#34;,
+ &#34;html_url&#34;: &#34;https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7&#34;
},
{
- "sha": "8b1b503609c161fea4b003a7179b3fbb2dd4345a",
- "url": "https://api.github.com/repos/stedolan/jq/commits/8b1b503609c161fea4b003a7179b3fbb2dd4345a",
- "html_url": "https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a"
+ &#34;sha&#34;: &#34;8b1b503609c161fea4b003a7179b3fbb2dd4345a&#34;,
+ &#34;url&#34;: &#34;https://api.github.com/repos/stedolan/jq/commits/8b1b503609c161fea4b003a7179b3fbb2dd4345a&#34;,
+ &#34;html_url&#34;: &#34;https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a&#34;
}
]
}
@@ -262,11 +258,10 @@
-
-<p>For the rest of the examples, I’ll leave out the <code>curl</code> command - it’s not going to change.</p>
-
-<p>There’s a lot of info we don’t care about there, so we’ll restrict it down to the most interesting fields.</p>
-
+ <p>For the rest of the examples, I'll leave out the <code>curl</code> command - it's not
+going to change.</p>
+<p>There's a lot of info we don't care about there, so we'll restrict it down
+to the most interesting fields.</p>
@@ -277,13 +272,13 @@
<div class="tutorial-example">
<div class="accordion-heading">
- <pre>jq '.[0] | {message: .commit.message, name: .commit.committer.name}'</pre>
+ <pre>jq &#39;.[0] | {message: .commit.message, name: .commit.committer.name}&#39;</pre>
<a data-toggle="collapse" href="#result4">Show result</a>
</div>
<div id="result4" class="accordion-body collapse">
<pre>{
- "message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161",
- "name": "Stephen Dolan"
+ &#34;message&#34;: &#34;Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161&#34;,
+ &#34;name&#34;: &#34;Stephen Dolan&#34;
}
</pre>
</div>
@@ -291,11 +286,11 @@
-
-<p>The <code>|</code> operator in jq feeds the output of one filter (<code>.[0]</code> which gets the first element of the array in the response) into the input of another (<code>{...}</code> which builds an object out of those fields). You can access nested attributes, such as <code>.commit.message</code>.</p>
-
-<p>Now let’s get the rest of the commits.</p>
-
+ <p>The <code>|</code> operator in jq feeds the output of one filter (<code>.[0]</code> which gets
+the first element of the array in the response) into the input of another
+(<code>{...}</code> which builds an object out of those fields). You can access
+nested attributes, such as <code>.commit.message</code>.</p>
+<p>Now let's get the rest of the commits.</p>
@@ -306,29 +301,29 @@
<div class="tutorial-example">
<div class="accordion-heading">
- <pre>jq '.[] | {message: .commit.message, name: .commit.committer.name}'</pre>
+ <pre>jq &#39;.[] | {message: .commit.message, name: .commit.committer.name}&#39;</pre>
<a data-toggle="collapse" href="#result5">Show result</a>
</div>
<div id="result5" class="accordion-body collapse">
<pre>{
- "message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161",
- "name": "Stephen Dolan"
+ &#34;message&#34;: &#34;Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161&#34;,
+ &#34;name&#34;: &#34;Stephen Dolan&#34;
}
{
- "message": "Reject all overlong UTF8 sequences.",
- "name": "Stephen Dolan"
+ &#34;message&#34;: &#34;Reject all overlong UTF8 sequences.&#34;,
+ &#34;name&#34;: &#34;Stephen Dolan&#34;
}
{
- "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"
+ &#34;message&#34;: &#34;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.&#34;,
+ &#34;name&#34;: &#34;Stephen Dolan&#34;
}
{
- "message": "Fix example in manual for `floor`. See #155.",
- "name": "Stephen Dolan"
+ &#34;message&#34;: &#34;Fix example in manual for `floor`. See #155.&#34;,
+ &#34;name&#34;: &#34;Stephen Dolan&#34;
}
{
- "message": "Document floor",
- "name": "Nicolas Williams"
+ &#34;message&#34;: &#34;Document floor&#34;,
+ &#34;name&#34;: &#34;Nicolas Williams&#34;
}
</pre>
</div>
@@ -336,15 +331,18 @@
-
-<p><code>.[]</code> returns each element of the array returned in the response, one at a time, which are all fed into <code>{message: .commit.message, name: .commit.committer.name}</code>.</p>
-
-<p>Data in jq is represented as streams of JSON values - every jq expression runs for each value in its input stream, and can produce any number of values to its output stream.</p>
-
-<p>Streams are serialised by just separating JSON values with whitespace. This is a <code>cat</code>-friendly format - you can just join two JSON streams together and get a valid JSON stream.</p>
-
-<p>If you want to get the output as a single array, you can tell jq to “collect” all of the answers by wrapping the filter in square brackets:</p>
-
+ <p><code>.[]</code> returns each element of the array returned in the response, one at a
+time, which are all fed into
+<code>{message: .commit.message, name: .commit.committer.name}</code>.</p>
+<p>Data in jq is represented as streams of JSON values - every jq
+expression runs for each value in its input stream, and can
+produce any number of values to its output stream.</p>
+<p>Streams are serialised by just separating JSON values with
+whitespace. This is a <code>cat</code>-friendly format - you can just join
+two JSON streams together and get a valid JSON stream.</p>
+<p>If you want to get the output as a single array, you can tell jq to
+"collect" all of the answers by wrapping the filter in square
+brackets:</p>
@@ -355,30 +353,30 @@
<div class="tutorial-example">
<div class="accordion-heading">
- <pre>jq '[.[] | {message: .commit.message, name: .commit.committer.name}]'</pre>
+ <pre>jq &#39;[.[] | {message: .commit.message, name: .commit.committer.name}]&#39;</pre>
<a data-toggle="collapse" href="#result6">Show result</a>
</div>
<div id="result6" class="accordion-body collapse">
<pre>[
{
- "message": "Merge pull request #163 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161",
- "name": "Stephen Dolan"
+ &#34;message&#34;: &#34;Merge pull request #163 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161&#34;,
+ &#34;name&#34;: &#34;Stephen Dolan&#34;
},
{
- "message": "Reject all overlong UTF8 sequences.",
- "name": "Stephen Dolan"
+ &#34;message&#34;: &#34;Reject all overlong UTF8 sequences.&#34;,
+ &#34;name&#34;: &#34;Stephen Dolan&#34;
},
{
- "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"
+ &#34;message&#34;: &#34;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.&#34;,
+ &#34;name&#34;: &#34;Stephen Dolan&#34;
},
{
- "message": "Fix example in manual for `floor`. See #155.",
- "name": "Stephen Dolan"
+ &#34;message&#34;: &#34;Fix example in manual for `floor`. See #155.&#34;,
+ &#34;name&#34;: &#34;Stephen Dolan&#34;
},
{
- "message": "Document floor",
- "name": "Nicolas Williams"
+ &#34;message&#34;: &#34;Document floor&#34;,
+ &#34;name&#34;: &#34;Nicolas Williams&#34;
}
]
</pre>
@@ -388,23 +386,25 @@
<hr />
-<p>Next, let’s try getting the URLs of the parent commits out of the API results as well. In each commit, the GitHub API includes information about “parent” commits. There can be one or many.</p>
-
-<pre><code>&quot;parents&quot;: [
+<p>Next, let's try getting the URLs of the parent commits out of the
+API results as well. In each commit, the GitHub API includes information
+about "parent" commits. There can be one or many.</p>
+<pre><code>"parents": [
{
- &quot;sha&quot;: &quot;54b9c9bdb225af5d886466d72f47eafc51acb4f7&quot;,
- &quot;url&quot;: &quot;https://api.github.com/repos/stedolan/jq/commits/54b9c9bdb225af5d886466d72f47eafc51acb4f7&quot;,
- &quot;html_url&quot;: &quot;https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7&quot;
+ "sha": "54b9c9bdb225af5d886466d72f47eafc51acb4f7",
+ "url": "https://api.github.com/repos/stedolan/jq/commits/54b9c9bdb225af5d886466d72f47eafc51acb4f7",
+ "html_url": "https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7"
},
{
- &quot;sha&quot;: &quot;8b1b503609c161fea4b003a7179b3fbb2dd4345a&quot;,
- &quot;url&quot;: &quot;https://api.github.com/repos/stedolan/jq/commits/8b1b503609c161fea4b003a7179b3fbb2dd4345a&quot;,
- &quot;html_url&quot;: &quot;https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a&quot;
+ "sha": "8b1b503609c161fea4b003a7179b3fbb2dd4345a",
+ "url": "https://api.github.com/repos/stedolan/jq/commits/8b1b503609c161fea4b003a7179b3fbb2dd4345a",
+ "html_url": "https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a"
}
-]</code></pre>
-
-<p>We want to pull out all of the “html_url” fields inside that array of parent commits and make a simple list of strings to go along with the “message” and “author” fields we already have.</p>
-
+]
+</code></pre>
+<p>We want to pull out all of the "html_url" fields inside that array of parent
+commits and make a simple list of strings to go along with the
+"message" and "author" fields we already have.</p>
@@ -415,45 +415,45 @@
<div class="tutorial-example">
<div class="accordion-heading">
- <pre>jq '[.[] | {message: .commit.message, name: .commit.committer.name, parents: [.parents[].html_url]}]'</pre>
+ <pre>jq &#39;[.[] | {message: .commit.message, name: .commit.committer.name, parents: [.parents[].html_url]}]&#39;</pre>
<a data-toggle="collapse" href="#result7">Show result</a>
</div>
<div id="result7" class="accordion-body collapse">
<pre>[
{
- "message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161",
- "name": "Stephen Dolan",
- "parents": [
- "https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7",
- "https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a"
+ &#34;message&#34;: &#34;Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161&#34;,
+ &#34;name&#34;: &#34;Stephen Dolan&#34;,
+ &#34;parents&#34;: [
+ &#34;https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7&#34;,
+ &#34;https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a&#34;
]
},
{
- "message": "Reject all overlong UTF8 sequences.",
- "name": "Stephen Dolan",
- "parents": [
- "https://github.com/stedolan/jq/commit/ff48bd6ec538b01d1057be8e93b94eef6914e9ef"
+ &#34;message&#34;: &#34;Reject all overlong UTF8 sequences.&#34;,
+ &#34;name&#34;: &#34;Stephen Dolan&#34;,
+ &#34;parents&#34;: [
+ &#34;https://github.com/stedolan/jq/commit/ff48bd6ec538b01d1057be8e93b94eef6914e9ef&#34;
]
},
{
- "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",
- "parents": [
- "https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7"
+ &#34;message&#34;: &#34;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.&#34;,
+ &#34;name&#34;: &#34;Stephen Dolan&#34;,
+ &#34;parents&#34;: [
+ &#34;https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7&#34;
]
},
{
- "message": "Fix example in manual for `floor`. See #155.",
- "name": "Stephen Dolan",
- "parents": [
- "https://github.com/stedolan/jq/commit/3dcdc582ea993afea3f5503a78a77675967ecdfa"
+ &#34;message&#34;: &#34;Fix example in manual for `floor`. See #155.&#34;,
+ &#34;name&#34;: &#34;Stephen Dolan&#34;,
+ &#34;parents&#34;: [
+ &#34;https://github.com/stedolan/jq/commit/3dcdc582ea993afea3f5503a78a77675967ecdfa&#34;
]
},
{
- "message": "Document floor",
- "name": "Nicolas Williams",
- "parents": [
- "https://github.com/stedolan/jq/commit/7c4171d414f647ab08bcd20c76a4d8ed68d9c602"
+ &#34;message&#34;: &#34;Document floor&#34;,
+ &#34;name&#34;: &#34;Nicolas Williams&#34;,
+ &#34;parents&#34;: [
+ &#34;https://github.com/stedolan/jq/commit/7c4171d414f647ab08bcd20c76a4d8ed68d9c602&#34;
]
}
]
@@ -463,17 +463,18 @@
-
-<p>Here we’re making an object as before, but this time the <code>parents</code> field is being set to <code>[.parents[].html_url]</code>, which collects all of the parent commit URLs defined in the parents object.</p>
-
+ <p>Here we're making an object as before, but this time the <code>parents</code>
+field is being set to <code>[.parents[].html_url]</code>, which collects
+all of the parent commit URLs defined in the parents object.</p>
<hr />
-<p>Here endeth the tutorial! There’s lots more to play with. Go read <a href="../manual/">the manual</a> if you’re interested, and <a href="../download/">download jq</a> if you haven’t already.</p>
-
+<p>Here endeth the tutorial! There's lots more to play with. Go
+read <a href="../manual/">the manual</a> if you're interested, and <a href="../download/">download
+jq</a> if you haven't already.</p>
@@ -483,7 +484,7 @@
<footer>
<div class="container">
- <p>This website is made with <a href="http://www.tinytree.info">Bonsai</a> and <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
+ <p>This website is made with <a href="http://getbootstrap.com">Bootstrap</a>, themed with <a href="https://bootswatch.com">Bootswatch</a>.</p>
<p>jq is licensed under the MIT license (code) and the <a href="https://creativecommons.org/licenses/by/3.0/">CC-BY-3.0</a> license (docs).</p>
</div>
</footer>
@@ -491,6 +492,5 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<script src="https://twitter.github.io/typeahead.js/releases/0.11.1/typeahead.bundle.js"></script>
-
</body>
-</html>
+</html> \ No newline at end of file