Compare commits
174
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7099becbe8 | ||
|
|
96815fe168 | ||
|
|
dc679081fa | ||
|
|
597c1f6667 | ||
|
|
125071cf00 | ||
|
|
2fb099e4cf | ||
|
|
6f9646a44f | ||
|
|
bd7b48c1b9 | ||
|
|
aac8132f47 | ||
|
|
7bdf3a39ad | ||
|
|
396543191c | ||
|
|
e24af3c78e | ||
|
|
e82147bbb8 | ||
|
|
d2c3cf49e1 | ||
|
|
e84d17196c | ||
|
|
fd4ae8304e | ||
|
|
83e2cf607f | ||
|
|
61b75639a7 | ||
|
|
19d266b528 | ||
|
|
9c4238c2f6 | ||
|
|
114ac72169 | ||
|
|
a10d7fbb02 | ||
|
|
f33af0b16a | ||
|
|
eeba7b3167 | ||
|
|
e5c30e6fae | ||
|
|
0b8218515e | ||
|
|
1a8a5ee000 | ||
|
|
1740fd036d | ||
|
|
6c635998f8 | ||
|
|
7835a724d6 | ||
|
|
239c357af0 | ||
|
|
d228490162 | ||
|
|
b92a12cf6c | ||
|
|
c514368f98 | ||
|
|
062f86a625 | ||
|
|
c3d13260a7 | ||
|
|
e6e07cd2c6 | ||
|
|
ec4dfd32cc | ||
|
|
c0e01452f2 | ||
|
|
45260890f2 | ||
|
|
4337fc5fe0 | ||
|
|
093d20c3b9 | ||
|
|
ec07936888 | ||
|
|
8e4724e16c | ||
|
|
3afdbb7b7d | ||
|
|
f217fa26ae | ||
|
|
8f6f28c8d3 | ||
|
|
856a4b2f3f | ||
|
|
6d76cd0a99 | ||
|
|
6151f20477 | ||
|
|
ad8d1a8cc8 | ||
|
|
ec583deefa | ||
|
|
5fe053671a | ||
|
|
0d177d240d | ||
|
|
18b4b18b41 | ||
|
|
befd192958 | ||
|
|
79f9ecd150 | ||
|
|
8f115e9eed | ||
|
|
e17ccf2297 | ||
|
|
8eb1367ca4 | ||
|
|
2f79004f85 | ||
|
|
b7a219a91d | ||
|
|
aa279ae7ac | ||
|
|
4060535f9f | ||
|
|
1847333342 | ||
|
|
87c278c8a5 | ||
|
|
143e8dc5e4 | ||
|
|
b80d58e167 | ||
|
|
6c31850e86 | ||
|
|
c8dc164566 | ||
|
|
32e5e6af4b | ||
|
|
4a886f831c | ||
|
|
e3c36777ab | ||
|
|
c2395f0278 | ||
|
|
0791261f07 | ||
|
|
73b8413d10 | ||
|
|
664b8e26f0 | ||
|
|
64ade137bc | ||
|
|
da15e10bd0 | ||
|
|
1f7c24fea7 | ||
|
|
49b8382c5f | ||
|
|
583ab589dc | ||
|
|
c80c07ab68 | ||
|
|
c5875504da | ||
|
|
05d1c09cc1 | ||
|
|
9d6e91ea7b | ||
|
|
4887cfd951 | ||
|
|
9a51696bc0 | ||
|
|
bf271b8062 | ||
|
|
2864fb467e | ||
|
|
4490d9d1f6 | ||
|
|
c4524da3e0 | ||
|
|
58f082d74f | ||
|
|
154d0ee4a8 | ||
|
|
83ab4e273b | ||
|
|
dccda74062 | ||
|
|
b52bebfbe8 | ||
|
|
1758c1ba74 | ||
|
|
83e8ec587f | ||
|
|
63dd033da7 | ||
|
|
91f0dcff5c | ||
|
|
688bb1993f | ||
|
|
94bda489ce | ||
|
|
c9003e521c | ||
|
|
8105255be2 | ||
|
|
f57743eb37 | ||
|
|
0c93eb3379 | ||
|
|
891f28ef5e | ||
|
|
371e74a25f | ||
|
|
9ec27fe362 | ||
|
|
75662a4b05 | ||
|
|
4a993dff29 | ||
|
|
516e79151f | ||
|
|
6c3934de15 | ||
|
|
370833d555 | ||
|
|
302ae77712 | ||
|
|
5d23c240b6 | ||
|
|
7032228879 | ||
|
|
8932cf719f | ||
|
|
7668a4f255 | ||
|
|
2c6c521799 | ||
|
|
19577fcefa | ||
|
|
b8f71d3659 | ||
|
|
2d05b5475c | ||
|
|
44a5c4b0b1 | ||
|
|
a12b9102c7 | ||
|
|
b5f8cb2126 | ||
|
|
31be4a0495 | ||
|
|
e785a17a5f | ||
|
|
b6e3657eda | ||
|
|
ec7c3cf9a7 | ||
|
|
eb2fc1d27e | ||
|
|
73b9e8dc99 | ||
|
|
490a843947 | ||
|
|
6fa1300d39 | ||
|
|
ef0fb50c1c | ||
|
|
3608341c53 | ||
|
|
461f04bd4d | ||
|
|
161a6fa635 | ||
|
|
6d2f917a3a | ||
|
|
8f55d6d4ab | ||
|
|
2306795864 | ||
|
|
e0eb03b96d | ||
|
|
b1083ab367 | ||
|
|
e3e7cea177 | ||
|
|
d36a85a369 | ||
|
|
bd46a5dd52 | ||
|
|
7f87785002 | ||
|
|
0f419563ea | ||
|
|
aff6f49990 | ||
|
|
58a053d7de | ||
|
|
7b5c6a9224 | ||
|
|
5479d7f2dc | ||
|
|
a5b2c55a70 | ||
|
|
b119853aef | ||
|
|
5d08d54636 | ||
|
|
10df52efed | ||
|
|
68f84659f3 | ||
|
|
3ef92863f2 | ||
|
|
dea7868f01 | ||
|
|
16d0e528aa | ||
|
|
c426d494f0 | ||
|
|
9a3f802d20 | ||
|
|
89897b4bcd | ||
|
|
f1d1fea467 | ||
|
|
e404a1a96d | ||
|
|
b23d07875e | ||
|
|
9a68905228 | ||
|
|
486c275885 | ||
|
|
a864e848b5 | ||
|
|
a4dc312eff | ||
|
|
765f9ac74c | ||
|
|
3fae608b65 | ||
|
|
a47b32999b |
No files matched your search
+6
-2
@@ -5,6 +5,9 @@
|
||||
*.lai
|
||||
*.so
|
||||
*.so.*
|
||||
*.gcda
|
||||
*.gcno
|
||||
*.gcov
|
||||
*~
|
||||
.*.sw[a-p]
|
||||
tags
|
||||
@@ -13,12 +16,13 @@ jq
|
||||
!tests/modules/lib/jq/
|
||||
jq.1
|
||||
|
||||
# Something delightfully recursive happens otherwise
|
||||
docs/content/2.download/source/*
|
||||
# Generated source
|
||||
src/builtin.inc
|
||||
|
||||
# Autotools junk
|
||||
.libs
|
||||
.deps
|
||||
.dirstamp
|
||||
libtool
|
||||
*.log
|
||||
stamp-h1
|
||||
|
||||
+31
-9
@@ -1,3 +1,7 @@
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
sudo: false
|
||||
|
||||
language: c
|
||||
@@ -10,39 +14,56 @@ matrix:
|
||||
include:
|
||||
- compiler: gcc
|
||||
env: COVERAGE="--disable-valgrind --enable-gcov"
|
||||
os: linux
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libonig-dev
|
||||
- valgrind
|
||||
- bison
|
||||
|
||||
before_install:
|
||||
- rm lexer.h lexer.c parser.h parser.c
|
||||
- echo "$TRAVIS_OS_NAME"
|
||||
- uname -s
|
||||
- brew update || true;
|
||||
brew install flex || true;
|
||||
brew install bison || true;
|
||||
brew install oniguruma || true;
|
||||
- rm src/{lexer,parser}.{c,h}
|
||||
|
||||
install:
|
||||
- bundle install --gemfile=docs/Gemfile
|
||||
|
||||
- wget http://ftp.debian.org/debian/pool/main/b/bison/bison_3.0.2.dfsg-2_amd64.deb
|
||||
- ar p bison_3.0.2.dfsg-2_amd64.deb data.tar.xz | tar xJ
|
||||
|
||||
- if [ -n "$COVERAGE" ]; then pip install --user cpp-coveralls; fi
|
||||
|
||||
before_script:
|
||||
# If this is OS X we'll get bison from brew, else we'll get bison
|
||||
# from the .deb unpacked above in the install section.
|
||||
- PATH=/usr/local/opt/bison/bin:$PWD/usr/bin:$PATH
|
||||
- echo SHELL=$SHELL
|
||||
- echo PATH=$PATH
|
||||
- which bison
|
||||
- bison --version
|
||||
- autoreconf -i
|
||||
- ./configure
|
||||
YACC="usr/bin/bison -y"
|
||||
$COVERAGE
|
||||
- ./configure YACC="$(which bison) -y" $COVERAGE
|
||||
|
||||
script:
|
||||
- make -j4 BISON_PKGDATADIR=$(pwd)/usr/share/bison
|
||||
# When using the bison from Debian we need to tell that bison where
|
||||
# to find its data. Yay non-relocatable code. Not.
|
||||
- echo PATH=$PATH
|
||||
- which bison
|
||||
- make BISON_PKGDATADIR=$PWD/usr/share/bison src/parser.c || make src/parser.c
|
||||
- make -j4
|
||||
- make check -j4
|
||||
|
||||
after_script:
|
||||
- |
|
||||
if [ -n "$COVERAGE" ]; then
|
||||
rm -rf .libs usr # don't care about coverage for libjq and bison
|
||||
coveralls -e lexer.c -e parser.c -e jv_dtoa.c --gcov-options '\-lp'
|
||||
rm -rf src/.libs # don't care about coverage for libjq
|
||||
coveralls --gcov-options '\-lp' \
|
||||
-e src/lexer.c -e src/parser.c -e src/jv_dtoa.c
|
||||
fi
|
||||
|
||||
after_failure:
|
||||
@@ -51,3 +72,4 @@ after_failure:
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
@@ -4,62 +4,59 @@ Stephen Dolan <mu@netsoc.tcd.ie>
|
||||
Maintained by:
|
||||
Nicolas Williams <nico@cryptonector.com>
|
||||
William Langford <wlangfor@gmail.com>
|
||||
David Tolnay <dtolnay@gmail.com>
|
||||
|
||||
Contributions by:
|
||||
Andrew Rodland <andrew@cleverdomain.org> - bug fixes
|
||||
Ankur <ankz.kothari@gmail.com> - bug fixes
|
||||
Anthony Shortland <anthony.shortland@me.com> - rpmbuild target
|
||||
Brendan Macmillan <melbourne.research@gmail.com> - bug fixes, load library from ~/.jq
|
||||
David R. MacIver <david@drmaciver.com> - bug fixes
|
||||
David Tolnay <dtolnay@gmail.com> - destructuring, build improvements
|
||||
Filippo Giunchedi <fgiunchedi@gmail.com> - bug fixes
|
||||
Filippo Valsorda <filippo.valsorda@gmail.com> - recursive object merge (`*`)
|
||||
Jack Pearkes <jackpearkes@gmail.com> - update tutorial
|
||||
Jingwen Owen Ou <jingweno@gmail.com> - jqplay.org and link to it
|
||||
Joe Littlejohn <joe.littlejohn@nokia.com> - bug fixes
|
||||
Juan Guerrero <juan.guerrero.lozano@gmail.com> - bug fixes
|
||||
Kenny Shen <kenny.shen@zalora.com> - doc fixes
|
||||
Lee Thompson <stagr.lee@gmail.com> - autoconf stuff
|
||||
Markus Lanthaler <mark_lanthaler@gmx.net> - doc fixes
|
||||
Michael Daines <michael@mdaines.com> - add sqrt; doc fixes
|
||||
Mike McCabe <mccabe@archive.org> - math (libm) functions
|
||||
Nicolas Pouillard <nicolas.pouillard@gmail.com> - add tests
|
||||
Nicolas Williams <nico@cryptonector.com> - library-fication, autoconf stuff, exception handling, various
|
||||
Peter van Dijk <peter@7bits.nl> - doc fixes
|
||||
Philipp Hagemeister <phihag@phihag.de> - doc fixes
|
||||
polyester <paul@cleanclothes.org> - automake version update
|
||||
Rémy Léone <remy.leone@gmail.com> - add .travis.yml
|
||||
Ryoichi KATO <ryo1kato@gmail.com> - doc fixes
|
||||
Santiago Lapresta <santiago.lapresta@gmail.com> - join, arrays, all, any, other filters
|
||||
pkoppstein <pkoppstein@gmail.com> - various builtins, improvements
|
||||
13ren <melbourne.research@gmail.com>
|
||||
Aaron Peschel <apeschel@zendesk.com>
|
||||
Adam Lindberg <hello@alind.io>
|
||||
Alex Chamberlain <alex@alexchamberlain.co.uk>
|
||||
Andrew O'Brien <obrien.andrew@gmail.com> - docs build
|
||||
Andrew Rodland <andrew@cleverdomain.org> - bug fixes
|
||||
Ankur <ankz.kothari@gmail.com> - bug fixes
|
||||
Anthony Shortland <anthony.shortland@me.com> - rpmbuild target
|
||||
Assaf Gordon <assafgordon@gmail.com> - error handling
|
||||
Brendan Macmillan <melbourne.research@gmail.com> - bug fixes, load library from ~/.jq
|
||||
cdnbacon <mike@busbud.com>
|
||||
Charles Merriam <charles.merriam@gmail.com>
|
||||
Colin von Heuring <colin@janrain.com>
|
||||
Damian Gryski <damian@gryski.com>
|
||||
David Haguenauer <ml@kurokatta.org>
|
||||
David R. MacIver <david@drmaciver.com> - bug fixes
|
||||
David Tolnay <dtolnay@gmail.com> - destructuring, build improvements
|
||||
Doug Luce <doug@github.con.com> - build
|
||||
Eiichi Sato <sato.eiichi@gmail.com>
|
||||
Filippo Giunchedi <fgiunchedi@gmail.com> - bug fixes
|
||||
Filippo Valsorda <filippo.valsorda@gmail.com> - recursive object merge (`*`)
|
||||
Hanfei Shen <qqshfox@gmail.com>
|
||||
Ian Miell <ian.miell@gmail.com>
|
||||
i <isomorphisms@sdf.org>
|
||||
Ian Miell <ian.miell@gmail.com>
|
||||
Jack Pearkes <jackpearkes@gmail.com> - update tutorial
|
||||
James Andariese <james.andariese@locationlabs.com> - Dockerfile
|
||||
Jingwen Owen Ou <jingweno@gmail.com> - jqplay.org and link to it
|
||||
jkleint <jkleint@gmail.com>
|
||||
Joe Littlejohn <joe.littlejohn@nokia.com> - bug fixes
|
||||
Joel Purra <code+github@joelpurra.com>
|
||||
Juan Guerrero <juan.guerrero.lozano@gmail.com> - bug fixes
|
||||
Kenny Shen <kenny.shen@zalora.com> - doc fixes
|
||||
Kim De Mey <kim.demey@gmail.com> - build
|
||||
Kim Toms <kim.toms@bplglobal.net>
|
||||
LCD 47 <lcd047@gmail.com>
|
||||
Lee Thompson <thompson@dtosolutions.com> - rpm
|
||||
Lee Thompson <stagr.lee@gmail.com> - autoconf stuff, rpm
|
||||
Marc Abramowitz <marc@marc-abramowitz.com>
|
||||
Marc Bruggmann <marcbr@spotify.com>
|
||||
Markus Lanthaler <mark_lanthaler@gmx.net> - doc fixes
|
||||
Maxime Biais <maxime.biais@gmail.com> - build
|
||||
Michael Daines <michael@mdaines.com> - add sqrt; doc fixes
|
||||
Mike Fletcher <john.m.fletcher@bankofamerica.com>
|
||||
Mike McCabe <mccabe@archive.org> - math (libm) functions
|
||||
Nicolas Pouillard <nicolas.pouillard@gmail.com> - add tests
|
||||
Nicolas Williams <nico@cryptonector.com> - library-fication, autoconf stuff, exception handling, various
|
||||
Peter van Dijk <peter@7bits.nl> - doc fixes
|
||||
Philipp Hagemeister <phihag@phihag.de> - doc fixes
|
||||
pkoppstein <pkoppstein@gmail.com> - various builtins, improvements
|
||||
polyester <paul@cleanclothes.org> - automake version update
|
||||
Ryoichi KATO <ryo1kato@gmail.com> - doc fixes
|
||||
Rémy Léone <remy.leone@gmail.com> - add .travis.yml
|
||||
Santiago Lapresta <santiago.lapresta@gmail.com> - join, arrays, all, any, other filters
|
||||
Sebastian Freundt <freundt@ga-group.nl> - build
|
||||
Shay Elkin <shay@everything.me>
|
||||
Simon Elsbrock <simon@iodev.org> - Debian
|
||||
@@ -71,3 +68,4 @@ Steven Penny <svnpenn@gmail.com> - Windows bug fixes
|
||||
tal@whatexit.org <tal@whatexit.org>
|
||||
Travis Gockel <travis@gockelhut.com>
|
||||
Zhiming Wang <zmwangx@gmail.com>
|
||||
13ren <melbourne.research@gmail.com>
|
||||
@@ -25,14 +25,14 @@ jq's documentation (everything found under the docs/ subdirectory in
|
||||
the source tree) is licensed under the Creative Commons CC BY 3.0
|
||||
license, which can be found at:
|
||||
|
||||
http://creativecommons.org/licenses/by/3.0/
|
||||
https://creativecommons.org/licenses/by/3.0/
|
||||
|
||||
The documentation website includes a copy of Twitter's Boostrap and
|
||||
relies on Bonsai, Liquid templates and various other projects, look
|
||||
them up for detailed licensing conditions.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
jq incorporates David M. Gay's dtoa.c and g_fmt.c, which bear the
|
||||
following notices:
|
||||
|
||||
|
||||
+28
-25
@@ -8,43 +8,46 @@ COPY . /app
|
||||
RUN apt-get update && \
|
||||
apt-get install -y \
|
||||
build-essential \
|
||||
autoconf \
|
||||
libtool \
|
||||
git \
|
||||
bison \
|
||||
flex \
|
||||
ruby \
|
||||
wget \
|
||||
ruby-dev && \
|
||||
wget http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.6.tar.gz && \
|
||||
sha512sum onig-5.9.6.tar.gz | grep 4a181ea6f0e1a018bbaf6c87e666dfffd1ef4b8f5dcead07fa0b6564a76174e7e01854173924668433ae74c455dbced6a0e1b43e9066f0499b4a57e855e1a2b2 && \
|
||||
autoconf \
|
||||
libtool \
|
||||
git \
|
||||
bison \
|
||||
flex \
|
||||
ruby \
|
||||
wget \
|
||||
ruby-dev && \
|
||||
wget https://github.com/kkos/oniguruma/archive/v5.9.6.tar.gz -O onig-5.9.6.tar.gz && \
|
||||
sha512sum onig-5.9.6.tar.gz | grep 6b048d345e148c9da38af7a8df76d4a358eb3d4db91fa7834076e511f526a63544284f212b0d56badbbd33112c8b458a5fff02bfbbda012ecfe478bc436ea679 && \
|
||||
tar zxvf onig-5.9.6.tar.gz && \
|
||||
(cd onig-5.9.6 && \
|
||||
(cd oniguruma-5.9.6 && \
|
||||
touch NEWS ChangeLog && \
|
||||
autoreconf -i && \
|
||||
./configure --prefix=/usr/local && \
|
||||
make && \
|
||||
make install ) && \
|
||||
make install ) && \
|
||||
gem install bundler && \
|
||||
(cd /app/docs && bundle install) && \
|
||||
(cd /app && \
|
||||
autoreconf -i && \
|
||||
./configure --disable-valgrind --enable-all-static --prefix=/usr/local && \
|
||||
make -j8 && \
|
||||
make check && \
|
||||
make install && \
|
||||
make distclean ) && \
|
||||
(cd onig-5.9.6 && \
|
||||
make -j8 && \
|
||||
make check && \
|
||||
make install && \
|
||||
make distclean ) && \
|
||||
(cd oniguruma-5.9.6 && \
|
||||
make uninstall ) && \
|
||||
apt-get purge -y \
|
||||
build-essential \
|
||||
autoconf \
|
||||
libtool \
|
||||
bison \
|
||||
git \
|
||||
flex \
|
||||
ruby \
|
||||
ruby-dev && \
|
||||
autoconf \
|
||||
libtool \
|
||||
bison \
|
||||
git \
|
||||
flex \
|
||||
ruby \
|
||||
ruby-dev && \
|
||||
apt-get autoremove -y && \
|
||||
rm -rf onig-5.9.6 && \
|
||||
rm -rf oniguruma-5.9.6 && \
|
||||
rm -rf /var/lib/apt/lists/* /var/lib/gems
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/jq"]
|
||||
CMD []
|
||||
@@ -0,0 +1,8 @@
|
||||
pub 4096R/71523402 2015-10-11
|
||||
Key fingerprint = 4FD7 01D6 FA9B 3D2D F5AC 935D AF19 040C 7152 3402
|
||||
uid jq Release Signing Key <jq@stedolan.github.io>
|
||||
|
||||
pub 2048R/D15684DB 2015-10-12 [expires: 2017-10-11]
|
||||
Key fingerprint = 7F6C 7BD3 0412 AFD5 8C1A 5007 EB26 A4F8 D156 84DB
|
||||
uid Nicolas Williams <nico@cryptonector.com>
|
||||
sub 2048R/9C9CCD6A 2015-10-12 [expires: 2017-10-11]
|
||||
+62
-65
@@ -1,18 +1,22 @@
|
||||
|
||||
### C source files to be built and distributed.
|
||||
|
||||
LIBJQ_INCS = jq_parser.h builtin.h bytecode.h compile.h exec_stack.h \
|
||||
libm.h jv_alloc.h jv_dtoa.h jv_unicode.h locfile.h \
|
||||
opcode_list.h parser.y jv_utf8_tables.h lexer.l util.h linker.h
|
||||
LIBJQ_INCS = src/builtin.h src/bytecode.h src/compile.h \
|
||||
src/exec_stack.h src/jq_parser.h src/jv_alloc.h src/jv_dtoa.h \
|
||||
src/jv_unicode.h src/jv_utf8_tables.h src/lexer.l src/libm.h \
|
||||
src/linker.h src/locfile.h src/opcode_list.h src/parser.y \
|
||||
src/util.h
|
||||
|
||||
LIBJQ_SRC = locfile.c bytecode.c compile.c execute.c builtin.c jv.c \
|
||||
jv_parse.c jv_print.c jv_dtoa.c jv_unicode.c jv_aux.c jv_file.c \
|
||||
jv_alloc.c jq_test.c util.c linker.c ${LIBJQ_INCS}
|
||||
LIBJQ_SRC = src/builtin.c src/bytecode.c src/compile.c src/execute.c \
|
||||
src/jq_test.c src/jv.c src/jv_alloc.c src/jv_aux.c \
|
||||
src/jv_dtoa.c src/jv_file.c src/jv_parse.c src/jv_print.c \
|
||||
src/jv_unicode.c src/linker.c src/locfile.c src/util.c \
|
||||
${LIBJQ_INCS}
|
||||
|
||||
### C build options
|
||||
|
||||
AM_CFLAGS = -Wextra -Wall -Wno-missing-field-initializers \
|
||||
-Wno-unused-parameter -Wno-unused-function
|
||||
AM_CFLAGS = -Wextra -Wall -Wno-missing-field-initializers \
|
||||
-Wno-unused-parameter -Wno-unused-function
|
||||
|
||||
ACLOCAL_AMFLAGS = -I config/m4
|
||||
|
||||
@@ -21,12 +25,13 @@ ACLOCAL_AMFLAGS = -I config/m4
|
||||
# While there is some autoconf macro support for lex/flex, it doesn't support
|
||||
# header file creation so we'll use good old make
|
||||
if MAINTAINER_MODE
|
||||
BUILT_SOURCES = lexer.h lexer.c parser.h parser.c version.h
|
||||
lexer.c: lexer.l
|
||||
$(AM_V_LEX) flex -o lexer.c --header-file=lexer.h $<
|
||||
lexer.h: lexer.c
|
||||
BUILT_SOURCES = src/lexer.h src/lexer.c src/parser.h src/parser.c \
|
||||
src/builtin.inc src/version.h
|
||||
src/lexer.c: src/lexer.l
|
||||
$(AM_V_LEX) flex -o src/lexer.c --header-file=src/lexer.h $<
|
||||
src/lexer.h: src/lexer.c
|
||||
else
|
||||
BUILT_SOURCES =
|
||||
BUILT_SOURCES = src/builtin.inc src/version.h
|
||||
.y.c:
|
||||
$(AM_V_YACC) echo "NOT building parser.c!"
|
||||
.l.c:
|
||||
@@ -45,15 +50,28 @@ libjq_la_SOURCES = ${LIBJQ_SRC}
|
||||
libjq_la_LIBADD = -lm
|
||||
libjq_la_LDFLAGS = -export-symbols-regex '^j[qv]_' -version-info 1:4:0
|
||||
|
||||
include_HEADERS = jv.h jq.h
|
||||
if WIN32
|
||||
libjq_la_LIBADD += -lshlwapi
|
||||
endif
|
||||
|
||||
include_HEADERS = src/jv.h src/jq.h
|
||||
|
||||
if ENABLE_UBSAN
|
||||
AM_CFLAGS += -fsanitize=undefined
|
||||
endif
|
||||
|
||||
### Running tests under Valgrind
|
||||
|
||||
if ENABLE_ASAN
|
||||
AM_CFLAGS += -fsanitize=address
|
||||
NO_VALGRIND = 1
|
||||
else
|
||||
if ENABLE_VALGRIND
|
||||
NO_VALGRIND =
|
||||
else
|
||||
NO_VALGRIND = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
### Code coverage with gcov
|
||||
|
||||
@@ -65,7 +83,7 @@ endif
|
||||
|
||||
if ENABLE_ERROR_INJECTION
|
||||
lib_LTLIBRARIES += libinject_errors.la
|
||||
libinject_errors_la_SOURCES = inject_errors.c
|
||||
libinject_errors_la_SOURCES = src/inject_errors.c
|
||||
libinject_errors_la_LIBADD = -ldl
|
||||
libinject_errors_la_LDFLAGS = -module
|
||||
endif
|
||||
@@ -77,13 +95,17 @@ endif
|
||||
.FORCE:
|
||||
generate_ver = ver="`{ $(srcdir)/scripts/version || echo '$(VERSION)' ; } | sed 's/.*/\#define JQ_VERSION \"&\"/'`"
|
||||
.remake-version-h: .FORCE
|
||||
@ $(generate_ver); test "x`cat version.h 2>/dev/null`" = "x$$ver" || touch .remake-version-h
|
||||
version.h: .remake-version-h
|
||||
@ $(generate_ver); test "x`cat src/version.h 2>/dev/null`" = "x$$ver" || touch .remake-version-h
|
||||
src/version.h: .remake-version-h
|
||||
$(AM_V_GEN) $(generate_ver); echo "$$ver" > $@
|
||||
main.c: version.h
|
||||
src/main.c: src/version.h
|
||||
|
||||
src/builtin.inc: src/builtin.jq
|
||||
$(AM_V_GEN) sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' $^ > $@
|
||||
src/builtin.o: src/builtin.inc
|
||||
|
||||
bin_PROGRAMS = jq
|
||||
jq_SOURCES = main.c version.h
|
||||
jq_SOURCES = src/main.c src/version.h
|
||||
jq_LDFLAGS = -static-libtool-libs
|
||||
jq_LDADD = libjq.la -lm
|
||||
|
||||
@@ -93,39 +115,21 @@ endif
|
||||
|
||||
### Tests (make check)
|
||||
|
||||
TESTS = tests/mantest tests/jqtest tests/onigtest tests/shtest
|
||||
TESTS = tests/optionaltest tests/mantest tests/jqtest tests/onigtest tests/shtest tests/utf8test
|
||||
TESTS_ENVIRONMENT = NO_VALGRIND=$(NO_VALGRIND)
|
||||
|
||||
|
||||
### Building the manpage
|
||||
|
||||
# If ENABLE_DOCS is not set, just copy jq.1.default to jq.1
|
||||
# The real_docs target succeeds (possibly after building jq.1) only if ENABLE_DOCS is set
|
||||
# Thus, making "dist" depend on "real_docs" ensures that we never build a tarball with
|
||||
# a stub manpage.
|
||||
|
||||
man_MANS = jq.1
|
||||
.PHONY: real_docs
|
||||
if ENABLE_DOCS
|
||||
jq.1: $(srcdir)/docs/content/3.manual/manual.yml
|
||||
$(AM_V_GEN) ( cd ${abs_srcdir}/docs; '$(BUNDLER)' exec rake manpage ) > $@ || { rm -f $@; false; }
|
||||
jq.1.prebuilt: jq.1
|
||||
$(AM_V_GEN) cp $^ $@ || { rm -f $@; false; }
|
||||
jq.1.default: $(srcdir)/docs/default_manpage.md
|
||||
$(AM_V_GEN) ( cd ${abs_srcdir}/docs; '$(BUNDLER)' exec rake manpage_default ) > $@ || { rm -f $@; false; }
|
||||
real_docs: jq.1 jq.1.prebuilt
|
||||
@if cmp jq.1 $(srcdir)/jq.1.default > /dev/null; then\
|
||||
rm -f jq.1; $(MAKE) $(AM_MAKEFLAGS) jq.1;\
|
||||
fi
|
||||
else
|
||||
jq.1: $(srcdir)/jq.1.prebuilt
|
||||
$(AM_V_GEN) cp $^ $@
|
||||
real_docs:
|
||||
@echo "Ruby dependencies not found, cannot build manpage." > /dev/stderr
|
||||
@echo "Follow the instructions in docs/README.md to install them" > /dev/stderr
|
||||
@echo "and then rerun ./configure" > /dev/stderr
|
||||
@echo "A pre-built, possibly out-of-date manpage used." > /dev/stderr
|
||||
false
|
||||
endif
|
||||
|
||||
|
||||
@@ -138,33 +142,26 @@ docs/site.yml: configure.ac
|
||||
install-binaries: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-exec
|
||||
|
||||
# Ensure "make dist" fails when we can't build the real manpage
|
||||
dist-hook: real_docs
|
||||
DOC_FILES = docs/content docs/public docs/templates docs/site.yml \
|
||||
docs/Gemfile docs/Gemfile.lock docs/Rakefile docs/README.md \
|
||||
docs/default_manpage.md jq.1.default
|
||||
|
||||
DOC_FILES = docs/content docs/public docs/templates docs/site.yml \
|
||||
docs/Gemfile docs/Gemfile.lock docs/Rakefile docs/README.md \
|
||||
docs/default_manpage.md jq.1.default
|
||||
|
||||
# setup is only used by distribution developers, not package developers.
|
||||
# Still, as a matter of allowing patching, its not a bad idea to distribute
|
||||
# the developer setup script in the tarball.
|
||||
EXTRA_DIST = $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER) jq.spec \
|
||||
$(DOC_FILES) scripts/version parser.h parser.c lexer.h \
|
||||
lexer.c tests/onig.supp tests/torture/input0.json \
|
||||
tests/modules/.jq tests/modules/a.jq tests/modules/b/b.jq \
|
||||
tests/modules/c/c.jq tests/modules/c/d.jq \
|
||||
tests/modules/lib/jq/e/e.jq tests/modules/lib/jq/f.jq \
|
||||
tests/setup tests/jq.test tests/onig.test \
|
||||
tests/modules/data.json \
|
||||
tests/modules/syntaxerror/syntaxerror.jq \
|
||||
tests/modules/test_bind_order.jq \
|
||||
tests/modules/test_bind_order0.jq \
|
||||
tests/modules/test_bind_order1.jq \
|
||||
tests/modules/test_bind_order2.jq \
|
||||
jq.1.prebuilt
|
||||
EXTRA_DIST = $(DOC_FILES) $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER) \
|
||||
jq.1.prebuilt jq.spec src/lexer.c src/lexer.h src/parser.c \
|
||||
src/parser.h src/version.h src/builtin.inc \
|
||||
scripts/version tests/jq.test tests/modules/.jq \
|
||||
tests/modules/a.jq tests/modules/b/b.jq tests/modules/c/c.jq \
|
||||
tests/modules/c/d.jq tests/modules/data.json \
|
||||
tests/modules/lib/jq/e/e.jq tests/modules/lib/jq/f.jq \
|
||||
tests/modules/syntaxerror/syntaxerror.jq \
|
||||
tests/modules/test_bind_order.jq \
|
||||
tests/modules/test_bind_order0.jq \
|
||||
tests/modules/test_bind_order1.jq \
|
||||
tests/modules/test_bind_order2.jq tests/onig.supp \
|
||||
tests/onig.test tests/setup tests/torture/input0.json
|
||||
|
||||
|
||||
# README.md is expected in Github projects, good stuff in it, so we'll
|
||||
# README.md is expected in Github projects, good stuff in it, so we'll
|
||||
# distribute it and install it with the package in the doc directory.
|
||||
docdir = ${datadir}/doc/${PACKAGE}
|
||||
dist_doc_DATA = README.md COPYING AUTHORS README
|
||||
@@ -187,12 +184,12 @@ dist-clean-local:
|
||||
clean-local-docs:
|
||||
if ENABLE_DOCS
|
||||
rm -f jq.1
|
||||
endif
|
||||
endif
|
||||
|
||||
clean-local-gcov:
|
||||
rm -f *.gcno *.gcda *.gcov
|
||||
rm -f src/*.gcno src/*.gcda src/*.gcov
|
||||
|
||||
clean-local: clean-local-docs clean-local-gcov
|
||||
rm -f version.h .remake-version-h
|
||||
rm -f src/version.h .remake-version-h
|
||||
|
||||
.PHONY: clean-local-docs clean-local-gcov
|
||||
@@ -1,11 +1,12 @@
|
||||
|
||||
Release history
|
||||
|
||||
* jq version 1.0 was released on Sun Oct 21 2012
|
||||
* jq version 1.1 was released on Sun Oct 21 2012
|
||||
* jq version 1.2 was released on Thu Dec 20 2012
|
||||
* jq version 1.3 was released on Sun May 19 2013
|
||||
* jq version 1.5 was released on Sat Aug 15 2015
|
||||
* jq version 1.4 was released on Mon Jun 9 2014
|
||||
* jq version 1.3 was released on Sun May 19 2013
|
||||
* jq version 1.2 was released on Thu Dec 20 2012
|
||||
* jq version 1.1 was released on Sun Oct 21 2012
|
||||
* jq version 1.0 was released on Sun Oct 21 2012
|
||||
|
||||
New features in 1.5 since 1.4:
|
||||
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
jq
|
||||
==
|
||||
|
||||
jq is a command-line JSON processor.
|
||||
jq is a lightweight and flexible command-line JSON processor.
|
||||
|
||||
[](https://coveralls.io/github/stedolan/jq?branch=master),
|
||||
Unix: [](https://travis-ci.org/stedolan/jq),
|
||||
Windows: [](https://ci.appveyor.com/project/stedolan/jq)
|
||||
|
||||
|
||||
If you want to learn to use jq, read the documentation at
|
||||
[http://stedolan.github.io/jq](http://stedolan.github.io/jq). This
|
||||
[https://stedolan.github.io/jq](https://stedolan.github.io/jq). This
|
||||
documentation is generated from the docs/ folder of this repository.
|
||||
You can also try it online at [jqplay.org](http://jqplay.org).
|
||||
You can also try it online at [jqplay.org](https://jqplay.org).
|
||||
|
||||
If you want to hack on jq, feel free, but be warned that its internals
|
||||
are not well-documented at the moment. Bring a hard hat and a
|
||||
shovel. Also, read the wiki: http://github.com/stedolan/jq/wiki
|
||||
shovel. Also, read the wiki: https://github.com/stedolan/jq/wiki, where
|
||||
you will find cookbooks, discussion of advanced topics, internals,
|
||||
release engineering, and more.
|
||||
|
||||
Source tarball and built executable releases can be found on the
|
||||
homepage and on the github release page, https://github.com/stedolan/jq/releases
|
||||
@@ -61,4 +68,4 @@ Cross-compilation requires a clean workspace, then:
|
||||
Use the --host= and --target= ./configure options to select a
|
||||
cross-compilation environment. See also the wiki.
|
||||
|
||||
Send questions to http://stackoverflow.com/questions/tagged/jq or to the #jq channel (http://irc.lc/freenode/%23jq/) on Freenode (https://webchat.freenode.net/).
|
||||
Send questions to https://stackoverflow.com/questions/tagged/jq or to the #jq channel (http://irc.lc/freenode/%23jq/) on Freenode (https://webchat.freenode.net/).
|
||||
@@ -0,0 +1,49 @@
|
||||
environment:
|
||||
matrix:
|
||||
- MSYSTEM: MINGW64
|
||||
PATH: C:\msys64\usr\bin;C:\msys64\mingw64\bin;C:\Windows\System32;C:\Windows;%PATH%
|
||||
- MSYSTEM: MINGW32
|
||||
PATH: C:\msys64\usr\bin;C:\msys64\mingw32\bin;C:\Windows\System32;C:\Windows;%PATH%
|
||||
|
||||
|
||||
install:
|
||||
# update mysy2
|
||||
- C:\msys64\usr\bin\bash -lc "pacman --needed --noconfirm -Sy pacman-mirrors"
|
||||
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy"
|
||||
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S autoconf automake bison flex"
|
||||
- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-oniguruma mingw-w64-x86_64-oniguruma"
|
||||
|
||||
|
||||
build_script:
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && autoreconf -i"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && ./configure --disable-shared --enable-static --enable-all-static"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && make -j8"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && cat jq.1 | groff -mandoc -Thtml > jq.html"
|
||||
- 7z a jq-package.zip jq.1 jq.html jq.exe
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && pwd && ls -la"
|
||||
- file jq.exe
|
||||
|
||||
test_script:
|
||||
# tests/optionaltest and tests/shtest fail on Windows; run them
|
||||
# anyways but ignore their failures. Also, trace shtest.
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && make -j3 'TESTS=tests/mantest tests/jqtest tests/onigtest' check"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && make TESTS=tests/optionaltest check || cat test-suite.log"
|
||||
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && make TRACE_TESTS=1 TESTS=tests/shtest check || cat test-suite.log"
|
||||
|
||||
artifacts:
|
||||
- path: jq-package.zip
|
||||
name: jq-package
|
||||
|
||||
- path: jq.exe
|
||||
name: jq-exe
|
||||
|
||||
- path: test-suite.log
|
||||
name: logs
|
||||
|
||||
|
||||
on_failure:
|
||||
- cat test-suite.log
|
||||
- appveyor PushArtifact test-suite.log
|
||||
# also push the jq.exe so that someone can download it anyways...
|
||||
- appveyor PushArtifact jq-package.zip
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ NJOBS="-j`sysctl -n hw.ncpu || echo 1`"
|
||||
# Get oniguruma
|
||||
rm -rf $PWD/build/ios onig-5.9.5
|
||||
echo "Downloading oniguruma 5.9.5"
|
||||
curl http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.5.tar.gz | tar xz
|
||||
cd onig-5.9.5
|
||||
curl -L https://github.com/kkos/oniguruma/archive/v5.9.6.tar.gz | tar xz
|
||||
cd oniguruma-5.9.5
|
||||
|
||||
# So, we need to remake the configure scripts so that the arm64 architecture
|
||||
# exists in config.sub. In order to keep autoreconf from failing, create
|
||||
|
||||
+70
-29
@@ -1,7 +1,7 @@
|
||||
m4_define([jq_version], m4_esyscmd_s([git describe --tags --dirty --match 'jq-*'|sed 's/^jq-//']))
|
||||
|
||||
AC_INIT([jq], [jq_version], [https://github.com/stedolan/jq/issues],
|
||||
[jq], [http://stedolan.github.io/jq])
|
||||
[jq], [https://stedolan.github.io/jq])
|
||||
|
||||
m4_include([m4/ax_compare_version.m4])
|
||||
m4_include([m4/ax_prog_bison_version.m4])
|
||||
@@ -9,7 +9,7 @@ m4_include([m4/ax_prog_bison_version.m4])
|
||||
dnl Created autoconf implementation thompson@dtosolutions, 26NOV12
|
||||
AC_PREREQ([2.64])
|
||||
AC_CONFIG_AUX_DIR([config])
|
||||
AM_INIT_AUTOMAKE([1.11.2 parallel-tests foreign -Wall])
|
||||
AM_INIT_AUTOMAKE([1.11.2 subdir-objects parallel-tests foreign -Wall])
|
||||
AM_SILENT_RULES([yes])
|
||||
AM_PROG_AR
|
||||
AM_MAINTAINER_MODE([enable])
|
||||
@@ -52,27 +52,26 @@ fi
|
||||
AC_ARG_WITH([oniguruma],
|
||||
[AS_HELP_STRING([--with-oniguruma=prefix],
|
||||
[try this for a non-standard install prefix of the oniguruma library])],
|
||||
[ONIGURUMAPATHSET=1],
|
||||
[ONIGURUMAPATHSET=0])
|
||||
|
||||
if test $ONIGURUMAPATHSET = 1; then
|
||||
CFLAGS="$CFLAGS -I${with_oniguruma}/include"
|
||||
LDFLAGS="$LDFLAGS -L${with_oniguruma}/lib"
|
||||
fi
|
||||
|
||||
# check for ONIGURUMA library
|
||||
HAVE_ONIGURUMA=0
|
||||
AC_CHECK_HEADER("oniguruma.h",
|
||||
AC_CHECK_LIB([onig],[onig_version],[LIBS="$LIBS -lonig"; HAVE_ONIGURUMA=1;]))
|
||||
|
||||
# handle check results
|
||||
if test $HAVE_ONIGURUMA != 1; then
|
||||
AC_MSG_NOTICE([Oniguruma was not found.])
|
||||
AC_MSG_NOTICE([ Try setting the location using '--with-oniguruma=PREFIX' ])
|
||||
else
|
||||
AC_DEFINE([HAVE_ONIGURUMA],1,[Define to 1 if Oniguruma is installed])
|
||||
fi
|
||||
[],
|
||||
[with_oniguruma=yes])
|
||||
|
||||
AS_IF([test "x$with_oniguruma" != xno], [
|
||||
AS_IF([test "x$with_oniguruma" != xyes], [
|
||||
CFLAGS="$CFLAGS -I${with_oniguruma}/include"
|
||||
LDFLAGS="$LDFLAGS -L${with_oniguruma}/lib"
|
||||
])
|
||||
# check for ONIGURUMA library
|
||||
have_oniguruma=0
|
||||
AC_CHECK_HEADER("oniguruma.h",
|
||||
AC_CHECK_LIB([onig],[onig_version],[LIBS="$LIBS -lonig"; have_oniguruma=1;]))
|
||||
# handle check results
|
||||
AS_IF([test $have_oniguruma = 1], [
|
||||
AC_DEFINE([HAVE_ONIGURUMA], 1, [Define to 1 if Oniguruma is installed])
|
||||
], [
|
||||
AC_MSG_NOTICE([Oniguruma was not found.])
|
||||
AC_MSG_NOTICE([Try setting the location using '--with-oniguruma=PREFIX'])
|
||||
])
|
||||
])
|
||||
|
||||
dnl Check for valgrind
|
||||
AC_CHECK_PROGS(valgrind_cmd, valgrind)
|
||||
@@ -82,6 +81,8 @@ fi
|
||||
AC_CHECK_FUNCS(memmem)
|
||||
AC_CHECK_FUNCS(mkstemp)
|
||||
|
||||
AC_CHECK_HEADER("shlwapi.h",[have_win32=1;])
|
||||
AM_CONDITIONAL([WIN32], [test "x$have_win32" = x1])
|
||||
|
||||
dnl Running tests with Valgrind is slow. It is faster to iterate on
|
||||
dnl code without Valgrind until tests pass, then enable Valgrind and
|
||||
@@ -89,6 +90,15 @@ dnl fix leaks.
|
||||
AC_ARG_ENABLE([valgrind],
|
||||
AC_HELP_STRING([--disable-valgrind], [do not run tests under Valgrind]))
|
||||
|
||||
dnl Running tests with Valgrind is slow; address sanitizer (ASAN) is
|
||||
dnl faster.
|
||||
AC_ARG_ENABLE([asan],
|
||||
AC_HELP_STRING([--enable-asan], [enable address sanitizer]))
|
||||
|
||||
dnl Undefined Behavior Sanitizer
|
||||
AC_ARG_ENABLE([ubsan],
|
||||
AC_HELP_STRING([--enable-ubsan], [enable undefined behavior sanitizer]))
|
||||
|
||||
dnl Code coverage
|
||||
AC_ARG_ENABLE([gcov],
|
||||
AC_HELP_STRING([--enable-gcov], [enable gcov code coverage tool]))
|
||||
@@ -117,7 +127,7 @@ AS_IF([test "x$enable_docs" != "xno"],[
|
||||
*****************************************************************
|
||||
* Ruby dependencies for building jq documentation not found. *
|
||||
* You can still build, install and hack on jq, but the manpage *
|
||||
* will not be rebuilt and some of the tests won't run. *
|
||||
* will not be rebuilt and some of the tests will not run. *
|
||||
* See docs/README.md for how to install the docs dependencies. *
|
||||
*****************************************************************
|
||||
EOF
|
||||
@@ -130,6 +140,8 @@ EOF
|
||||
])
|
||||
|
||||
AM_CONDITIONAL([ENABLE_VALGRIND], [test "x$enable_valgrind" != xno])
|
||||
AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = xyes])
|
||||
AM_CONDITIONAL([ENABLE_UBSAN], [test "x$enable_ubsan" = xyes])
|
||||
AM_CONDITIONAL([ENABLE_GCOV], [test "x$enable_gcov" = xyes])
|
||||
AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" != xno])
|
||||
AM_CONDITIONAL([ENABLE_ERROR_INJECTION], [test "x$enable_error_injection" = xyes])
|
||||
@@ -167,31 +179,61 @@ AC_CHECK_MATH_FUNC(acos, [.5])
|
||||
AC_CHECK_MATH_FUNC(acosh, [.5])
|
||||
AC_CHECK_MATH_FUNC(asin, [.5])
|
||||
AC_CHECK_MATH_FUNC(asinh, [.5])
|
||||
AC_CHECK_MATH_FUNC(atan2, [.5,.5])
|
||||
AC_CHECK_MATH_FUNC(atan, [.5])
|
||||
AC_CHECK_MATH_FUNC(atanh, [.5])
|
||||
AC_CHECK_MATH_FUNC(cbrt, [.5])
|
||||
AC_CHECK_MATH_FUNC(ceil,[.5])
|
||||
AC_CHECK_MATH_FUNC(copysign,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(cos, [.5])
|
||||
AC_CHECK_MATH_FUNC(cosh, [.5])
|
||||
AC_CHECK_MATH_FUNC(drem,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(erf,[.5])
|
||||
AC_CHECK_MATH_FUNC(erfc,[.5])
|
||||
AC_CHECK_MATH_FUNC(exp10,[.5])
|
||||
AC_CHECK_MATH_FUNC(exp2, [.5])
|
||||
AC_CHECK_MATH_FUNC(exp, [.5])
|
||||
AC_CHECK_MATH_FUNC(expm1,[.5])
|
||||
AC_CHECK_MATH_FUNC(fabs,[.5])
|
||||
AC_CHECK_MATH_FUNC(fdim,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(floor, [.5])
|
||||
AC_CHECK_MATH_FUNC(fma,[.5,1.0,1.5])
|
||||
AC_CHECK_MATH_FUNC(fmax,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(fmin,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(fmod,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(frexp,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(gamma,[.5])
|
||||
AC_CHECK_MATH_FUNC(hypot, [.5,.5])
|
||||
AC_CHECK_MATH_FUNC(j0, [.5])
|
||||
AC_CHECK_MATH_FUNC(j1, [.5])
|
||||
AC_CHECK_MATH_FUNC(ldexp,[.5,2])
|
||||
AC_CHECK_MATH_FUNC(lgamma,[.5])
|
||||
AC_CHECK_MATH_FUNC(log10, [.5])
|
||||
AC_CHECK_MATH_FUNC(log1p,[.5])
|
||||
AC_CHECK_MATH_FUNC(log2, [.5])
|
||||
AC_CHECK_MATH_FUNC(log, [.5])
|
||||
AC_CHECK_MATH_FUNC(logb,[.5])
|
||||
AC_CHECK_MATH_FUNC(modf,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(nearbyint,[.5])
|
||||
AC_CHECK_MATH_FUNC(nextafter,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(nexttoward,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(pow10,[.5])
|
||||
AC_CHECK_MATH_FUNC(pow, [2,2])
|
||||
AC_CHECK_MATH_FUNC(remainder, [3,2])
|
||||
AC_CHECK_MATH_FUNC(rint,[.5])
|
||||
AC_CHECK_MATH_FUNC(round,[.5])
|
||||
AC_CHECK_MATH_FUNC(scalb,[.5,1.0])
|
||||
AC_CHECK_MATH_FUNC(scalbln,[.5,2])
|
||||
AC_CHECK_MATH_FUNC(significand,[.5])
|
||||
AC_CHECK_MATH_FUNC(sin, [.5])
|
||||
AC_CHECK_MATH_FUNC(sinh, [.5])
|
||||
AC_CHECK_MATH_FUNC(sqrt, [.5])
|
||||
AC_CHECK_MATH_FUNC(tan, [.5])
|
||||
AC_CHECK_MATH_FUNC(tanh, [.5])
|
||||
AC_CHECK_MATH_FUNC(tgamma, [.5])
|
||||
AC_CHECK_MATH_FUNC(trunc,[.5])
|
||||
AC_CHECK_MATH_FUNC(y0, [.5])
|
||||
AC_CHECK_MATH_FUNC(y1, [.5])
|
||||
AC_CHECK_MATH_FUNC(pow, [2,2])
|
||||
AC_CHECK_MATH_FUNC(atan2, [.5,.5])
|
||||
AC_CHECK_MATH_FUNC(hypot, [.5,.5])
|
||||
AC_CHECK_MATH_FUNC(remainder, [3,2])
|
||||
|
||||
dnl Thread local storage
|
||||
have___thread=no
|
||||
@@ -200,7 +242,7 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([
|
||||
static __thread int x ;
|
||||
int main () { x = 123; return x; }
|
||||
])], have___thread=yes)
|
||||
if test $have___thread = yes; then
|
||||
if test $have___thread = yes; then
|
||||
AC_DEFINE([HAVE___THREAD],1,[Define to 1 if the system supports __thread])
|
||||
fi
|
||||
AC_MSG_RESULT($have___thread)
|
||||
@@ -218,4 +260,3 @@ AC_CONFIG_MACRO_DIR([config/m4])
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
|
||||
@@ -4,3 +4,4 @@ gem "rake"
|
||||
gem "bonsai"
|
||||
gem "maruku"
|
||||
gem "ronn"
|
||||
gem "mustache", "<1.0" # to support ruby <2.0
|
||||
+30
-30
@@ -1,15 +1,14 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
POpen4 (0.1.4)
|
||||
Platform (>= 0.4.0)
|
||||
open4
|
||||
Platform (0.4.0)
|
||||
activesupport (3.2.12)
|
||||
i18n (~> 0.6)
|
||||
multi_json (~> 1.0)
|
||||
addressable (2.3.4)
|
||||
bonsai (1.4.8)
|
||||
activesupport (4.2.3)
|
||||
i18n (~> 0.7)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
addressable (2.3.8)
|
||||
bonsai (1.4.9)
|
||||
activesupport (>= 3.0.3)
|
||||
builder (>= 3.0.0)
|
||||
i18n (>= 0.5.0)
|
||||
@@ -22,36 +21,36 @@ GEM
|
||||
tilt (>= 1.3)
|
||||
watch (>= 0.1.0)
|
||||
yui-compressor
|
||||
builder (3.2.0)
|
||||
builder (3.2.2)
|
||||
hpricot (0.8.6)
|
||||
i18n (0.6.4)
|
||||
launchy (2.3.0)
|
||||
i18n (0.7.0)
|
||||
json (1.8.3)
|
||||
launchy (2.4.3)
|
||||
addressable (~> 2.3)
|
||||
liquid (2.5.0)
|
||||
maruku (0.6.1)
|
||||
syntax (>= 1.0.0)
|
||||
multi_json (1.7.3)
|
||||
mustache (0.99.4)
|
||||
open4 (1.3.0)
|
||||
rack (1.5.2)
|
||||
rack-protection (1.5.0)
|
||||
liquid (3.0.6)
|
||||
maruku (0.7.2)
|
||||
minitest (5.8.0)
|
||||
mustache (0.99.8)
|
||||
rack (1.6.4)
|
||||
rack-protection (1.5.3)
|
||||
rack
|
||||
rake (10.0.3)
|
||||
rdiscount (2.0.7.2)
|
||||
rake (10.4.2)
|
||||
rdiscount (2.1.8)
|
||||
ronn (0.7.3)
|
||||
hpricot (>= 0.8.2)
|
||||
mustache (>= 0.7.0)
|
||||
rdiscount (>= 1.5.8)
|
||||
sass (3.2.8)
|
||||
sinatra (1.4.2)
|
||||
rack (~> 1.5, >= 1.5.2)
|
||||
sass (3.4.16)
|
||||
sinatra (1.4.6)
|
||||
rack (~> 1.4)
|
||||
rack-protection (~> 1.4)
|
||||
tilt (~> 1.3, >= 1.3.4)
|
||||
syntax (1.0.0)
|
||||
tilt (1.4.0)
|
||||
tilt (>= 1.3, < 3)
|
||||
thread_safe (0.3.5)
|
||||
tilt (2.0.1)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
watch (0.1.0)
|
||||
yui-compressor (0.9.6)
|
||||
POpen4 (>= 0.1.4)
|
||||
yui-compressor (0.12.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@@ -59,5 +58,6 @@ PLATFORMS
|
||||
DEPENDENCIES
|
||||
bonsai
|
||||
maruku
|
||||
mustache (< 1.0)
|
||||
rake
|
||||
ronn
|
||||
+1
-1
@@ -13,7 +13,7 @@ RVM and Ruby 1.9.3 like so:
|
||||
|
||||
After that finishes installing, you'll need to make sure RVM is on
|
||||
your path by doing `source $HOME/.rvm/scripts/rvm`, or just opening a
|
||||
new shell. See <http://rvm.io> for more info on RVM.
|
||||
new shell. See <https://rvm.io> for more info on RVM.
|
||||
|
||||
Once RVM is installed, you can install all the dependencies for jq's
|
||||
documentation build by running this from the `docs` directory:
|
||||
|
||||
+15
-136
@@ -1,145 +1,24 @@
|
||||
require 'yaml'
|
||||
require 'bonsai'
|
||||
require 'liquid'
|
||||
require 'maruku'
|
||||
require 'json'
|
||||
require 'ronn'
|
||||
require 'tempfile'
|
||||
require 'yaml'
|
||||
|
||||
module ExtraFilters
|
||||
def markdownify(input)
|
||||
Maruku.new(input).to_html
|
||||
end
|
||||
|
||||
def sanitize(input)
|
||||
input.gsub(/[^a-zA-Z0-9_]/,"")
|
||||
end
|
||||
|
||||
def json(input)
|
||||
input.to_json
|
||||
end
|
||||
|
||||
def unique(input)
|
||||
@n = (@n || 0) + 1
|
||||
input + @n.to_s
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_filter(ExtraFilters)
|
||||
|
||||
|
||||
task :serve do
|
||||
begin
|
||||
Bonsai.log "Press Control+C to quit"
|
||||
|
||||
require 'rack'
|
||||
require 'sinatra'
|
||||
require 'watch'
|
||||
require 'launchy'
|
||||
|
||||
Bonsai.root_dir = Dir.pwd
|
||||
|
||||
server = fork {
|
||||
app = Rack::Builder.app {
|
||||
map "/jq" do
|
||||
use Bonsai::StaticPassThrough, :root => Bonsai.root_dir + "/output", :urls => ["/"]
|
||||
end
|
||||
run Bonsai::DevelopmentServer
|
||||
}
|
||||
Rack::Handler.default.run(app, :Port => 5000) do
|
||||
Launchy.open("http://localhost:5000/jq/")
|
||||
end
|
||||
}
|
||||
Watch.new("{content,templates,public}/**/*") { Bonsai::Exporter.process! }
|
||||
rescue Interrupt
|
||||
Process.kill("QUIT", server)
|
||||
Process.wait(server)
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
task :build do
|
||||
Bonsai.root_dir = Dir.pwd
|
||||
Bonsai::Exporter.publish!
|
||||
end
|
||||
|
||||
$BINARIES = {
|
||||
:osx32 => "--host=i686-apple-darwin10 CFLAGS='-m32 -g -O'",
|
||||
:osx64 => "--host=i686-apple-darwin10 CFLAGS='-m64 -g -O'",
|
||||
:win32 => "--host=i686-w64-mingw32 CFLAGS='-g -O'",
|
||||
:win64 => "--host=x86_64-w64-mingw32 CFLAGS='-g -O'",
|
||||
:linux32 => "--host=x86_64-linux-gnu CFLAGS='-m32 -g -O'",
|
||||
:linux64 => "--host=x86_64-linux-gnu CFLAGS='-m64 -g -O'"
|
||||
}
|
||||
|
||||
$BINARIES.each do |name, args|
|
||||
file "../build/#{name}" do |t|
|
||||
sh "../scripts/crosscompile -j4 #{name} #{args}"
|
||||
end
|
||||
task :binaries => ["../build/#{name}"]
|
||||
end
|
||||
|
||||
task :binaries => ["output/download"] do
|
||||
$BINARIES.each do |name, args|
|
||||
FileUtils.cp_r "../build/#{name}", "output/download/"
|
||||
end
|
||||
end
|
||||
|
||||
def load_manual
|
||||
YAML::load(File.open("content/3.manual/manual.yml"))
|
||||
end
|
||||
current_dir = File.dirname(__FILE__)
|
||||
rakefile_manual = File.expand_path(File.join(current_dir, "Rakefile.manual"))
|
||||
rakefile_website = File.expand_path(File.join(current_dir, "Rakefile.website"))
|
||||
|
||||
desc "Build the manpage from the bonsai source of the manual"
|
||||
task :manpage do
|
||||
Tempfile.open "manpage" do |f|
|
||||
manual = load_manual
|
||||
f.puts manual['manpage_intro']
|
||||
f.puts manual['body']
|
||||
manual['sections'].each do |section|
|
||||
|
||||
f.puts "## #{section['title'].upcase}\n"
|
||||
f.puts section['body']
|
||||
f.puts ""
|
||||
(section['entries'] || []).each do |entry|
|
||||
f.puts "### #{entry['title']}\n"
|
||||
f.puts entry['body']
|
||||
f.puts ""
|
||||
(entry['examples'] || []).each do |example|
|
||||
f.puts " jq '#{example['program']}'"
|
||||
f.puts " #{example['input']}"
|
||||
f.puts " => #{example['output'].join(", ")}"
|
||||
f.puts
|
||||
end
|
||||
end
|
||||
f.puts ""
|
||||
end
|
||||
f.puts manual['manpage_epilogue']
|
||||
f.close
|
||||
puts Ronn::Document.new(f.path).convert('roff').gsub(/<\/?code>/,"")
|
||||
end
|
||||
end
|
||||
|
||||
task :manpage_default => ["default_manpage.md"] do
|
||||
puts Ronn::Document.new("default_manpage.md").convert('roff').gsub(/<\/?code>/,"")
|
||||
system %(#{$0} -f #{rakefile_manual} manpage)
|
||||
end
|
||||
|
||||
desc "Collect jq unit test cases from the bonsai source of the manual"
|
||||
task :mantests do
|
||||
load_manual['sections'].each do |section|
|
||||
(section['entries'] || []).each do |entry|
|
||||
(entry['examples'] || []).each do |example|
|
||||
puts example['program'].gsub("\n", " ")
|
||||
puts example['input']
|
||||
example['output'].each do |s| puts s end
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
||||
system %(#{$0} -f #{rakefile_manual} mantests)
|
||||
end
|
||||
|
||||
directory "output/download/source"
|
||||
task :tarball => ["output/download/source"] do
|
||||
sh "cd ..; ./configure && make dist && make distclean"
|
||||
sh "cp ../jq-*.tar.gz output/download/source"
|
||||
desc "Build the website from the bonsai sources"
|
||||
task :build do
|
||||
system %(#{$0} -f #{rakefile_website} build)
|
||||
end
|
||||
|
||||
desc "Serve a live view of the website on http://localhost:5000/jq/"
|
||||
task :serve do
|
||||
system %(#{$0} -f #{rakefile_website} serve)
|
||||
end
|
||||
|
||||
task :dist => [:build, :binaries, :tarball]
|
||||
@@ -0,0 +1,49 @@
|
||||
require 'ronn'
|
||||
require 'tempfile'
|
||||
require 'yaml'
|
||||
|
||||
def load_manual
|
||||
YAML::load(File.open("content/3.manual/manual.yml"))
|
||||
end
|
||||
|
||||
task :manpage do
|
||||
Tempfile.open "manpage" do |f|
|
||||
manual = load_manual
|
||||
f.puts manual['manpage_intro']
|
||||
f.puts manual['body']
|
||||
manual['sections'].each do |section|
|
||||
|
||||
f.puts "## #{section['title'].upcase}\n"
|
||||
f.puts section['body']
|
||||
f.puts ""
|
||||
(section['entries'] || []).each do |entry|
|
||||
f.puts "### #{entry['title']}\n"
|
||||
f.puts entry['body']
|
||||
f.puts ""
|
||||
(entry['examples'] || []).each do |example|
|
||||
f.puts " jq '#{example['program']}'"
|
||||
f.puts " #{example['input']}"
|
||||
f.puts " => #{example['output'].join(", ")}"
|
||||
f.puts
|
||||
end
|
||||
end
|
||||
f.puts ""
|
||||
end
|
||||
f.puts manual['manpage_epilogue']
|
||||
f.close
|
||||
puts Ronn::Document.new(f.path).convert('roff').gsub(/<\/?code>/,"")
|
||||
end
|
||||
end
|
||||
|
||||
task :mantests do
|
||||
load_manual['sections'].each do |section|
|
||||
(section['entries'] || []).each do |entry|
|
||||
(entry['examples'] || []).each do |example|
|
||||
puts example['program'].gsub("\n", " ")
|
||||
puts example['input']
|
||||
example['output'].each do |s| puts s end
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,66 @@
|
||||
require 'bonsai'
|
||||
require 'json'
|
||||
require 'liquid'
|
||||
require 'maruku'
|
||||
|
||||
module ExtraFilters
|
||||
def markdownify(input)
|
||||
Maruku.new(input).to_html
|
||||
end
|
||||
def search_id(input)
|
||||
input.gsub(/`/, '')
|
||||
end
|
||||
def section_id(input)
|
||||
input.gsub(/[^a-zA-Z0-9_]/, '')
|
||||
end
|
||||
def entry_id(input)
|
||||
input.gsub(/[ `]/, '')
|
||||
end
|
||||
def no_paragraph(input)
|
||||
input.gsub('<p>', '').gsub('</p>', '')
|
||||
end
|
||||
def json(input)
|
||||
input.to_json
|
||||
end
|
||||
def unique(input)
|
||||
@n = (@n || 0) + 1
|
||||
input + @n.to_s
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_filter(ExtraFilters)
|
||||
|
||||
task :build do
|
||||
Bonsai.root_dir = Dir.pwd
|
||||
Bonsai::Exporter.publish!
|
||||
end
|
||||
|
||||
task :serve do
|
||||
begin
|
||||
Bonsai.log "Press Control+C to quit"
|
||||
|
||||
require 'rack'
|
||||
require 'sinatra'
|
||||
require 'watch'
|
||||
require 'launchy'
|
||||
|
||||
Bonsai.root_dir = Dir.pwd
|
||||
|
||||
server = fork {
|
||||
app = Rack::Builder.app {
|
||||
map "/jq" do
|
||||
use Bonsai::StaticPassThrough, :root => Bonsai.root_dir + "/output", :urls => ["/"]
|
||||
end
|
||||
run Bonsai::DevelopmentServer
|
||||
}
|
||||
Rack::Handler.default.run(app, :Port => 5000) do
|
||||
Launchy.open("http://localhost:5000/jq/")
|
||||
end
|
||||
}
|
||||
Watch.new("{content,templates,public}/**/*") { Bonsai::Exporter.process! }
|
||||
rescue Interrupt
|
||||
Process.kill("QUIT", server)
|
||||
Process.wait(server)
|
||||
exit
|
||||
end
|
||||
end
|
||||
+157
-152
@@ -2,8 +2,8 @@ headline: Tutorial
|
||||
body:
|
||||
- text: |
|
||||
|
||||
GitHub has a JSON API, so let's play with that. This URL gets
|
||||
us the last 5 commits from the jq repo:
|
||||
GitHub has a JSON API, so let's play with that. This URL gets us the last
|
||||
5 commits from the jq repo.
|
||||
|
||||
- command: "curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5'"
|
||||
result: |
|
||||
@@ -34,174 +34,180 @@ body:
|
||||
"comments_url": "https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f/comments",
|
||||
"author": {
|
||||
"login": "stedolan",
|
||||
...
|
||||
...
|
||||
|
||||
- text: |
|
||||
Github returns a ton of info here, and it's relatively hard to
|
||||
read as it is. To syntax highlight it and order the attributes we pipe
|
||||
it through jq, telling jq to just spit the input back at us using
|
||||
the expression `.`:
|
||||
|
||||
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 `.`, which takes the input and produces it
|
||||
unchanged as output.
|
||||
|
||||
- command: "curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | jq '.'"
|
||||
result: |
|
||||
[
|
||||
{
|
||||
"parents": [
|
||||
{
|
||||
"html_url": "https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7",
|
||||
"url": "https://api.github.com/repos/stedolan/jq/commits/54b9c9bdb225af5d886466d72f47eafc51acb4f7",
|
||||
"sha": "54b9c9bdb225af5d886466d72f47eafc51acb4f7"
|
||||
"sha": "d25341478381063d1c76e81b3a52e0592a7c997f",
|
||||
"commit": {
|
||||
"author": {
|
||||
"name": "Stephen Dolan",
|
||||
"email": "mu@netsoc.tcd.ie",
|
||||
"date": "2013-06-22T16:30:59Z"
|
||||
},
|
||||
{
|
||||
"html_url": "https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a",
|
||||
"url": "https://api.github.com/repos/stedolan/jq/commits/8b1b503609c161fea4b003a7179b3fbb2dd4345a",
|
||||
"sha": "8b1b503609c161fea4b003a7179b3fbb2dd4345a"
|
||||
}
|
||||
],
|
||||
"committer": {
|
||||
"type": "User",
|
||||
"received_events_url": "https://api.github.com/users/stedolan/received_events",
|
||||
"events_url": "https://api.github.com/users/stedolan/events{/privacy}",
|
||||
"repos_url": "https://api.github.com/users/stedolan/repos",
|
||||
"organizations_url": "https://api.github.com/users/stedolan/orgs",
|
||||
"committer": {
|
||||
"name": "Stephen Dolan",
|
||||
"email": "mu@netsoc.tcd.ie",
|
||||
"date": "2013-06-22T16:30:59Z"
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"url": "https://api.github.com/repos/stedolan/jq/git/commits/d25341478381063d1c76e81b3a52e0592a7c997f",
|
||||
"comment_count": 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",
|
||||
...
|
||||
|
||||
- text: |
|
||||
|
||||
There's still far too much info for our purposes, so we can try
|
||||
just grab the first commit:
|
||||
|
||||
We can use jq to extract just the first commit.
|
||||
|
||||
- command: "curl 'https://api.github.com/repos/stedolan/jq/commits?per_page=5' | jq '.[0]'"
|
||||
result: |
|
||||
{
|
||||
"parents": [
|
||||
{
|
||||
"html_url": "https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7",
|
||||
"url": "https://api.github.com/repos/stedolan/jq/commits/54b9c9bdb225af5d886466d72f47eafc51acb4f7",
|
||||
"sha": "54b9c9bdb225af5d886466d72f47eafc51acb4f7"
|
||||
},
|
||||
{
|
||||
"html_url": "https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a",
|
||||
"url": "https://api.github.com/repos/stedolan/jq/commits/8b1b503609c161fea4b003a7179b3fbb2dd4345a",
|
||||
"sha": "8b1b503609c161fea4b003a7179b3fbb2dd4345a"
|
||||
}
|
||||
],
|
||||
"committer": {
|
||||
"type": "User",
|
||||
"received_events_url": "https://api.github.com/users/stedolan/received_events",
|
||||
"events_url": "https://api.github.com/users/stedolan/events{/privacy}",
|
||||
"repos_url": "https://api.github.com/users/stedolan/repos",
|
||||
"organizations_url": "https://api.github.com/users/stedolan/orgs",
|
||||
"subscriptions_url": "https://api.github.com/users/stedolan/subscriptions",
|
||||
"starred_url": "https://api.github.com/users/stedolan/starred{/owner}{/repo}",
|
||||
"gists_url": "https://api.github.com/users/stedolan/gists{/gist_id}",
|
||||
"login": "stedolan",
|
||||
"id": 79765,
|
||||
"avatar_url": "https://1.gravatar.com/avatar/31de909d8e55dd07ed782d92ece59842?d=https%3A%2F%2Fidenticons.github.com%2Ffc5b6765b1c9cfaecea48ae71df4d279.png",
|
||||
"gravatar_id": "31de909d8e55dd07ed782d92ece59842",
|
||||
"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}"
|
||||
},
|
||||
"author": {
|
||||
"type": "User",
|
||||
"received_events_url": "https://api.github.com/users/stedolan/received_events",
|
||||
"events_url": "https://api.github.com/users/stedolan/events{/privacy}",
|
||||
"repos_url": "https://api.github.com/users/stedolan/repos",
|
||||
"organizations_url": "https://api.github.com/users/stedolan/orgs",
|
||||
"subscriptions_url": "https://api.github.com/users/stedolan/subscriptions",
|
||||
"starred_url": "https://api.github.com/users/stedolan/starred{/owner}{/repo}",
|
||||
"gists_url": "https://api.github.com/users/stedolan/gists{/gist_id}",
|
||||
"login": "stedolan",
|
||||
"id": 79765,
|
||||
"avatar_url": "https://1.gravatar.com/avatar/31de909d8e55dd07ed782d92ece59842?d=https%3A%2F%2Fidenticons.github.com%2Ffc5b6765b1c9cfaecea48ae71df4d279.png",
|
||||
"gravatar_id": "31de909d8e55dd07ed782d92ece59842",
|
||||
"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}"
|
||||
},
|
||||
"comments_url": "https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f/comments",
|
||||
"html_url": "https://github.com/stedolan/jq/commit/d25341478381063d1c76e81b3a52e0592a7c997f",
|
||||
"url": "https://api.github.com/repos/stedolan/jq/commits/d25341478381063d1c76e81b3a52e0592a7c997f",
|
||||
"sha": "d25341478381063d1c76e81b3a52e0592a7c997f",
|
||||
"commit": {
|
||||
"comment_count": 0,
|
||||
"url": "https://api.github.com/repos/stedolan/jq/git/commits/d25341478381063d1c76e81b3a52e0592a7c997f",
|
||||
"tree": {
|
||||
"url": "https://api.github.com/repos/stedolan/jq/git/trees/6ab697a8dfb5a96e124666bf6d6213822599fb40",
|
||||
"sha": "6ab697a8dfb5a96e124666bf6d6213822599fb40"
|
||||
"author": {
|
||||
"name": "Stephen Dolan",
|
||||
"email": "mu@netsoc.tcd.ie",
|
||||
"date": "2013-06-22T16:30:59Z"
|
||||
},
|
||||
"committer": {
|
||||
"name": "Stephen Dolan",
|
||||
"email": "mu@netsoc.tcd.ie",
|
||||
"date": "2013-06-22T16:30:59Z"
|
||||
},
|
||||
"message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161",
|
||||
"committer": {
|
||||
"date": "2013-06-22T16:30:59Z",
|
||||
"email": "mu@netsoc.tcd.ie",
|
||||
"name": "Stephen Dolan"
|
||||
"tree": {
|
||||
"sha": "6ab697a8dfb5a96e124666bf6d6213822599fb40",
|
||||
"url": "https://api.github.com/repos/stedolan/jq/git/trees/6ab697a8dfb5a96e124666bf6d6213822599fb40"
|
||||
},
|
||||
"author": {
|
||||
"date": "2013-06-22T16:30:59Z",
|
||||
"email": "mu@netsoc.tcd.ie",
|
||||
"name": "Stephen Dolan"
|
||||
}
|
||||
"url": "https://api.github.com/repos/stedolan/jq/git/commits/d25341478381063d1c76e81b3a52e0592a7c997f",
|
||||
"comment_count": 0
|
||||
},
|
||||
"sha": "d25341478381063d1c76e81b3a52e0592a7c997f"
|
||||
"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
|
||||
},
|
||||
"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
|
||||
},
|
||||
"parents": [
|
||||
{
|
||||
"sha": "54b9c9bdb225af5d886466d72f47eafc51acb4f7",
|
||||
"url": "https://api.github.com/repos/stedolan/jq/commits/54b9c9bdb225af5d886466d72f47eafc51acb4f7",
|
||||
"html_url": "https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7"
|
||||
},
|
||||
{
|
||||
"sha": "8b1b503609c161fea4b003a7179b3fbb2dd4345a",
|
||||
"url": "https://api.github.com/repos/stedolan/jq/commits/8b1b503609c161fea4b003a7179b3fbb2dd4345a",
|
||||
"html_url": "https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
- text: |
|
||||
|
||||
For the rest of the examples, I'll leave out the `curl` command - it's not going to change.
|
||||
|
||||
There's still a lot of info we don't care about there, so we'll
|
||||
restrict it down to the most interesting fields.
|
||||
For the rest of the examples, I'll leave out the `curl` command - it's not
|
||||
going to change.
|
||||
|
||||
There's a lot of info we don't care about there, so we'll restrict it down
|
||||
to the most interesting fields.
|
||||
|
||||
- command: "jq '.[0] | {message: .commit.message, name: .commit.committer.name}'"
|
||||
result: |
|
||||
{
|
||||
"name": "Stephen Dolan",
|
||||
"message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161"
|
||||
"message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161",
|
||||
"name": "Stephen Dolan"
|
||||
}
|
||||
|
||||
- text: |
|
||||
|
||||
The `|` operator in jq feeds the output of one filter
|
||||
(`.[0]` which gets the first element of the array in the response)
|
||||
into the input of another (`{...}` which
|
||||
builds an object out of those fields). You can access nested attributes,
|
||||
such as `.commit.message`:
|
||||
|
||||
Now let's get the rest of the commits:
|
||||
The `|` operator in jq feeds the output of one filter (`.[0]` which gets
|
||||
the first element of the array in the response) into the input of another
|
||||
(`{...}` which builds an object out of those fields). You can access
|
||||
nested attributes, such as `.commit.message`.
|
||||
|
||||
Now let's get the rest of the commits.
|
||||
|
||||
- command: "jq '.[] | {message: .commit.message, name: .commit.committer.name}'"
|
||||
result: |
|
||||
{
|
||||
"name": "Stephen Dolan",
|
||||
"message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161"
|
||||
"message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161",
|
||||
"name": "Stephen Dolan"
|
||||
}
|
||||
{
|
||||
"name": "Stephen Dolan",
|
||||
"message": "Reject all overlong UTF8 sequences."
|
||||
"message": "Reject all overlong UTF8 sequences.",
|
||||
"name": "Stephen Dolan"
|
||||
}
|
||||
{
|
||||
"name": "Stephen Dolan",
|
||||
"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."
|
||||
"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"
|
||||
}
|
||||
{
|
||||
"name": "Stephen Dolan",
|
||||
"message": "Fix example in manual for `floor`. See #155."
|
||||
"message": "Fix example in manual for `floor`. See #155.",
|
||||
"name": "Stephen Dolan"
|
||||
}
|
||||
{
|
||||
"name": "Nicolas Williams",
|
||||
"message": "Document floor"
|
||||
"message": "Document floor",
|
||||
"name": "Nicolas Williams"
|
||||
}
|
||||
|
||||
- text: |
|
||||
|
||||
`.[]` returns each element of the array returned in the response,
|
||||
one at a time, which are all fed into `{message: .commit.message, name: .commit.committer.name}`.
|
||||
|
||||
`.[]` returns each element of the array returned in the response, one at a
|
||||
time, which are all fed into
|
||||
`{message: .commit.message, name: .commit.committer.name}`.
|
||||
|
||||
Data in jq is represented as streams of JSON values - every jq
|
||||
expression runs for each value in its input stream, and can
|
||||
@@ -219,26 +225,27 @@ body:
|
||||
result: |
|
||||
[
|
||||
{
|
||||
"name": "Stephen Dolan",
|
||||
"message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161"
|
||||
"message": "Merge pull request #163 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161",
|
||||
"name": "Stephen Dolan"
|
||||
},
|
||||
{
|
||||
"name": "Stephen Dolan",
|
||||
"message": "Reject all overlong UTF8 sequences."
|
||||
"message": "Reject all overlong UTF8 sequences.",
|
||||
"name": "Stephen Dolan"
|
||||
},
|
||||
{
|
||||
"name": "Stephen Dolan",
|
||||
"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."
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"name": "Stephen Dolan",
|
||||
"message": "Fix example in manual for `floor`. See #155."
|
||||
"message": "Fix example in manual for `floor`. See #155.",
|
||||
"name": "Stephen Dolan"
|
||||
},
|
||||
{
|
||||
"name": "Nicolas Williams",
|
||||
"message": "Document floor"
|
||||
"message": "Document floor",
|
||||
"name": "Nicolas Williams"
|
||||
}
|
||||
]
|
||||
|
||||
- text: |
|
||||
|
||||
- - -
|
||||
@@ -249,14 +256,14 @@ body:
|
||||
|
||||
"parents": [
|
||||
{
|
||||
"html_url": "https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7",
|
||||
"sha": "54b9c9bdb225af5d886466d72f47eafc51acb4f7",
|
||||
"url": "https://api.github.com/repos/stedolan/jq/commits/54b9c9bdb225af5d886466d72f47eafc51acb4f7",
|
||||
"sha": "54b9c9bdb225af5d886466d72f47eafc51acb4f7"
|
||||
"html_url": "https://github.com/stedolan/jq/commit/54b9c9bdb225af5d886466d72f47eafc51acb4f7"
|
||||
},
|
||||
{
|
||||
"html_url": "https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a",
|
||||
"sha": "8b1b503609c161fea4b003a7179b3fbb2dd4345a",
|
||||
"url": "https://api.github.com/repos/stedolan/jq/commits/8b1b503609c161fea4b003a7179b3fbb2dd4345a",
|
||||
"sha": "8b1b503609c161fea4b003a7179b3fbb2dd4345a"
|
||||
"html_url": "https://github.com/stedolan/jq/commit/8b1b503609c161fea4b003a7179b3fbb2dd4345a"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -264,59 +271,57 @@ body:
|
||||
commits and make a simple list of strings to go along with the
|
||||
"message" and "author" fields we already have.
|
||||
|
||||
|
||||
|
||||
- command: "jq '[.[] | {message: .commit.message, name: .commit.committer.name, parents: [.parents[].html_url]}]'"
|
||||
result: |
|
||||
[
|
||||
{
|
||||
"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"
|
||||
],
|
||||
"name": "Stephen Dolan",
|
||||
"message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161"
|
||||
]
|
||||
},
|
||||
{
|
||||
"message": "Reject all overlong UTF8 sequences.",
|
||||
"name": "Stephen Dolan",
|
||||
"parents": [
|
||||
"https://github.com/stedolan/jq/commit/ff48bd6ec538b01d1057be8e93b94eef6914e9ef"
|
||||
],
|
||||
"name": "Stephen Dolan",
|
||||
"message": "Reject all overlong UTF8 sequences."
|
||||
]
|
||||
},
|
||||
{
|
||||
"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"
|
||||
],
|
||||
"name": "Stephen Dolan",
|
||||
"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."
|
||||
]
|
||||
},
|
||||
{
|
||||
"message": "Fix example in manual for `floor`. See #155.",
|
||||
"name": "Stephen Dolan",
|
||||
"parents": [
|
||||
"https://github.com/stedolan/jq/commit/3dcdc582ea993afea3f5503a78a77675967ecdfa"
|
||||
],
|
||||
"name": "Stephen Dolan",
|
||||
"message": "Fix example in manual for `floor`. See #155."
|
||||
]
|
||||
},
|
||||
{
|
||||
"message": "Document floor",
|
||||
"name": "Nicolas Williams",
|
||||
"parents": [
|
||||
"https://github.com/stedolan/jq/commit/7c4171d414f647ab08bcd20c76a4d8ed68d9c602"
|
||||
],
|
||||
"name": "Nicolas Williams",
|
||||
"message": "Document floor"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
- text: |
|
||||
|
||||
Here we're making an object as before, but this time the `parents`
|
||||
field is being set to `[.parents[].html_url]}]`, which collects
|
||||
field is being set to `[.parents[].html_url]`, which collects
|
||||
all of the parent commit URLs defined in the parents object.
|
||||
|
||||
- text: |
|
||||
|
||||
- - -
|
||||
|
||||
Here endeth the tutorial! There's lots more to play with, go
|
||||
Here endeth the tutorial! There's lots more to play with. Go
|
||||
read [the manual](../manual/) if you're interested, and [download
|
||||
jq](../download/) if you haven't already.
|
||||
@@ -15,51 +15,110 @@ body:
|
||||
|
||||
|
||||
### Linux
|
||||
|
||||
* jq 1.4 binaries for [64-bit](linux64/jq) or [32-bit](linux32/jq) systems.
|
||||
* jq 1.3 binaries for [64-bit](linux64/jq-1.3/jq) or [32-bit](linux32/jq-1.3/jq) systems.
|
||||
|
||||
* For Arch users, a PKGBUILD for jq-1.1 is in the
|
||||
[AUR](https://aur.archlinux.org/packages.php?ID=63849), as
|
||||
well as a PKGBUILD for the HEAD of master
|
||||
([jq-git](https://aur.archlinux.org/packages.php?ID=63850)).
|
||||
You can install them using
|
||||
[Yaourt](https://wiki.archlinux.org/index.php/Yaourt) or
|
||||
manually by following instructions on [Arch Linux's
|
||||
Wiki](https://wiki.archlinux.org/index.php/Arch_UseRepository).
|
||||
* jq 1.5 is in the official [Debian](https://packages.debian.org/jq) and
|
||||
[Ubuntu](http://packages.ubuntu.com/jq) repositories. Install using
|
||||
`sudo apt-get install jq`.
|
||||
|
||||
* jq 1.4 is [in Debian](http://packages.debian.org/jq)
|
||||
* jq 1.5 is in the official
|
||||
[Fedora](http://pkgs.fedoraproject.org/cgit/jq.git/) repository.
|
||||
Install using `sudo dnf install jq`.
|
||||
|
||||
* jq 1.3.2 is in the official Fedora repository. You can install using
|
||||
`sudo yum install jq`.
|
||||
* jq 1.4 is in the official [openSUSE](https://software.opensuse.org/package/jq)
|
||||
repository. Install using `sudo zypper install jq`.
|
||||
|
||||
* jq 1.5 is in the official
|
||||
[Arch](https://www.archlinux.org/packages/?sort=&q=jq&maintainer=&flagged=)
|
||||
repository. Install using `sudo pacman -Sy jq`.
|
||||
|
||||
* jq 1.5 binaries for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux32).
|
||||
|
||||
* jq 1.4 binaries for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-linux-x86_64)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-linux-x86).
|
||||
|
||||
* jq 1.3 binaries for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-linux-x86_64)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-linux-x86).
|
||||
|
||||
### OS X
|
||||
|
||||
* `brew install jq` using [homebrew](http://mxcl.github.com/homebrew/)
|
||||
* Use [Homebrew](http://brew.sh/) to install jq 1.5 with
|
||||
`brew install jq`.
|
||||
|
||||
* Or, grab prebuilt jq 1.4 [64-bit binaries](osx64/jq) or [32-bit
|
||||
binaries](osx32/jq)
|
||||
* jq 1.5 binary for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64).
|
||||
|
||||
* Or, grab prebuilt jq 1.3 [64-bit binaries](osx64/jq-1.3/jq) or [32-bit
|
||||
binaries](osx32/jq-1.3/jq)
|
||||
* jq 1.4 binaries for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-osx-x86_64)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-osx-x86).
|
||||
|
||||
* jq 1.3 binaries for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-osx-x86_64)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-osx-x86).
|
||||
|
||||
### FreeBSD
|
||||
|
||||
* Use [FreshPorts](https://www.freshports.org/textproc/jq/) to install
|
||||
jq 1.4 with `pkg install jq`.
|
||||
|
||||
### Solaris
|
||||
|
||||
* `pkgutil -i jq` in [OpenCSW](http://www.opencsw.org/p/jq) for Solaris 10+, Sparc and x86
|
||||
* `pkgutil -i jq` in [OpenCSW](https://www.opencsw.org/p/jq) for Solaris
|
||||
10+, Sparc and x86.
|
||||
|
||||
* jq 1.4 executables for Solaris 11 [64-bit](solaris11-64/jq) or [32-bit](solaris11-32/jq)
|
||||
* jq 1.4 binaries for Solaris 11
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-solaris11-64)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-solaris11-32).
|
||||
|
||||
### Windows
|
||||
|
||||
* `chocolatey install jq` using [Chocolatey NuGet](https://chocolatey.org/)
|
||||
* Use [Chocolatey NuGet](https://chocolatey.org/) to install jq 1.5 with
|
||||
`chocolatey install jq`.
|
||||
|
||||
* jq 1.4 executables for [64-bit](win64/jq.exe) or [32-bit](win32/jq.exe)
|
||||
* jq 1.5 executables for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-win64.exe)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-win32.exe).
|
||||
|
||||
* jq 1.3 executables for [64-bit](win64/jq-1.3/jq-1.3.exe) or [32-bit](win32/jq-1.3/jq-1.3.exe)
|
||||
* jq 1.4 executables for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-win64.exe)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.4/jq-win32.exe).
|
||||
|
||||
* jq 1.3 executables for
|
||||
[64-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-win64.exe)
|
||||
or
|
||||
[32-bit](https://github.com/stedolan/jq/releases/download/jq-1.3/jq-win32.exe).
|
||||
|
||||
### Checksums and signatures
|
||||
|
||||
SHA-256 checksums are provided for all release and pre-release binaries.
|
||||
They can be found under
|
||||
[sig/v1.x/sha256sum.txt](https://github.com/stedolan/jq/tree/master/sig).
|
||||
The checksums for jq 1.5 are in
|
||||
[sig/v1.5/sha256sum.txt](https://raw.githubusercontent.com/stedolan/jq/master/sig/v1.5/sha256sum.txt).
|
||||
|
||||
Additionally, all binaries are signed by the
|
||||
[jq Package Signing Key](https://raw.githubusercontent.com/stedolan/jq/master/sig/jq-release.key).
|
||||
The signatures can be found under
|
||||
[sig/v1.x/\*.asc](https://github.com/stedolan/jq/tree/master/sig).
|
||||
The signatures for jq 1.5 are in
|
||||
[sig/v1.5/\*.asc](https://github.com/stedolan/jq/tree/master/sig/v1.5).
|
||||
You can use [GnuPG](https://gnupg.org/) to verify a signature by downloading
|
||||
the signature and running `gpg --verify signature.asc`.
|
||||
|
||||
### From source on Linux, OS X, Cygwin, and other POSIX-like operating systems
|
||||
|
||||
* [Source tarball for jq 1.4](source/jq-1.4.tar.gz)
|
||||
* [Source tarball for jq 1.5](https://github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz)
|
||||
|
||||
You can build it using the usual `./configure && make && sudo
|
||||
make install` rigmarole.
|
||||
@@ -69,34 +128,33 @@ body:
|
||||
git clone https://github.com/stedolan/jq.git
|
||||
cd jq
|
||||
autoreconf -i
|
||||
./configure
|
||||
./configure --disable-maintainer-mode
|
||||
make
|
||||
sudo make install
|
||||
|
||||
To build it from a git clone, you'll need to install a few
|
||||
packages first:
|
||||
|
||||
* [Flex](http://www.gnu.org/software/flex/)
|
||||
* [Bison](http://www.gnu.org/software/bison/)
|
||||
* [GCC](http://gcc.gnu.org)
|
||||
* [Make](http://www.gnu.org/software/make)
|
||||
* [Autotools](http://www.gnu.org/software/automake)
|
||||
* [GCC](https://gcc.gnu.org)
|
||||
* [Make](https://www.gnu.org/software/make/)
|
||||
* [Autotools](https://www.gnu.org/software/automake/)
|
||||
|
||||
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.
|
||||
|
||||
On OS X, these are all included in Apple's command line tools, which
|
||||
can be installed from [Xcode](http://developer.apple.com/technologies/tools/).
|
||||
However, you may find that you need a newer version of Bison than the one provided
|
||||
by Apple. This can be found in [Homebrew](http://mxcl.github.com/homebrew/)
|
||||
or [MacPorts](http://macports.org/).
|
||||
On OS X, these are all included in Apple's command line tools, which can
|
||||
be installed from [Xcode](https://developer.apple.com/xcode/). However,
|
||||
you may find that you need a newer version of Bison than the one provided
|
||||
by Apple. This can be found in [Homebrew](http://brew.sh) or
|
||||
[MacPorts](https://macports.org/).
|
||||
|
||||
The `--disable-maintainer-mode` 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
|
||||
[Flex](http://flex.sourceforge.net/) and
|
||||
[Bison](https://www.gnu.org/software/bison/).
|
||||
|
||||
`flex` and `bison` are used to generate the lexer and parser for
|
||||
jq. For jq 1.5, neither is required if you use `./configure
|
||||
--disable-maintainer-mode` instead of `./configure`. This flag says to use
|
||||
the pre-generated lexer and parser that come with the code.
|
||||
|
||||
#### Building the documentation
|
||||
|
||||
jq's documentation is compiled into static HTML using
|
||||
@@ -110,4 +168,3 @@ body:
|
||||
the YAML docs, and you'll still need the Ruby dependencies to
|
||||
build the manpage.
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ headline: jq Manual (development version)
|
||||
|
||||
history: |
|
||||
|
||||
*For released versions, see [jq 1.4](/jq/manual/v1.4) or
|
||||
[jq 1.3](/jq/manual/v1.3).*
|
||||
*For released versions, see [jq 1.5](/jq/manual/v1.5),
|
||||
[jq 1.4](/jq/manual/v1.4) or [jq 1.3](/jq/manual/v1.3).*
|
||||
|
||||
body: |
|
||||
|
||||
@@ -107,7 +107,7 @@ sections:
|
||||
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 `--seq`
|
||||
RS. This mode also parses the output of jq without the `--seq`
|
||||
option.
|
||||
|
||||
* `--stream`:
|
||||
@@ -237,13 +237,13 @@ sections:
|
||||
|
||||
(This option is like `--slurpfile`, but when the file has just
|
||||
one text, then that is used, else an array of texts is used as
|
||||
in `--slurfile`.)
|
||||
in `--slurpfile`.)
|
||||
|
||||
* `--run-tests [filename]`:
|
||||
|
||||
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 consts of comment lines, empty lines, and
|
||||
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
|
||||
@@ -338,7 +338,7 @@ sections:
|
||||
|
||||
The `.foo` syntax only works for simply keys i.e. keys that
|
||||
are all alphanumeric characters. `.[<string>]` works with
|
||||
keys that contain special charactors such as colons and dots.
|
||||
keys that contain special characters such as colons and dots.
|
||||
For example `.["foo::bar"]` and `.["foo.bar"]` work while
|
||||
`.foo::bar` and `.foo.bar` would not.
|
||||
|
||||
@@ -433,6 +433,7 @@ sections:
|
||||
|
||||
- title: "`|`"
|
||||
body: |
|
||||
|
||||
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
|
||||
@@ -443,11 +444,29 @@ sections:
|
||||
expression `.[] | .foo` retrieves the "foo" field of each
|
||||
element of the input array.
|
||||
|
||||
Note that `.a.b.c` is the same as `.a | .b | .c`.
|
||||
|
||||
Note too that `.` is the input value at the particular stage
|
||||
in a "pipeline", specifically: where the `.` expression appears.
|
||||
Thus `.a | . | .b` is the same as `.a.b`, as the `.` in the
|
||||
middle refers to whatever value `.a` produced.
|
||||
|
||||
examples:
|
||||
- program: '.[] | .name'
|
||||
input: '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]'
|
||||
output: ['"JSON"', '"XML"']
|
||||
|
||||
- title: "Parenthesis"
|
||||
body: |
|
||||
|
||||
Parenthesis work as a grouping operator just as in any typical
|
||||
programming language.
|
||||
|
||||
examples:
|
||||
- program: '(. + 2) * 5'
|
||||
input: '1'
|
||||
output: [15]
|
||||
|
||||
- title: Types and Values
|
||||
body: |
|
||||
|
||||
@@ -598,7 +617,7 @@ sections:
|
||||
body: |
|
||||
|
||||
As well as normal arithmetic subtraction on numbers, the `-`
|
||||
operator can be used on arrays to remove all occurences of
|
||||
operator can be used on arrays to remove all occurrences of
|
||||
the second array's elements from the first array.
|
||||
|
||||
examples:
|
||||
@@ -619,7 +638,7 @@ sections:
|
||||
that string that many times. `"x" * 0` produces **null**.
|
||||
|
||||
Dividing a string by another splits the first using the second
|
||||
as separators.
|
||||
as separators.
|
||||
|
||||
Multiplying two objects will merge them recursively: this works
|
||||
like addition but if both objects contain a value for the
|
||||
@@ -662,6 +681,18 @@ sections:
|
||||
input: '[[1,2], "string", {"a":2}, null]'
|
||||
output: [2, 6, 1, 0]
|
||||
|
||||
|
||||
- title: "`utf8bytelength`"
|
||||
body: |
|
||||
|
||||
The builtin function `utf8bytelength` outputs the number of
|
||||
bytes used to encode a string in UTF-8.
|
||||
|
||||
examples:
|
||||
- program: 'utf8bytelength'
|
||||
input: '"\u03bc"'
|
||||
output: [2]
|
||||
|
||||
- title: "`keys`, `keys_unsorted`"
|
||||
body: |
|
||||
|
||||
@@ -710,12 +741,12 @@ sections:
|
||||
|
||||
- title: "`in`"
|
||||
body: |
|
||||
|
||||
The builtin function `in` returns the input key is in the
|
||||
|
||||
The builtin function `in` 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 `has`.
|
||||
|
||||
|
||||
examples:
|
||||
- program: '.[] | in({"foo": 42})'
|
||||
input: '["foo", "bar"]'
|
||||
@@ -723,13 +754,35 @@ sections:
|
||||
- program: 'map(in([0,1]))'
|
||||
input: '[2, 0]'
|
||||
output: ['[false, true]']
|
||||
|
||||
|
||||
- title: "`map(x)`, `map_values(x)`"
|
||||
body: |
|
||||
|
||||
For any filter `x`, `map(x)` will run that filter for each
|
||||
element of the input array, and return the outputs in a new
|
||||
array. `map(.+1)` will increment each element of an array of numbers.
|
||||
|
||||
Similarly, `map_values(x)` will run that filter for each element,
|
||||
but it will return an object when an object is passed.
|
||||
|
||||
`map(x)` is equivalent to `[.[] | x]`. In fact, this is how
|
||||
it's defined. Similarly, `map_values(x)` is defined as `.[] |= x`.
|
||||
|
||||
examples:
|
||||
- program: 'map(.+1)'
|
||||
input: '[1,2,3]'
|
||||
output: ['[2,3,4]']
|
||||
|
||||
- program: 'map_values(.+1)'
|
||||
input: '{"a": 1, "b": 2, "c": 3}'
|
||||
output: ['{"a": 2, "b": 3, "c": 4}']
|
||||
|
||||
- title: "`path(path_expression)`"
|
||||
body: |
|
||||
|
||||
Outputs array representations of the given path expression
|
||||
in `.`. The outputs are arrays of strings (keys in objects0
|
||||
and/or numbers (array indices.
|
||||
in `.`. The outputs are arrays of strings (object keys)
|
||||
and/or numbers (array indices).
|
||||
|
||||
Path expressions are jq expressions like `.a`, but also `.[]`.
|
||||
There are two types of path expressions: ones that can match
|
||||
@@ -770,6 +823,48 @@ sections:
|
||||
input: '["foo", "bar", "baz"]'
|
||||
output: ['["foo"]']
|
||||
|
||||
- title: "`getpath(PATHS)`"
|
||||
body: |
|
||||
|
||||
The builtin function `getpath` outputs the values in `.` found
|
||||
at each path in `PATHS`.
|
||||
|
||||
examples:
|
||||
- program: 'getpath(["a","b"])'
|
||||
input: 'null'
|
||||
output: ['null']
|
||||
- program: '[getpath(["a","b"], ["a","c"])]'
|
||||
input: '{"a":{"b":0, "c":1}}'
|
||||
output: ['[0, 1]']
|
||||
|
||||
- title: "`setpath(PATHS; VALUE)`"
|
||||
body: |
|
||||
|
||||
The builtin function `setpath` sets the `PATHS` in `.` to `VALUE`.
|
||||
|
||||
examples:
|
||||
- program: 'setpath(["a","b"]; 1)'
|
||||
input: 'null'
|
||||
output: ['{"a": {"b": 1}}']
|
||||
- program: 'setpath(["a","b"]; 1)'
|
||||
input: '{"a":{"b":0}}'
|
||||
output: ['{"a": {"b": 1}}']
|
||||
- program: 'setpath([0,"a"]; 1)'
|
||||
input: 'null'
|
||||
output: ['[{"a":1}]']
|
||||
|
||||
- title: "`delpaths(PATHS)`"
|
||||
body: |
|
||||
|
||||
The builtin function `delpaths` sets the `PATHS` in `.`.
|
||||
`PATHS` must be an array of paths, where each path is an array
|
||||
of strings and numbers.
|
||||
|
||||
examples:
|
||||
- program: 'delpaths([["a","b"]])'
|
||||
input: '{"a":{"b":1},"x":{"y":2}}'
|
||||
output: ['{"a":{},"x":{"y":2}}']
|
||||
|
||||
- title: "`to_entries`, `from_entries`, `with_entries`"
|
||||
body: |
|
||||
|
||||
@@ -782,7 +877,7 @@ sections:
|
||||
`with_entries(foo)` is a shorthand for `to_entries |
|
||||
map(foo) | from_entries`, useful for doing some operation to
|
||||
all keys and values of an object. `from_entries` accepts key, Key,
|
||||
Name, value and Value as keys.
|
||||
name, Name, value and Value as keys.
|
||||
|
||||
examples:
|
||||
- program: 'to_entries'
|
||||
@@ -862,28 +957,6 @@ sections:
|
||||
input: 'null'
|
||||
output: ['"{\"file\":\"<top-level>\",\"line\":1}"']
|
||||
|
||||
- title: "`map(x)`, `map_values(x)`"
|
||||
body: |
|
||||
|
||||
For any filter `x`, `map(x)` will run that filter for each
|
||||
element of the input array, and produce the outputs a new
|
||||
array. `map(.+1)` will increment each element of an array of numbers.
|
||||
|
||||
Similarly, `map_values(x)` will run that filter for each element,
|
||||
but it will return an object when an object is passed.
|
||||
|
||||
`map(x)` is equivalent to `[.[] | x]`. In fact, this is how
|
||||
it's defined. Similarly, `map_values(x)` is defined as `.[] |= x`.
|
||||
|
||||
examples:
|
||||
- program: 'map(.+1)'
|
||||
input: '[1,2,3]'
|
||||
output: ['[2,3,4]']
|
||||
|
||||
- program: 'map_values(.+1)'
|
||||
input: '{"a": 1, "b": 2, "c": 3}'
|
||||
output: ['{"a": 2, "b": 3, "c": 4}']
|
||||
|
||||
- title: "`paths`, `paths(node_filter)`, `leaf_paths`"
|
||||
body: |
|
||||
|
||||
@@ -932,8 +1005,8 @@ sections:
|
||||
body: |
|
||||
|
||||
The filter `any` takes as input an array of boolean values,
|
||||
and produces `true` as output if any of the the elements of
|
||||
the array is `true`.
|
||||
and produces `true` as output if any of the elements of
|
||||
the array are `true`.
|
||||
|
||||
If the input is an empty array, `any` returns `false`.
|
||||
|
||||
@@ -958,7 +1031,7 @@ sections:
|
||||
body: |
|
||||
|
||||
The filter `all` takes as input an array of boolean values,
|
||||
and produces `true` as output if all of the the elements of
|
||||
and produces `true` as output if all of the elements of
|
||||
the array are `true`.
|
||||
|
||||
The `all(condition)` form applies the given condition to the
|
||||
@@ -980,7 +1053,7 @@ sections:
|
||||
input: '[]'
|
||||
output: ["true"]
|
||||
|
||||
- title: "\\[Requires 1.5\\] `flatten`, `flatten(depth)`"
|
||||
- title: "`flatten`, `flatten(depth)`"
|
||||
body: |
|
||||
|
||||
The filter `flatten` takes as input an array of nested arrays,
|
||||
@@ -1386,7 +1459,7 @@ sections:
|
||||
input: '[65, 66, 67]'
|
||||
output: ['"ABC"']
|
||||
|
||||
- title: "`split`"
|
||||
- title: "`split(str)`"
|
||||
body: |
|
||||
|
||||
Splits an input string on the separator argument.
|
||||
@@ -1404,16 +1477,22 @@ sections:
|
||||
running `split("foo") | join("foo")` over any input string
|
||||
returns said input string.
|
||||
|
||||
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.
|
||||
|
||||
examples:
|
||||
- program: 'join(", ")'
|
||||
input: '["a","b,c,d","e"]'
|
||||
output: ['"a, b,c,d, e"']
|
||||
|
||||
- program: 'join(" ")'
|
||||
input: '["a",1,2.3,true,null,false]'
|
||||
output: ['"a 1 2.3 true false"']
|
||||
|
||||
- title: "`ascii_downcase`, `ascii_upcase`"
|
||||
body: |
|
||||
|
||||
Emit a copy of the input string with its alphabetic characters (a-z and A-Z)
|
||||
Emit a copy of the input string with its alphabetic characters (a-z and A-Z)
|
||||
converted to the specified case.
|
||||
|
||||
example:
|
||||
@@ -1522,6 +1601,33 @@ sections:
|
||||
- 4
|
||||
- 16
|
||||
|
||||
- title: "`walk(f)`"
|
||||
body: |
|
||||
|
||||
The `walk(f)` 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.
|
||||
|
||||
examples:
|
||||
- program: 'walk(if type == "array" then sort else . end)'
|
||||
input: '[[4, 1, 7], [8, 5, 2], [3, 6, 9]]'
|
||||
output:
|
||||
- '[[1,4,7],[2,5,8],[3,6,9]]'
|
||||
|
||||
- program: 'walk( if type == "object" then with_entries( .key |= sub( "^_+"; "") ) else . end )'
|
||||
input: '[ { "_a": { "__b": 2 } } ]'
|
||||
output:
|
||||
- '[{"a":{"b":2}}]'
|
||||
|
||||
|
||||
- title: "`..`"
|
||||
body: |
|
||||
|
||||
@@ -1549,7 +1655,7 @@ sections:
|
||||
- title: "`transpose`"
|
||||
body: |
|
||||
|
||||
Transpose a possibly jagged matrix (an array of arrays).
|
||||
Transpose a possibly jagged matrix (an array of arrays).
|
||||
Rows are padded with nulls so the result is always rectangular.
|
||||
|
||||
examples:
|
||||
@@ -1625,7 +1731,7 @@ sections:
|
||||
|
||||
* `@json`:
|
||||
|
||||
Serialises the input as JSON.
|
||||
Serializes the input as JSON.
|
||||
|
||||
* `@html`:
|
||||
|
||||
@@ -1670,12 +1776,12 @@ sections:
|
||||
escaped. However, all interpolations made inside that string
|
||||
literal will be escaped. For instance,
|
||||
|
||||
@uri "http://www.google.com/search?q=\(.search)"
|
||||
@uri "https://www.google.com/search?q=\(.search)"
|
||||
|
||||
will produce the following output for the input
|
||||
`{"search":"what is jq?"}`:
|
||||
|
||||
"http://www.google.com/search?q=what%20is%20jq%3F"
|
||||
"https://www.google.com/search?q=what%20is%20jq%3F"
|
||||
|
||||
Note that the slashes, question mark, etc. in the URL are
|
||||
not escaped, as they were part of the string literal.
|
||||
@@ -1760,6 +1866,46 @@ sections:
|
||||
input: '"2015-03-05T23:51:47Z"'
|
||||
output: ['1425599507']
|
||||
|
||||
- title: "SQL-Style Operators"
|
||||
body: |
|
||||
|
||||
jq provides a few SQL-style operators.
|
||||
|
||||
* INDEX(stream; index_expression):
|
||||
|
||||
This builtin produces an object whose keys are computed by
|
||||
the given index expression applied to each value from the
|
||||
given stream.
|
||||
|
||||
* JOIN($idx; stream; idx_expr; join_expr):
|
||||
|
||||
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.
|
||||
|
||||
* JOIN($idx; stream; idx_expr):
|
||||
|
||||
Same as `JOIN($idx; stream; idx_expr; .)`.
|
||||
|
||||
* JOIN($idx; idx_expr):
|
||||
|
||||
This builtin joins the input `.` to the given index, applying
|
||||
the given index expression to `.` to compute the index key.
|
||||
The join operation is as described above.
|
||||
|
||||
* IN(s):
|
||||
|
||||
This builtin outputs `true` if `.` appears in the given
|
||||
stream, otherwise it outputs `false`.
|
||||
|
||||
* IN(source; s):
|
||||
|
||||
This builtin outputs `true` if any value in the source stream
|
||||
appears in the second stream, otherwise it outputs `false`.
|
||||
|
||||
- title: Conditionals and Comparisons
|
||||
entries:
|
||||
- title: "`==`, `!=`"
|
||||
@@ -1794,9 +1940,9 @@ sections:
|
||||
need something more like `if (.name | length) > 0 then A else
|
||||
B end` instead.
|
||||
|
||||
If the condition A produces multiple results, it is
|
||||
considered "true" if any of those results is not false or
|
||||
null. If it produces zero results, it's considered false.
|
||||
If the condition `A` produces multiple results, then `B` is evaluated
|
||||
once for each result that is not false or null, and `C` is evaluated
|
||||
once for each false or null.
|
||||
|
||||
More cases can be added to an if using `elif A then B` syntax.
|
||||
|
||||
@@ -1996,7 +2142,7 @@ sections:
|
||||
evaluates to: true, true, false, false.
|
||||
|
||||
entries:
|
||||
- title: "\\[Requires 1.5\\] `test(val)`, `test(regex; flags)`"
|
||||
- title: "`test(val)`, `test(regex; flags)`"
|
||||
body: |
|
||||
|
||||
Like `match`, but does not return match objects, only `true` or `false`
|
||||
@@ -2010,7 +2156,7 @@ sections:
|
||||
input: '["xabcd", "ABC"]'
|
||||
output: ['true', 'true']
|
||||
|
||||
- title: "\\[Requires 1.5\\] `match(val)`, `match(regex; flags)`"
|
||||
- title: "`match(val)`, `match(regex; flags)`"
|
||||
body: |
|
||||
|
||||
**match** outputs an object for each match it finds. Matches have
|
||||
@@ -2055,7 +2201,7 @@ sections:
|
||||
output: [3]
|
||||
|
||||
|
||||
- title: "\\[Requires 1.5\\] `capture(val)`, `capture(regex; flags)`"
|
||||
- title: "`capture(val)`, `capture(regex; flags)`"
|
||||
body: |
|
||||
|
||||
Collects the named captures in a JSON object, with the name
|
||||
@@ -2067,7 +2213,7 @@ sections:
|
||||
input: '"xyzzy-14"'
|
||||
output: ['{ "a": "xyzzy", "n": "14" }']
|
||||
|
||||
- title: "\\[Requires 1.5\\] `scan(regex)`, `scan(regex; flags)`"
|
||||
- title: "`scan(regex)`, `scan(regex; flags)`"
|
||||
body: |
|
||||
|
||||
Emit a stream of the non-overlapping substrings of the input
|
||||
@@ -2096,7 +2242,7 @@ sections:
|
||||
output: ['"ab","cd","ef"']
|
||||
|
||||
|
||||
- title: "\\[Requires 1.5\\] `splits(regex)`, `splits(regex; flags)`"
|
||||
- title: "`splits(regex)`, `splits(regex; flags)`"
|
||||
body: |
|
||||
|
||||
These provide the same results as their `split` counterparts,
|
||||
@@ -2107,7 +2253,7 @@ sections:
|
||||
input: '("ab,cd", "ef, gh")'
|
||||
output: ['"ab"', '"cd"', '"ef"', '"gh"']
|
||||
|
||||
- title: "\\[Requires 1.5\\] `sub(regex; tostring)` `sub(regex; string; flags)`"
|
||||
- title: "`sub(regex; tostring)` `sub(regex; string; flags)`"
|
||||
body: |
|
||||
|
||||
Emit the string obtained by replacing the first match of regex in the
|
||||
@@ -2123,7 +2269,7 @@ sections:
|
||||
output: '"ZabcZabc"'
|
||||
|
||||
|
||||
- title: "\\[Requires 1.5\\] `gsub(regex; string)`, `gsub(regex; string; flags)`"
|
||||
- title: "`gsub(regex; string)`, `gsub(regex; string; flags)`"
|
||||
body: |
|
||||
|
||||
`gsub` is like `sub` but all the non-overlapping occurrences of the regex are
|
||||
@@ -2274,17 +2420,17 @@ sections:
|
||||
def increment: . + 1;
|
||||
|
||||
From then on, `increment` is usable as a filter just like a
|
||||
builtin function (in fact, this is how some of the builtins
|
||||
builtin function (in fact, this is how many of the builtins
|
||||
are defined). A function may take arguments:
|
||||
|
||||
def map(f): [.[] | f];
|
||||
|
||||
Arguments are passed as filters, not as values. The
|
||||
same argument may be referenced multiple times with
|
||||
different inputs (here `f` 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:
|
||||
Arguments are passed as _filters_ (functions with no
|
||||
arguments), _not_ as values. The same argument may be
|
||||
referenced multiple times with different inputs (here `f` 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:
|
||||
|
||||
def foo(f): f|f;
|
||||
5|foo(.*2)
|
||||
@@ -2305,12 +2451,16 @@ sections:
|
||||
def addvalue($f): ...;
|
||||
|
||||
With either definition, `addvalue(.foo)` will add the current
|
||||
input's `.foo` field to each element of the array.
|
||||
input's `.foo` field to each element of the array. Do note
|
||||
that calling `addvalue(.[])` will cause the `map(. + $f)` part
|
||||
to be evaluated once per value in the value of `.` at the call
|
||||
site.
|
||||
|
||||
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.
|
||||
|
||||
examples:
|
||||
- program: 'def addvalue(f): . + [f]; map(addvalue(.[0]))'
|
||||
@@ -2320,6 +2470,23 @@ sections:
|
||||
input: '[[1,2],[10,20]]'
|
||||
output: ['[[1,2,1,2], [10,20,1,2]]']
|
||||
|
||||
- title: 'Scoping'
|
||||
body: |
|
||||
|
||||
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.
|
||||
|
||||
For example, in the following expression there is a binding
|
||||
which is visible "to the right" of it, `... | .*3 as
|
||||
$times_three | [. + $times_three] | ...`, but not "to the
|
||||
left". Consider this expression now, `... | (.*3 as
|
||||
$times_three | [.+ $times_three]) | ...`: here the binding
|
||||
`$times_three` is _not_ visible past the closing parenthesis.
|
||||
|
||||
- title: Reduce
|
||||
body: |
|
||||
|
||||
@@ -2338,10 +2505,18 @@ sections:
|
||||
(2 as $item | . + $item) |
|
||||
(1 as $item | . + $item)
|
||||
|
||||
If the reduction update expression outputs `empty` (that is,
|
||||
no values), then the reduction state is left as-is. For
|
||||
example, `reduce range(4) as $n ({}; if .==2 then empty else
|
||||
.[$n|tostring] |= $n)` will produce `{"0":0,"1":1,"3":3}`.
|
||||
|
||||
examples:
|
||||
- program: 'reduce .[] as $item (0; . + $item)'
|
||||
input: '[10,2,5,3]'
|
||||
output: ['20']
|
||||
- program: 'reduce .[] as $n ([]; if $n%2==0 then empty else . + [$n] end)'
|
||||
input: '[0,1,2,3,4,5]'
|
||||
output: ['[1,3,5]']
|
||||
|
||||
- title: "`limit(n; exp)`"
|
||||
body: |
|
||||
@@ -2416,7 +2591,7 @@ sections:
|
||||
function can be recursive. The `while` builtin is also
|
||||
implemented in terms of recursion.
|
||||
|
||||
Tail calls are optmized whenever the expression to the left of
|
||||
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.
|
||||
@@ -2494,13 +2669,30 @@ sections:
|
||||
that take a single input argument (e.g., `sin()`) are available as
|
||||
zero-argument jq functions. C math functions that take two input
|
||||
arguments (e.g., `pow()`) are available as two-argument jq
|
||||
functions that ignore `.`.
|
||||
functions that ignore `.`. C math functions that take three input
|
||||
arguments are available as three-argument jq functions that ignore
|
||||
`.`.
|
||||
|
||||
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.
|
||||
|
||||
One-input C math functions: `acos` `acosh` `asin` `asinh` `atan`
|
||||
`atanh` `cbrt` `ceil` `cos` `cosh` `erf` `erfc` `exp` `exp10`
|
||||
`exp2` `expm1` `fabs` `floor` `gamma` `j0` `j1` `lgamma` `log`
|
||||
`log10` `log1p` `log2` `logb` `nearbyint` `pow10` `rint` `round`
|
||||
`significand` `sin` `sinh` `sqrt` `tan` `tanh` `tgamma` `trunc`
|
||||
`y0` `y1`.
|
||||
|
||||
Two-input C math functions: `atan2` `copysign` `drem` `fdim`
|
||||
`fmax` `fmin` `fmod` `frexp` `hypot` `jn` `ldexp` `modf`
|
||||
`nextafter` `nexttoward` `pow` `remainder` `scalb` `scalbln` `yn`.
|
||||
|
||||
Three-input C math functions: `fma`.
|
||||
|
||||
See your system's manual for more information on each of these.
|
||||
|
||||
- title: 'I/O'
|
||||
body: |
|
||||
|
||||
@@ -2517,6 +2709,10 @@ sections:
|
||||
application-specific behavior, such as for executables that use
|
||||
the libjq C API but aren't the jq executable itself.
|
||||
|
||||
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.
|
||||
|
||||
entries:
|
||||
- title: "`input`"
|
||||
body: |
|
||||
@@ -2562,11 +2758,11 @@ sections:
|
||||
|
||||
However, streaming isn't easy to deal with as the jq program will
|
||||
have `[<path>, <leaf-value>]` (and a few other forms) as inputs.
|
||||
|
||||
|
||||
Several builtins are provided to make handling streams easier.
|
||||
|
||||
The examples below use the the streamed form of `[0,[1]]`, which
|
||||
is `[[0],1],[[1,0],2],[[1,0]],[[1]])]`.
|
||||
The examples below use the streamed form of `[0,[1]]`, which is
|
||||
`[[0],0],[[1,0],1],[[1,0]],[[1]]`.
|
||||
|
||||
Streaming forms include `[<path>, <leaf-value>]` (to indicate any
|
||||
scalar value, empty array, or empty object), and `[<path>]` (to
|
||||
@@ -2625,6 +2821,18 @@ sections:
|
||||
of every object before it does the assignment (for performance,
|
||||
it doesn't actually do that, but that's the general idea).
|
||||
|
||||
All the assignment operators in jq have path expressions on the
|
||||
left-hand side.
|
||||
|
||||
Values in jq are always immutable. Internally, assignment works
|
||||
by using a reduction to compute new, replacement values for `.` that
|
||||
have had all the desired assignments applied to `.`, then
|
||||
outputting the modified value. This might be made clear by this
|
||||
example: `{a:{b:{c:1}}} | (.a.b|=3), .`. This will output
|
||||
`{"a":{"b":3}}` and `{"a":{"b":{"c":1}}}` because the last
|
||||
sub-expression, `.`, sees the original value, not the modified
|
||||
value.
|
||||
|
||||
entries:
|
||||
- title: "`=`"
|
||||
body: |
|
||||
@@ -2651,9 +2859,20 @@ sections:
|
||||
can produce can be represented in JSON.
|
||||
|
||||
Note that the left-hand side of '=' refers to a value in `.`.
|
||||
Thus `$var.foo = 1` won't work as expected; use `$var | .foo =
|
||||
Thus `$var.foo = 1` won't work as expected (`$var.foo` is not
|
||||
a valid or useful path expression in `.`); use `$var | .foo =
|
||||
1` instead.
|
||||
|
||||
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 `.`.
|
||||
For example, `(.a,.b)=range(2)` outputs `{"a":0,"b":0}`, then
|
||||
`{"a":1,"b":1}`. The "update" assignment forms (see below) do
|
||||
not do this.
|
||||
|
||||
Note too that `.a,.b=0` does not set `.a` and `.b`, but
|
||||
`(.a,.b)=0` sets both.
|
||||
|
||||
- title: "`|=`"
|
||||
body: |
|
||||
As well as the assignment operator '=', jq provides the "update"
|
||||
@@ -2677,9 +2896,17 @@ sections:
|
||||
The left-hand side can be any general path expression; see `path()`.
|
||||
|
||||
Note that the left-hand side of '|=' refers to a value in `.`.
|
||||
Thus `$var.foo |= . + 1` won't work as expected; use `$var |
|
||||
Thus `$var.foo |= . + 1` won't work as expected (`$var.foo` is
|
||||
not a valid or useful path expression in `.`); use `$var |
|
||||
.foo |= . + 1` instead.
|
||||
|
||||
If the right-hand side outputs no values (i.e., `empty`), then
|
||||
the left-hand side path will be deleted, as with `del(path)`.
|
||||
|
||||
If the right-hand side outputs multiple values, only the first
|
||||
one will be used (NOTE: it used to be that only the last one was
|
||||
used).
|
||||
|
||||
examples:
|
||||
|
||||
- program: '(..|select(type=="boolean")) |= if . then 1 else 0 end'
|
||||
@@ -2797,7 +3024,7 @@ sections:
|
||||
this time jq only uses the "search" key/value of the metadata.
|
||||
The metadata is also made available to users via the
|
||||
`modulemeta` builtin.
|
||||
|
||||
|
||||
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.
|
||||
@@ -2830,7 +3057,7 @@ sections:
|
||||
this time jq only uses the "search" key/value of the metadata.
|
||||
The metadata is also made available to users via the
|
||||
`modulemeta` builtin.
|
||||
|
||||
|
||||
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.
|
||||
|
||||
@@ -16,7 +16,7 @@ body: |
|
||||
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.
|
||||
|
||||
|
||||
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
|
||||
@@ -50,7 +50,7 @@ manpage_intro: |
|
||||
By default, `jq` reads a stream of JSON objects (whitespace
|
||||
separated) from `stdin`. One or more <files> may be specified, in
|
||||
which case `jq` will read input from those instead.
|
||||
|
||||
|
||||
The <options> are described in the [INVOKING JQ] section, they
|
||||
mostly concern input and output formatting. The <filter> is written
|
||||
in the jq language and specifies how to transform the input
|
||||
@@ -68,11 +68,11 @@ manpage_epilogue: |
|
||||
## AUTHOR
|
||||
|
||||
Stephen Dolan `<mu@netsoc.tcd.ie>`
|
||||
|
||||
|
||||
sections:
|
||||
- title: Invoking jq
|
||||
body: |
|
||||
|
||||
|
||||
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
|
||||
@@ -83,46 +83,46 @@ sections:
|
||||
using some command-line options:
|
||||
|
||||
* `--slurp`/`-s`:
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
* `--raw-input`/`-R`:
|
||||
|
||||
|
||||
Don't parse the input as JSON. Instead, each line of text is
|
||||
passed to the filter as a string. If combined with `--slurp`,
|
||||
then the entire input is passed to the filter as a single long
|
||||
string.
|
||||
|
||||
|
||||
* `--null-input`/`-n`:
|
||||
|
||||
|
||||
Don't read any input at all! Instead, the filter is run once
|
||||
using `null` as the input. This is useful when using jq as a
|
||||
simple calculator or to construct JSON data from scratch.
|
||||
|
||||
|
||||
* `--compact-output` / `-c`:
|
||||
|
||||
|
||||
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.
|
||||
|
||||
* `--colour-output` / `-C` and `--monochrome-output` / `-M`:
|
||||
|
||||
|
||||
* `--color-output` / `-C` and `--monochrome-output` / `-M`:
|
||||
|
||||
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 `-C`, and disable color with `-M`.
|
||||
|
||||
|
||||
* `--ascii-output` / `-a`:
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
* `--raw-output` / `-r`:
|
||||
|
||||
|
||||
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
|
||||
@@ -138,7 +138,7 @@ sections:
|
||||
entries:
|
||||
- title: "`.`"
|
||||
body: |
|
||||
|
||||
|
||||
The absolute simplest (and least interesting) filter
|
||||
is `.`. This is a filter that takes its input and
|
||||
produces it unchanged as output.
|
||||
@@ -154,7 +154,7 @@ sections:
|
||||
|
||||
- title: "`.foo`"
|
||||
body: |
|
||||
|
||||
|
||||
The simplest *useful* 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.
|
||||
@@ -169,7 +169,7 @@ sections:
|
||||
|
||||
- title: "`.[foo]`, `.[2]`, `.[10:15]`"
|
||||
body: |
|
||||
|
||||
|
||||
You can also look up fields of an object using syntax like
|
||||
`.["foo"]` (.foo above is a shorthand version of this). This
|
||||
one works for arrays as well, if the key is an
|
||||
@@ -195,7 +195,7 @@ sections:
|
||||
- program: '.[2:4]'
|
||||
input: '["a","b","c","d","e"]'
|
||||
output: ['["c", "d"]']
|
||||
|
||||
|
||||
- program: '.[:3]'
|
||||
input: '["a","b","c","d","e"]'
|
||||
output: ['["a", "b", "c"]']
|
||||
@@ -206,7 +206,7 @@ sections:
|
||||
|
||||
- title: "`.[]`"
|
||||
body: |
|
||||
|
||||
|
||||
If you use the `.[foo]` syntax, but omit the index
|
||||
entirely, it will return *all* of the elements of an
|
||||
array. Running `.[]` with the input `[1,2,3]` will produce the
|
||||
@@ -233,7 +233,7 @@ sections:
|
||||
|
||||
- title: "`,`"
|
||||
body: |
|
||||
|
||||
|
||||
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
|
||||
@@ -248,18 +248,18 @@ sections:
|
||||
|
||||
- program: ".user, .projects[]"
|
||||
input: '{"user":"stedolan", "projects": ["jq", "wikiflow"]}'
|
||||
output: ['"stedolan"', '"jq"', '"wikiflow"']
|
||||
|
||||
output: ['"stedolan"', '"jq"', '"wikiflow"']
|
||||
|
||||
- program: '.[4,2]'
|
||||
input: '["a","b","c","d","e"]'
|
||||
output: ['"e"', '"c"']
|
||||
|
||||
|
||||
- title: "`|`"
|
||||
body: |
|
||||
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.
|
||||
that.
|
||||
|
||||
If the one on the left produces multiple results, the one on
|
||||
the right will be run for each of those results. So, the
|
||||
@@ -273,7 +273,7 @@ sections:
|
||||
|
||||
- title: Types and Values
|
||||
body: |
|
||||
|
||||
|
||||
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".
|
||||
@@ -287,7 +287,7 @@ sections:
|
||||
entries:
|
||||
- title: Array construction - `[]`
|
||||
body: |
|
||||
|
||||
|
||||
As in JSON, `[]` is used to construct arrays, as in
|
||||
`[1,2,3]`. The elements of the arrays can be any jq
|
||||
expression. All of the results produced by all of the
|
||||
@@ -295,7 +295,7 @@ sections:
|
||||
to construct an array out of a known quantity of values (as
|
||||
in `[.foo, .bar, .baz]`) or to "collect" all the results of a
|
||||
filter into an array (as in `[.items[].name]`)
|
||||
|
||||
|
||||
Once you understand the "," operator, you can look at jq's array
|
||||
syntax in a different light: the expression `[1,2,3]` is not using a
|
||||
built-in syntax for comma-separated arrays, but is instead applying
|
||||
@@ -315,49 +315,49 @@ sections:
|
||||
|
||||
Like JSON, `{}` is for constructing objects (aka
|
||||
dictionaries or hashes), as in: `{"a": 42, "b": 17}`.
|
||||
|
||||
|
||||
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).
|
||||
|
||||
|
||||
{foo: .bar}
|
||||
|
||||
|
||||
will produce the JSON object `{"foo": 42}` if given the JSON
|
||||
object `{"bar":42, "baz":43}`. 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
|
||||
|
||||
|
||||
{user: .user, title: .title}
|
||||
|
||||
|
||||
Because that's so common, there's a shortcut syntax: `{user, title}`.
|
||||
|
||||
|
||||
If one of the expressions produces multiple results,
|
||||
multiple dictionaries will be produced. If the input's
|
||||
|
||||
|
||||
{"user":"stedolan","titles":["JQ Primer", "More JQ"]}
|
||||
|
||||
|
||||
then the expression
|
||||
|
||||
|
||||
{user, title: .titles[]}
|
||||
|
||||
will produce two outputs:
|
||||
|
||||
|
||||
will produce two outputs:
|
||||
|
||||
{"user":"stedolan", "title": "JQ Primer"}
|
||||
{"user":"stedolan", "title": "More JQ"}
|
||||
|
||||
|
||||
Putting parentheses around the key means it will be evaluated as an
|
||||
expression. With the same input as above,
|
||||
|
||||
|
||||
{(.user): .titles}
|
||||
|
||||
|
||||
produces
|
||||
|
||||
|
||||
{"stedolan": ["JQ Primer", "More JQ"]}
|
||||
|
||||
|
||||
examples:
|
||||
- program: '{user, title: .titles[]}'
|
||||
input: '{"user":"stedolan","titles":["JQ Primer", "More JQ"]}'
|
||||
@@ -376,7 +376,7 @@ sections:
|
||||
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.
|
||||
|
||||
|
||||
entries:
|
||||
- title: Addition - `+`
|
||||
body: |
|
||||
@@ -390,12 +390,12 @@ sections:
|
||||
- **Arrays** are added by being concatenated into a larger array.
|
||||
|
||||
- **Strings** are added by being joined into a larger string.
|
||||
|
||||
|
||||
- **Objects** 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 `+` wins.
|
||||
|
||||
|
||||
`null` can be added to any value, and returns the other
|
||||
value unchanged.
|
||||
|
||||
@@ -464,7 +464,7 @@ sections:
|
||||
|
||||
- title: `keys`
|
||||
body: |
|
||||
|
||||
|
||||
The builtin function `keys`, when given an object, returns
|
||||
its keys in an array.
|
||||
|
||||
@@ -487,7 +487,7 @@ sections:
|
||||
|
||||
- title: `has`
|
||||
body: |
|
||||
|
||||
|
||||
The builtin function `has` returns whether the input object
|
||||
has the given key, or the input array has an element at the
|
||||
given index.
|
||||
@@ -506,11 +506,11 @@ sections:
|
||||
|
||||
- title: `to_entries`, `from_entries`, `with_entries`
|
||||
body: |
|
||||
|
||||
|
||||
These functions convert between an object and an array of
|
||||
key-value pairs. If `to_entries` is passed an object, then
|
||||
for each `k: v` entry in the input, the output array
|
||||
includes `{"key": k, "value": v}`.
|
||||
includes `{"key": k, "value": v}`.
|
||||
|
||||
`from_entries` does the opposite conversion, and
|
||||
`with_entries(foo)` is a shorthand for `to_entries |
|
||||
@@ -531,7 +531,7 @@ sections:
|
||||
|
||||
- title: `select`
|
||||
body: |
|
||||
|
||||
|
||||
The function `select(foo)` produces its input unchanged if
|
||||
`foo` returns true for that input, and produces no output
|
||||
otherwise.
|
||||
@@ -546,7 +546,7 @@ sections:
|
||||
|
||||
- title: `empty`
|
||||
body: |
|
||||
|
||||
|
||||
`empty` returns no results. None at all. Not even `null`.
|
||||
|
||||
It's useful on occasion. You'll know if you need it :)
|
||||
@@ -598,10 +598,10 @@ sections:
|
||||
|
||||
- title: `range`
|
||||
body: |
|
||||
|
||||
|
||||
The `range` function produces a range of numbers. `range(4;10)`
|
||||
produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers
|
||||
are produced as separate outputs. Use `[range(4;10)]` to get a range as
|
||||
are produced as separate outputs. Use `[range(4;10)]` to get a range as
|
||||
an array.
|
||||
|
||||
examples:
|
||||
@@ -611,7 +611,7 @@ sections:
|
||||
- program: '[range(2;4)]'
|
||||
input: 'null'
|
||||
output: ['[2,3]']
|
||||
|
||||
|
||||
- title: `tonumber`
|
||||
body: |
|
||||
|
||||
@@ -638,7 +638,7 @@ sections:
|
||||
|
||||
- title: `type`
|
||||
body: |
|
||||
|
||||
|
||||
The `type` function returns the type of its argument as a
|
||||
string, which is one of null, boolean, number, string, array
|
||||
or object.
|
||||
@@ -650,7 +650,7 @@ sections:
|
||||
|
||||
- title: `sort, sort_by`
|
||||
body: |
|
||||
|
||||
|
||||
The `sort` functions sorts its input, which must be an
|
||||
array. Values are sorted in the following order:
|
||||
|
||||
@@ -682,7 +682,7 @@ sections:
|
||||
|
||||
- title: `group_by`
|
||||
body: |
|
||||
|
||||
|
||||
`group_by(.foo)` takes as input an array, groups the
|
||||
elements having the same `.foo` field into separate arrays,
|
||||
and produces all of these arrays as elements of a larger
|
||||
@@ -699,7 +699,7 @@ sections:
|
||||
|
||||
- title: `min`, `max`, `min_by`, `max_by`
|
||||
body: |
|
||||
|
||||
|
||||
Find the minimum or maximum element of the input array. The
|
||||
`_by` versions allow you to specify a particular field or
|
||||
property to examine, e.g. `min_by(.foo)` finds the object
|
||||
@@ -715,7 +715,7 @@ sections:
|
||||
|
||||
- title: `unique`
|
||||
body: |
|
||||
|
||||
|
||||
The `unique` function takes as input an array and produces
|
||||
an array of the same elements, in sorted order, with
|
||||
duplicates removed.
|
||||
@@ -727,7 +727,7 @@ sections:
|
||||
|
||||
- title: `reverse`
|
||||
body: |
|
||||
|
||||
|
||||
This function reverses an array.
|
||||
|
||||
examples:
|
||||
@@ -766,7 +766,7 @@ sections:
|
||||
|
||||
- title: `recurse`
|
||||
body: |
|
||||
|
||||
|
||||
The `recurse` function allows you to search through a
|
||||
recursive structure, and extract interesting data from all
|
||||
levels. Suppose your input represents a filesystem:
|
||||
@@ -778,7 +778,7 @@ sections:
|
||||
{"name": "/home", "children": [
|
||||
{"name": "/home/stephen", "children": [
|
||||
{"name": "/home/stephen/jq", "children": []}]}]}]}
|
||||
|
||||
|
||||
Now suppose you want to extract all of the filenames
|
||||
present. You need to retrieve `.name`, `.children[].name`,
|
||||
`.children[].children[].name`, and so on. You can do this
|
||||
@@ -789,7 +789,7 @@ sections:
|
||||
examples:
|
||||
- program: 'recurse(.foo[])'
|
||||
input: '{"foo":[{"foo": []}, {"foo":[{"foo":[]}]}]}'
|
||||
output:
|
||||
output:
|
||||
- '{"foo":[{"foo":[]},{"foo":[{"foo":[]}]}]}'
|
||||
- '{"foo":[]}'
|
||||
- '{"foo":[{"foo":[]}]}'
|
||||
@@ -807,7 +807,7 @@ sections:
|
||||
- program: '"The input was \(.), which is one less than \(.+1)"'
|
||||
input: '42'
|
||||
output: ['"The input was 42, which is one less than 43"']
|
||||
|
||||
|
||||
- title: "Format strings and escaping"
|
||||
body: |
|
||||
|
||||
@@ -836,17 +836,17 @@ sections:
|
||||
characters to a `%xx` sequence.
|
||||
|
||||
* `@csv`:
|
||||
|
||||
|
||||
The input must be an array, and it is rendered as CSV
|
||||
with double quotes for strings, and quotes escaped by
|
||||
repetition.
|
||||
|
||||
* `@sh`:
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
* `@base64`:
|
||||
|
||||
The input is converted to base64 as specified by RFC 4648.
|
||||
@@ -857,12 +857,12 @@ sections:
|
||||
escaped. However, all interpolations made inside that string
|
||||
literal will be escaped. For instance,
|
||||
|
||||
@uri "http://www.google.com/search?q=\(.search)"
|
||||
@uri "https://www.google.com/search?q=\(.search)"
|
||||
|
||||
will produce the following output for the input
|
||||
`{"search":"jq!"}`:
|
||||
|
||||
http://www.google.com/search?q=jq%21
|
||||
https://www.google.com/search?q=jq%21
|
||||
|
||||
Note that the slashes, question mark, etc. in the URL are
|
||||
not escaped, as they were part of the string literal.
|
||||
@@ -879,7 +879,7 @@ sections:
|
||||
- program: '@sh "echo \(.)"'
|
||||
input: "\"O'Hara's Ale\""
|
||||
output: ["\"echo 'O'\\\\''Hara'\\\\''s Ale'\""]
|
||||
|
||||
|
||||
- title: Conditionals and Comparisons
|
||||
entries:
|
||||
- title: `==`, `!=`
|
||||
@@ -891,7 +891,7 @@ sections:
|
||||
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.
|
||||
|
||||
|
||||
!= is "not equal", and 'a != b' returns the opposite value of 'a == b'
|
||||
|
||||
examples:
|
||||
@@ -904,7 +904,7 @@ sections:
|
||||
`if A then B else C end` will act the same as `B` if `A`
|
||||
produces a value other than false or null, but act the same
|
||||
as `C` otherwise.
|
||||
|
||||
|
||||
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
|
||||
@@ -912,11 +912,11 @@ sections:
|
||||
string is empty using `if .name then A else B end`, you'll
|
||||
need something more like `if (.name | count) > 0 then A else
|
||||
B end` instead.
|
||||
|
||||
If the condition A produces multiple results, it is
|
||||
considered "true" if any of those results is not false or
|
||||
null. If it produces zero results, it's considered false.
|
||||
|
||||
|
||||
If the condition `A` produces multiple results, then `B` is evaluated
|
||||
once for each result that is not false or null, and `C` is evaluated
|
||||
once for each false or null.
|
||||
|
||||
More cases can be added to an if using `elif A then B` syntax.
|
||||
|
||||
examples:
|
||||
@@ -930,10 +930,10 @@ sections:
|
||||
end
|
||||
input: 2
|
||||
output: ['"many"']
|
||||
|
||||
|
||||
- title: `>, >=, <=, <`
|
||||
body: |
|
||||
|
||||
|
||||
The comparison operators `>`, `>=`, `<=`, `<` return whether
|
||||
their left argument is greater than, greater than or equal
|
||||
to, less than or equal to or less than their right argument
|
||||
@@ -960,14 +960,14 @@ sections:
|
||||
so it is called as a filter to which things can be piped
|
||||
rather than with special syntax, as in `.foo and .bar |
|
||||
not`.
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
examples:
|
||||
- program: '42 and "a string"'
|
||||
input: 'null'
|
||||
@@ -1005,7 +1005,7 @@ sections:
|
||||
- program: '.foo // 42'
|
||||
input: '{}'
|
||||
output: [42]
|
||||
|
||||
|
||||
- title: Advanced features
|
||||
body: |
|
||||
Variables are an absolute necessity in most programming languages, but
|
||||
@@ -1030,67 +1030,67 @@ sections:
|
||||
entries:
|
||||
- title: Variables
|
||||
body: |
|
||||
|
||||
|
||||
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 `a + b`, pass their input
|
||||
to two distinct subexpressions (here `a` and `b` are both passed the
|
||||
same input), so variables aren't usually necessary in order to use a
|
||||
value twice.
|
||||
|
||||
|
||||
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 `add / length` - the `add` expression is given the array and
|
||||
produces its sum, and the `length` expression is given the array and
|
||||
produces its length.
|
||||
|
||||
|
||||
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 `expression as $variable`. All
|
||||
variable names start with `$`. Here's a slightly uglier version of the
|
||||
array-averaging example:
|
||||
|
||||
|
||||
length as $array_length | add / $array_length
|
||||
|
||||
|
||||
We'll need a more complicated problem to find a situation where using
|
||||
variables actually makes our lives easier.
|
||||
|
||||
|
||||
|
||||
|
||||
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:
|
||||
|
||||
|
||||
{"posts": [{"title": "Frist psot", "author": "anon"},
|
||||
{"title": "A well-written article", "author": "person1"}],
|
||||
"realnames": {"anon": "Anonymous Coward",
|
||||
"person1": "Person McPherson"}}
|
||||
|
||||
|
||||
We want to produce the posts with the author field containing a real
|
||||
name, as in:
|
||||
|
||||
|
||||
{"title": "Frist psot", "author": "Anonymous Coward"}
|
||||
{"title": "A well-written article", "author": "Person McPherson"}
|
||||
|
||||
|
||||
We use a variable, $names, to store the realnames object, so that we
|
||||
can refer to it later when looking up author usernames:
|
||||
|
||||
|
||||
.realnames as $names | .posts[] | {title, author: $names[.author]}
|
||||
|
||||
|
||||
The expression `exp as $x | ...` means: for each value of expression
|
||||
`exp`, run the rest of the pipeline with the entire original input, and
|
||||
with `$x` set to that value. Thus `as` functions as something of a
|
||||
with `$x` set to that value. Thus `as` functions as something of a
|
||||
foreach loop.
|
||||
|
||||
Variables are scoped over the rest of the expression that defines
|
||||
them, so
|
||||
|
||||
them, so
|
||||
|
||||
.realnames as $names | (.posts[] | {title, author: $names[.author]})
|
||||
|
||||
will work, but
|
||||
|
||||
|
||||
will work, but
|
||||
|
||||
(.realnames as $names | .posts[]) | {title, author: $names[.author]}
|
||||
|
||||
|
||||
won't.
|
||||
|
||||
examples:
|
||||
@@ -1100,11 +1100,11 @@ sections:
|
||||
|
||||
- title: 'Defining Functions'
|
||||
body: |
|
||||
|
||||
|
||||
You can give a filter a name using "def" syntax:
|
||||
|
||||
def increment: . + 1;
|
||||
|
||||
|
||||
From then on, `increment` 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:
|
||||
@@ -1135,19 +1135,19 @@ sections:
|
||||
|
||||
- title: Reduce
|
||||
body: |
|
||||
|
||||
|
||||
The `reduce` 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 `[3,2,1]` to this expression:
|
||||
|
||||
reduce .[] as $item (0; . + $item)
|
||||
|
||||
|
||||
For each result that `.[]` produces, `. + $item` is run to
|
||||
accumulate a running total, starting from 0. In this
|
||||
example, `.[]` produces the results 3, 2, and 1, so the
|
||||
effect is similar to running something like this:
|
||||
|
||||
0 | (3 as $item | . + $item) |
|
||||
0 | (3 as $item | . + $item) |
|
||||
(2 as $item | . + $item) |
|
||||
(1 as $item | . + $item)
|
||||
|
||||
@@ -1155,7 +1155,7 @@ sections:
|
||||
- program: 'reduce .[] as $item (0; . + $item)'
|
||||
input: '[10,2,5,3]'
|
||||
output: ['20']
|
||||
|
||||
|
||||
|
||||
- title: Assignment
|
||||
body: |
|
||||
@@ -1177,14 +1177,14 @@ sections:
|
||||
entries:
|
||||
- title: "`=`"
|
||||
body: |
|
||||
|
||||
|
||||
The filter `.foo = 1` 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,
|
||||
|
||||
|
||||
.foo = .bar | .foo.baz = 1
|
||||
|
||||
|
||||
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
|
||||
@@ -1193,7 +1193,7 @@ sections:
|
||||
"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.
|
||||
|
||||
|
||||
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
|
||||
@@ -1206,14 +1206,14 @@ sections:
|
||||
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.
|
||||
|
||||
|
||||
This example should show the difference between '=' and '|=':
|
||||
|
||||
|
||||
Provide input '{"a": {"b": 10}, "b": 20}' to the programs:
|
||||
|
||||
|
||||
.a = .b
|
||||
.a |= .b
|
||||
|
||||
|
||||
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}.
|
||||
@@ -1228,43 +1228,43 @@ sections:
|
||||
- program: .foo += 1
|
||||
input: '{"foo": 42}'
|
||||
output: ['{"foo": 43}']
|
||||
|
||||
|
||||
- title: Complex assignments
|
||||
body: |
|
||||
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:
|
||||
|
||||
|
||||
.posts[0].title = "JQ Manual"
|
||||
|
||||
|
||||
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:
|
||||
|
||||
|
||||
.posts[].comments |= . + ["this is great"]
|
||||
|
||||
|
||||
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).
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
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:
|
||||
|
||||
|
||||
.posts[] | select(.author == "stedolan")
|
||||
|
||||
|
||||
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:
|
||||
|
||||
|
||||
(.posts[] | select(.author == "stedolan") | .comments) |=
|
||||
. + ["terrible."]
|
||||
@@ -16,7 +16,7 @@ body: |
|
||||
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.
|
||||
|
||||
|
||||
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
|
||||
@@ -50,7 +50,7 @@ manpage_intro: |
|
||||
By default, `jq` reads a stream of JSON objects (whitespace
|
||||
separated) from `stdin`. One or more <files> may be specified, in
|
||||
which case `jq` will read input from those instead.
|
||||
|
||||
|
||||
The <options> are described in the [INVOKING JQ] section, they
|
||||
mostly concern input and output formatting. The <filter> is written
|
||||
in the jq language and specifies how to transform the input
|
||||
@@ -68,11 +68,11 @@ manpage_epilogue: |
|
||||
## AUTHOR
|
||||
|
||||
Stephen Dolan `<mu@netsoc.tcd.ie>`
|
||||
|
||||
|
||||
sections:
|
||||
- title: Invoking jq
|
||||
body: |
|
||||
|
||||
|
||||
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
|
||||
@@ -98,44 +98,44 @@ sections:
|
||||
Output the jq version and exit with zero.
|
||||
|
||||
* `--slurp`/`-s`:
|
||||
|
||||
|
||||
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.
|
||||
|
||||
* `--online-input`/`-I`:
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
* `--raw-input`/`-R`:
|
||||
|
||||
|
||||
Don't parse the input as JSON. Instead, each line of text is
|
||||
passed to the filter as a string. If combined with `--slurp`,
|
||||
then the entire input is passed to the filter as a single long
|
||||
string.
|
||||
|
||||
|
||||
* `--null-input`/`-n`:
|
||||
|
||||
|
||||
Don't read any input at all! Instead, the filter is run once
|
||||
using `null` as the input. This is useful when using jq as a
|
||||
simple calculator or to construct JSON data from scratch.
|
||||
|
||||
|
||||
* `--compact-output` / `-c`:
|
||||
|
||||
|
||||
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.
|
||||
|
||||
* `--colour-output` / `-C` and `--monochrome-output` / `-M`:
|
||||
|
||||
|
||||
* `--color-output` / `-C` and `--monochrome-output` / `-M`:
|
||||
|
||||
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 `-C`, and disable color with `-M`.
|
||||
|
||||
|
||||
* `--ascii-output` / `-a`:
|
||||
|
||||
|
||||
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
|
||||
@@ -149,11 +149,11 @@ sections:
|
||||
output elsewhere).
|
||||
|
||||
* `--sort-keys` / `-S`:
|
||||
|
||||
|
||||
Output the fields of each object with the keys in sorted order.
|
||||
|
||||
* `--raw-output` / `-r`:
|
||||
|
||||
|
||||
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
|
||||
@@ -191,7 +191,7 @@ sections:
|
||||
entries:
|
||||
- title: "`.`"
|
||||
body: |
|
||||
|
||||
|
||||
The absolute simplest (and least interesting) filter
|
||||
is `.`. This is a filter that takes its input and
|
||||
produces it unchanged as output.
|
||||
@@ -207,7 +207,7 @@ sections:
|
||||
|
||||
- title: "`.foo`, `.foo.bar`"
|
||||
body: |
|
||||
|
||||
|
||||
The simplest *useful* 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.
|
||||
@@ -216,7 +216,7 @@ sections:
|
||||
it with double quotes like this: `."foo$"`.
|
||||
|
||||
A filter of the form `.foo.bar` is equivalent to `.foo|.bar`.
|
||||
|
||||
|
||||
examples:
|
||||
- program: '.foo'
|
||||
input: '{"foo": 42, "bar": "less interesting data"}'
|
||||
@@ -230,7 +230,7 @@ sections:
|
||||
|
||||
- title: "`.foo?`"
|
||||
body: |
|
||||
|
||||
|
||||
Just like `.foo`, but does not output even an error when `.`
|
||||
is not an array or an object.
|
||||
|
||||
@@ -250,7 +250,7 @@ sections:
|
||||
|
||||
- title: "`.[<string>]`, `.[2]`, `.[10:15]`"
|
||||
body: |
|
||||
|
||||
|
||||
You can also look up fields of an object using syntax like
|
||||
`.["foo"]` (.foo above is a shorthand version of this). This
|
||||
one works for arrays as well, if the key is an
|
||||
@@ -285,7 +285,7 @@ sections:
|
||||
- program: '.[2:4]'
|
||||
input: '"abcdefghi"'
|
||||
output: ['"cd"']
|
||||
|
||||
|
||||
- program: '.[:3]'
|
||||
input: '["a","b","c","d","e"]'
|
||||
output: ['["a", "b", "c"]']
|
||||
@@ -296,7 +296,7 @@ sections:
|
||||
|
||||
- title: "`.[]`"
|
||||
body: |
|
||||
|
||||
|
||||
If you use the `.[index]` syntax, but omit the index
|
||||
entirely, it will return *all* of the elements of an
|
||||
array. Running `.[]` with the input `[1,2,3]` will produce the
|
||||
@@ -323,13 +323,13 @@ sections:
|
||||
|
||||
- title: "`.[]?`"
|
||||
body: |
|
||||
|
||||
|
||||
Like `.[]`, but no errors will be output if . is not an array
|
||||
or object.
|
||||
|
||||
- title: "`,`"
|
||||
body: |
|
||||
|
||||
|
||||
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
|
||||
@@ -344,18 +344,18 @@ sections:
|
||||
|
||||
- program: ".user, .projects[]"
|
||||
input: '{"user":"stedolan", "projects": ["jq", "wikiflow"]}'
|
||||
output: ['"stedolan"', '"jq"', '"wikiflow"']
|
||||
|
||||
output: ['"stedolan"', '"jq"', '"wikiflow"']
|
||||
|
||||
- program: '.[4,2]'
|
||||
input: '["a","b","c","d","e"]'
|
||||
output: ['"e"', '"c"']
|
||||
|
||||
|
||||
- title: "`|`"
|
||||
body: |
|
||||
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.
|
||||
that.
|
||||
|
||||
If the one on the left produces multiple results, the one on
|
||||
the right will be run for each of those results. So, the
|
||||
@@ -369,7 +369,7 @@ sections:
|
||||
|
||||
- title: Types and Values
|
||||
body: |
|
||||
|
||||
|
||||
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".
|
||||
@@ -383,7 +383,7 @@ sections:
|
||||
entries:
|
||||
- title: Array construction - `[]`
|
||||
body: |
|
||||
|
||||
|
||||
As in JSON, `[]` is used to construct arrays, as in
|
||||
`[1,2,3]`. The elements of the arrays can be any jq
|
||||
expression. All of the results produced by all of the
|
||||
@@ -391,7 +391,7 @@ sections:
|
||||
to construct an array out of a known quantity of values (as
|
||||
in `[.foo, .bar, .baz]`) or to "collect" all the results of a
|
||||
filter into an array (as in `[.items[].name]`)
|
||||
|
||||
|
||||
Once you understand the "," operator, you can look at jq's array
|
||||
syntax in a different light: the expression `[1,2,3]` is not using a
|
||||
built-in syntax for comma-separated arrays, but is instead applying
|
||||
@@ -411,49 +411,49 @@ sections:
|
||||
|
||||
Like JSON, `{}` is for constructing objects (aka
|
||||
dictionaries or hashes), as in: `{"a": 42, "b": 17}`.
|
||||
|
||||
|
||||
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).
|
||||
|
||||
|
||||
{foo: .bar}
|
||||
|
||||
|
||||
will produce the JSON object `{"foo": 42}` if given the JSON
|
||||
object `{"bar":42, "baz":43}`. 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
|
||||
|
||||
|
||||
{user: .user, title: .title}
|
||||
|
||||
|
||||
Because that's so common, there's a shortcut syntax: `{user, title}`.
|
||||
|
||||
|
||||
If one of the expressions produces multiple results,
|
||||
multiple dictionaries will be produced. If the input's
|
||||
|
||||
|
||||
{"user":"stedolan","titles":["JQ Primer", "More JQ"]}
|
||||
|
||||
|
||||
then the expression
|
||||
|
||||
|
||||
{user, title: .titles[]}
|
||||
|
||||
will produce two outputs:
|
||||
|
||||
|
||||
will produce two outputs:
|
||||
|
||||
{"user":"stedolan", "title": "JQ Primer"}
|
||||
{"user":"stedolan", "title": "More JQ"}
|
||||
|
||||
|
||||
Putting parentheses around the key means it will be evaluated as an
|
||||
expression. With the same input as above,
|
||||
|
||||
|
||||
{(.user): .titles}
|
||||
|
||||
|
||||
produces
|
||||
|
||||
|
||||
{"stedolan": ["JQ Primer", "More JQ"]}
|
||||
|
||||
|
||||
examples:
|
||||
- program: '{user, title: .titles[]}'
|
||||
input: '{"user":"stedolan","titles":["JQ Primer", "More JQ"]}'
|
||||
@@ -472,7 +472,7 @@ sections:
|
||||
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.
|
||||
|
||||
|
||||
entries:
|
||||
- title: Addition - `+`
|
||||
body: |
|
||||
@@ -486,13 +486,13 @@ sections:
|
||||
- **Arrays** are added by being concatenated into a larger array.
|
||||
|
||||
- **Strings** are added by being joined into a larger string.
|
||||
|
||||
|
||||
- **Objects** 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 `+` wins. (For
|
||||
recursive merge use the `*` operator.)
|
||||
|
||||
|
||||
`null` can be added to any value, and returns the other
|
||||
value unchanged.
|
||||
|
||||
@@ -578,7 +578,7 @@ sections:
|
||||
|
||||
- title: "`keys`"
|
||||
body: |
|
||||
|
||||
|
||||
The builtin function `keys`, when given an object, returns
|
||||
its keys in an array.
|
||||
|
||||
@@ -601,7 +601,7 @@ sections:
|
||||
|
||||
- title: "`has`"
|
||||
body: |
|
||||
|
||||
|
||||
The builtin function `has` returns whether the input object
|
||||
has the given key, or the input array has an element at the
|
||||
given index.
|
||||
@@ -620,25 +620,25 @@ sections:
|
||||
|
||||
- title: "`del`"
|
||||
body: |
|
||||
|
||||
|
||||
The builtin function `del` removes a key and its corresponding
|
||||
value from an object.
|
||||
|
||||
|
||||
examples:
|
||||
- program: 'del(.foo)'
|
||||
input: '[{"foo": 42, "bar": 9001, "baz": 42}]'
|
||||
input: '{"foo": 42, "bar": 9001, "baz": 42}'
|
||||
output: ['{"bar": 9001, "baz": 42}']
|
||||
- program: 'del(.[1, 2])'
|
||||
input: '[["foo", "bar", "baz"]]'
|
||||
input: '["foo", "bar", "baz"]'
|
||||
output: ['["foo"]']
|
||||
|
||||
- title: "`to_entries`, `from_entries`, `with_entries`"
|
||||
body: |
|
||||
|
||||
|
||||
These functions convert between an object and an array of
|
||||
key-value pairs. If `to_entries` is passed an object, then
|
||||
for each `k: v` entry in the input, the output array
|
||||
includes `{"key": k, "value": v}`.
|
||||
includes `{"key": k, "value": v}`.
|
||||
|
||||
`from_entries` does the opposite conversion, and
|
||||
`with_entries(foo)` is a shorthand for `to_entries |
|
||||
@@ -659,7 +659,7 @@ sections:
|
||||
|
||||
- title: "`select`"
|
||||
body: |
|
||||
|
||||
|
||||
The function `select(foo)` produces its input unchanged if
|
||||
`foo` returns true for that input, and produces no output
|
||||
otherwise.
|
||||
@@ -675,7 +675,7 @@ sections:
|
||||
|
||||
- title: "`arrays`, `objects`, `iterables`, `booleans`, `numbers`, `strings`, `nulls`, `values`, `scalars`"
|
||||
body: |
|
||||
|
||||
|
||||
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.
|
||||
@@ -687,7 +687,7 @@ sections:
|
||||
|
||||
- title: "`empty`"
|
||||
body: |
|
||||
|
||||
|
||||
`empty` returns no results. None at all. Not even `null`.
|
||||
|
||||
It's useful on occasion. You'll know if you need it :)
|
||||
@@ -721,7 +721,7 @@ sections:
|
||||
Outputs the paths to all the elements in its input (except it
|
||||
does not output the empty list, representing . itself).
|
||||
|
||||
`paths` is equivalent to
|
||||
`paths` is equivalent to
|
||||
|
||||
def paths: path(recurse(if (type|. == "array" or . == "object") then .[] else empty end))|select(length > 0);
|
||||
|
||||
@@ -765,13 +765,13 @@ sections:
|
||||
|
||||
- title: "`any`"
|
||||
body: |
|
||||
|
||||
|
||||
The filter `any` takes as input an array of boolean values,
|
||||
and produces `true` as output if any of the the elements of
|
||||
the array is `true`.
|
||||
|
||||
and produces `true` as output if any of the elements of
|
||||
the array are `true`.
|
||||
|
||||
If the input is an empty array, `any` returns `false`.
|
||||
|
||||
|
||||
examples:
|
||||
- program: any
|
||||
input: '[true, false]'
|
||||
@@ -785,13 +785,13 @@ sections:
|
||||
|
||||
- title: "`all`"
|
||||
body: |
|
||||
|
||||
|
||||
The filter `all` takes as input an array of boolean values,
|
||||
and produces `true` as output if all of the the elements of
|
||||
and produces `true` as output if all of the elements of
|
||||
the array are `true`.
|
||||
|
||||
|
||||
If the input is an empty array, `all` returns `true`.
|
||||
|
||||
|
||||
examples:
|
||||
- program: all
|
||||
input: '[true, false]'
|
||||
@@ -805,10 +805,10 @@ sections:
|
||||
|
||||
- title: "`range`"
|
||||
body: |
|
||||
|
||||
|
||||
The `range` function produces a range of numbers. `range(4;10)`
|
||||
produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers
|
||||
are produced as separate outputs. Use `[range(4;10)]` to get a range as
|
||||
are produced as separate outputs. Use `[range(4;10)]` to get a range as
|
||||
an array.
|
||||
|
||||
examples:
|
||||
@@ -818,7 +818,7 @@ sections:
|
||||
- program: '[range(2;4)]'
|
||||
input: 'null'
|
||||
output: ['[2,3]']
|
||||
|
||||
|
||||
- title: "`floor`"
|
||||
body: |
|
||||
|
||||
@@ -828,7 +828,7 @@ sections:
|
||||
- program: 'floor'
|
||||
input: '3.14159'
|
||||
output: ['3']
|
||||
|
||||
|
||||
- title: "`sqrt`"
|
||||
body: |
|
||||
|
||||
@@ -838,7 +838,7 @@ sections:
|
||||
- program: 'sqrt'
|
||||
input: '9'
|
||||
output: ['3']
|
||||
|
||||
|
||||
- title: "`tonumber`"
|
||||
body: |
|
||||
|
||||
@@ -865,7 +865,7 @@ sections:
|
||||
|
||||
- title: "`type`"
|
||||
body: |
|
||||
|
||||
|
||||
The `type` function returns the type of its argument as a
|
||||
string, which is one of null, boolean, number, string, array
|
||||
or object.
|
||||
@@ -877,7 +877,7 @@ sections:
|
||||
|
||||
- title: "`sort, sort_by`"
|
||||
body: |
|
||||
|
||||
|
||||
The `sort` functions sorts its input, which must be an
|
||||
array. Values are sorted in the following order:
|
||||
|
||||
@@ -909,7 +909,7 @@ sections:
|
||||
|
||||
- title: "`group_by`"
|
||||
body: |
|
||||
|
||||
|
||||
`group_by(.foo)` takes as input an array, groups the
|
||||
elements having the same `.foo` field into separate arrays,
|
||||
and produces all of these arrays as elements of a larger
|
||||
@@ -926,7 +926,7 @@ sections:
|
||||
|
||||
- title: "`min`, `max`, `min_by`, `max_by`"
|
||||
body: |
|
||||
|
||||
|
||||
Find the minimum or maximum element of the input array. The
|
||||
`_by` versions allow you to specify a particular field or
|
||||
property to examine, e.g. `min_by(.foo)` finds the object
|
||||
@@ -942,7 +942,7 @@ sections:
|
||||
|
||||
- title: "`unique`"
|
||||
body: |
|
||||
|
||||
|
||||
The `unique` function takes as input an array and produces
|
||||
an array of the same elements, in sorted order, with
|
||||
duplicates removed.
|
||||
@@ -954,25 +954,25 @@ sections:
|
||||
|
||||
- title: "`unique_by`"
|
||||
body: |
|
||||
|
||||
|
||||
The `unique_by(.foo)` function takes as input an array and produces
|
||||
an array of the same elements, in sorted order, with
|
||||
elqements with a duplicate `.foo` field removed. Think of it as making
|
||||
an array by taking one element out of every group produced by
|
||||
`group_by`.
|
||||
|
||||
|
||||
examples:
|
||||
- program: 'unique_by(.foo)'
|
||||
input: '[{"foo": 1, "bar": 2}, {"foo": 1, "bar": 3}, {"foo": 4, "bar": 5}]'
|
||||
output: ['[{"foo": 1, "bar": 2}, {"foo": 4, "bar": 5}]']
|
||||
- program: 'unique_by(length)'
|
||||
input: '["chunky", "bacon", "kitten", "cicada", "asparagus"]'
|
||||
output: ['["chunky", "bacon", "asparagus"]']
|
||||
output: ['["bacon", "chunky", "asparagus"]']
|
||||
|
||||
|
||||
- title: "`reverse`"
|
||||
body: |
|
||||
|
||||
|
||||
This function reverses an array.
|
||||
|
||||
examples:
|
||||
@@ -1038,7 +1038,7 @@ sections:
|
||||
- program: 'index(", ")'
|
||||
input: '"a,b, cd, efg, hijk"'
|
||||
output: ['3']
|
||||
- program: 'rindex(", ")]'
|
||||
- program: 'rindex(", ")'
|
||||
input: '"a,b, cd, efg, hijk"'
|
||||
output: ['12']
|
||||
|
||||
@@ -1060,7 +1060,7 @@ sections:
|
||||
examples:
|
||||
- program: '[.[]|endswith("foo")]'
|
||||
input: '["foobar", "barfoo"]'
|
||||
output: ['[false, true, true, false, false]']
|
||||
output: ['[false, true]']
|
||||
|
||||
- title: "`ltrimstr`"
|
||||
body: |
|
||||
@@ -1117,12 +1117,12 @@ sections:
|
||||
|
||||
- title: "`join`"
|
||||
body: |
|
||||
|
||||
|
||||
Joins the array of elements given as input, using the
|
||||
argument as separator. It is the inverse of `split`: that is,
|
||||
running `split("foo") | join("foo")` over any input string
|
||||
returns said input string.
|
||||
|
||||
|
||||
examples:
|
||||
- program: 'join(", ")'
|
||||
input: '["a","b,c,d","e"]'
|
||||
@@ -1131,7 +1131,7 @@ sections:
|
||||
|
||||
- title: "`recurse`"
|
||||
body: |
|
||||
|
||||
|
||||
The `recurse` function allows you to search through a
|
||||
recursive structure, and extract interesting data from all
|
||||
levels. Suppose your input represents a filesystem:
|
||||
@@ -1143,7 +1143,7 @@ sections:
|
||||
{"name": "/home", "children": [
|
||||
{"name": "/home/stephen", "children": [
|
||||
{"name": "/home/stephen/jq", "children": []}]}]}]}
|
||||
|
||||
|
||||
Now suppose you want to extract all of the filenames
|
||||
present. You need to retrieve `.name`, `.children[].name`,
|
||||
`.children[].children[].name`, and so on. You can do this
|
||||
@@ -1154,7 +1154,7 @@ sections:
|
||||
examples:
|
||||
- program: 'recurse(.foo[])'
|
||||
input: '{"foo":[{"foo": []}, {"foo":[{"foo":[]}]}]}'
|
||||
output:
|
||||
output:
|
||||
- '{"foo":[{"foo":[]},{"foo":[{"foo":[]}]}]}'
|
||||
- '{"foo":[]}'
|
||||
- '{"foo":[{"foo":[]}]}'
|
||||
@@ -1162,14 +1162,14 @@ sections:
|
||||
|
||||
- title: "`recurse_down`"
|
||||
body: |
|
||||
|
||||
|
||||
A quieter version of `recurse(.[])`, equivalent to:
|
||||
|
||||
def recurse_down: recurse(.[]?);
|
||||
|
||||
- title: "`..`"
|
||||
body: |
|
||||
|
||||
|
||||
Short-hand for `recurse_down`. This is intended to resemble
|
||||
the XPath `//` operator. Note that `..a` does not work; use
|
||||
`..|a` instead.
|
||||
@@ -1190,7 +1190,7 @@ sections:
|
||||
- program: '"The input was \(.), which is one less than \(.+1)"'
|
||||
input: '42'
|
||||
output: ['"The input was 42, which is one less than 43"']
|
||||
|
||||
|
||||
- title: "Convert to/from JSON"
|
||||
body: |
|
||||
|
||||
@@ -1238,17 +1238,17 @@ sections:
|
||||
characters to a `%xx` sequence.
|
||||
|
||||
* `@csv`:
|
||||
|
||||
|
||||
The input must be an array, and it is rendered as CSV
|
||||
with double quotes for strings, and quotes escaped by
|
||||
repetition.
|
||||
|
||||
* `@sh`:
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
* `@base64`:
|
||||
|
||||
The input is converted to base64 as specified by RFC 4648.
|
||||
@@ -1259,12 +1259,12 @@ sections:
|
||||
escaped. However, all interpolations made inside that string
|
||||
literal will be escaped. For instance,
|
||||
|
||||
@uri "http://www.google.com/search?q=\(.search)"
|
||||
@uri "https://www.google.com/search?q=\(.search)"
|
||||
|
||||
will produce the following output for the input
|
||||
`{"search":"what is jq?"}`:
|
||||
|
||||
"http://www.google.com/search?q=what%20is%20jq%3f"
|
||||
"https://www.google.com/search?q=what%20is%20jq%3f"
|
||||
|
||||
Note that the slashes, question mark, etc. in the URL are
|
||||
not escaped, as they were part of the string literal.
|
||||
@@ -1281,7 +1281,7 @@ sections:
|
||||
- program: '@sh "echo \(.)"'
|
||||
input: "\"O'Hara's Ale\""
|
||||
output: ["\"echo 'O'\\\\''Hara'\\\\''s Ale'\""]
|
||||
|
||||
|
||||
- title: Conditionals and Comparisons
|
||||
entries:
|
||||
- title: "`==`, `!=`"
|
||||
@@ -1293,7 +1293,7 @@ sections:
|
||||
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.
|
||||
|
||||
|
||||
!= is "not equal", and 'a != b' returns the opposite value of 'a == b'
|
||||
|
||||
examples:
|
||||
@@ -1306,7 +1306,7 @@ sections:
|
||||
`if A then B else C end` will act the same as `B` if `A`
|
||||
produces a value other than false or null, but act the same
|
||||
as `C` otherwise.
|
||||
|
||||
|
||||
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
|
||||
@@ -1314,11 +1314,11 @@ sections:
|
||||
string is empty using `if .name then A else B end`, you'll
|
||||
need something more like `if (.name | length) > 0 then A else
|
||||
B end` instead.
|
||||
|
||||
If the condition A produces multiple results, it is
|
||||
considered "true" if any of those results is not false or
|
||||
null. If it produces zero results, it's considered false.
|
||||
|
||||
|
||||
If the condition `A` produces multiple results, then `B` is evaluated
|
||||
once for each result that is not false or null, and `C` is evaluated
|
||||
once for each false or null.
|
||||
|
||||
More cases can be added to an if using `elif A then B` syntax.
|
||||
|
||||
examples:
|
||||
@@ -1332,10 +1332,10 @@ sections:
|
||||
end
|
||||
input: 2
|
||||
output: ['"many"']
|
||||
|
||||
|
||||
- title: "`>, >=, <=, <`"
|
||||
body: |
|
||||
|
||||
|
||||
The comparison operators `>`, `>=`, `<=`, `<` return whether
|
||||
their left argument is greater than, greater than or equal
|
||||
to, less than or equal to or less than their right argument
|
||||
@@ -1362,14 +1362,14 @@ sections:
|
||||
so it is called as a filter to which things can be piped
|
||||
rather than with special syntax, as in `.foo and .bar |
|
||||
not`.
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
examples:
|
||||
- program: '42 and "a string"'
|
||||
input: 'null'
|
||||
@@ -1407,7 +1407,7 @@ sections:
|
||||
- program: '.foo // 42'
|
||||
input: '{}'
|
||||
output: [42]
|
||||
|
||||
|
||||
- title: Advanced features
|
||||
body: |
|
||||
Variables are an absolute necessity in most programming languages, but
|
||||
@@ -1432,67 +1432,67 @@ sections:
|
||||
entries:
|
||||
- title: Variables
|
||||
body: |
|
||||
|
||||
|
||||
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 `a + b`, pass their input
|
||||
to two distinct subexpressions (here `a` and `b` are both passed the
|
||||
same input), so variables aren't usually necessary in order to use a
|
||||
value twice.
|
||||
|
||||
|
||||
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 `add / length` - the `add` expression is given the array and
|
||||
produces its sum, and the `length` expression is given the array and
|
||||
produces its length.
|
||||
|
||||
|
||||
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 `expression as $variable`. All
|
||||
variable names start with `$`. Here's a slightly uglier version of the
|
||||
array-averaging example:
|
||||
|
||||
|
||||
length as $array_length | add / $array_length
|
||||
|
||||
|
||||
We'll need a more complicated problem to find a situation where using
|
||||
variables actually makes our lives easier.
|
||||
|
||||
|
||||
|
||||
|
||||
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:
|
||||
|
||||
|
||||
{"posts": [{"title": "Frist psot", "author": "anon"},
|
||||
{"title": "A well-written article", "author": "person1"}],
|
||||
"realnames": {"anon": "Anonymous Coward",
|
||||
"person1": "Person McPherson"}}
|
||||
|
||||
|
||||
We want to produce the posts with the author field containing a real
|
||||
name, as in:
|
||||
|
||||
|
||||
{"title": "Frist psot", "author": "Anonymous Coward"}
|
||||
{"title": "A well-written article", "author": "Person McPherson"}
|
||||
|
||||
|
||||
We use a variable, $names, to store the realnames object, so that we
|
||||
can refer to it later when looking up author usernames:
|
||||
|
||||
|
||||
.realnames as $names | .posts[] | {title, author: $names[.author]}
|
||||
|
||||
|
||||
The expression `exp as $x | ...` means: for each value of expression
|
||||
`exp`, run the rest of the pipeline with the entire original input, and
|
||||
with `$x` set to that value. Thus `as` functions as something of a
|
||||
with `$x` set to that value. Thus `as` functions as something of a
|
||||
foreach loop.
|
||||
|
||||
Variables are scoped over the rest of the expression that defines
|
||||
them, so
|
||||
|
||||
them, so
|
||||
|
||||
.realnames as $names | (.posts[] | {title, author: $names[.author]})
|
||||
|
||||
will work, but
|
||||
|
||||
|
||||
will work, but
|
||||
|
||||
(.realnames as $names | .posts[]) | {title, author: $names[.author]}
|
||||
|
||||
|
||||
won't.
|
||||
|
||||
examples:
|
||||
@@ -1502,11 +1502,11 @@ sections:
|
||||
|
||||
- title: 'Defining Functions'
|
||||
body: |
|
||||
|
||||
|
||||
You can give a filter a name using "def" syntax:
|
||||
|
||||
def increment: . + 1;
|
||||
|
||||
|
||||
From then on, `increment` 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:
|
||||
@@ -1537,19 +1537,19 @@ sections:
|
||||
|
||||
- title: Reduce
|
||||
body: |
|
||||
|
||||
|
||||
The `reduce` 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 `[3,2,1]` to this expression:
|
||||
|
||||
reduce .[] as $item (0; . + $item)
|
||||
|
||||
|
||||
For each result that `.[]` produces, `. + $item` is run to
|
||||
accumulate a running total, starting from 0. In this
|
||||
example, `.[]` produces the results 3, 2, and 1, so the
|
||||
effect is similar to running something like this:
|
||||
|
||||
0 | (3 as $item | . + $item) |
|
||||
0 | (3 as $item | . + $item) |
|
||||
(2 as $item | . + $item) |
|
||||
(1 as $item | . + $item)
|
||||
|
||||
@@ -1557,7 +1557,7 @@ sections:
|
||||
- program: 'reduce .[] as $item (0; . + $item)'
|
||||
input: '[10,2,5,3]'
|
||||
output: ['20']
|
||||
|
||||
|
||||
|
||||
- title: Assignment
|
||||
body: |
|
||||
@@ -1579,14 +1579,14 @@ sections:
|
||||
entries:
|
||||
- title: "`=`"
|
||||
body: |
|
||||
|
||||
|
||||
The filter `.foo = 1` 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,
|
||||
|
||||
|
||||
.foo = .bar | .foo.baz = 1
|
||||
|
||||
|
||||
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
|
||||
@@ -1595,7 +1595,7 @@ sections:
|
||||
"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.
|
||||
|
||||
|
||||
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
|
||||
@@ -1608,14 +1608,14 @@ sections:
|
||||
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.
|
||||
|
||||
|
||||
This example should show the difference between '=' and '|=':
|
||||
|
||||
|
||||
Provide input '{"a": {"b": 10}, "b": 20}' to the programs:
|
||||
|
||||
|
||||
.a = .b
|
||||
.a |= .b
|
||||
|
||||
|
||||
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}.
|
||||
@@ -1630,43 +1630,43 @@ sections:
|
||||
- program: .foo += 1
|
||||
input: '{"foo": 42}'
|
||||
output: ['{"foo": 43}']
|
||||
|
||||
|
||||
- title: Complex assignments
|
||||
body: |
|
||||
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:
|
||||
|
||||
|
||||
.posts[0].title = "JQ Manual"
|
||||
|
||||
|
||||
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:
|
||||
|
||||
|
||||
.posts[].comments |= . + ["this is great"]
|
||||
|
||||
|
||||
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).
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
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:
|
||||
|
||||
|
||||
.posts[] | select(.author == "stedolan")
|
||||
|
||||
|
||||
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:
|
||||
|
||||
|
||||
(.posts[] | select(.author == "stedolan") | .comments) |=
|
||||
. + ["terrible."]
|
||||
File diff suppressed because it is too large.
Load diff
@@ -24,26 +24,43 @@ body3: |
|
||||
|
||||
tail: |
|
||||
|
||||
Go read the [tutorial](tutorial/) for more, or the [manual](manual/)
|
||||
for *way* more. Ask questions over on
|
||||
[stackoverflow](http://stackoverflow.com/) using the [jq
|
||||
tag](http://stackoverflow.com/questions/tagged/jq), or on the
|
||||
[#jq](http://irc.lc/freenode/%23jq/) channel over on
|
||||
Go read the [tutorial](/jq/tutorial/) for more, or the [manual](/jq/manual/)
|
||||
for *way* more.
|
||||
|
||||
Ask questions on [stackoverflow](https://stackoverflow.com/) using the [jq
|
||||
tag](https://stackoverflow.com/questions/tagged/jq), or on the
|
||||
[#jq](http://irc.lc/freenode/%23jq/) channel on
|
||||
[Freenode](https://webchat.freenode.net/).
|
||||
|
||||
news:
|
||||
- date: 2015-01-01
|
||||
- date: 15 August 2015
|
||||
body: |
|
||||
|
||||
jq 1.5rc1 Get it on the
|
||||
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
|
||||
[download](/jq/download/) page, and the
|
||||
[release notes](https://github.com/stedolan/jq/releases/tag/jq-1.5)
|
||||
for details.
|
||||
|
||||
- date: 26 July 2015
|
||||
body: |
|
||||
|
||||
jq 1.5rc2 is available. Get it on the
|
||||
[releases](https://github.com/stedolan/jq/releases) page.
|
||||
|
||||
- date: 2014-06-08
|
||||
- date: 01 January 2015
|
||||
body: |
|
||||
|
||||
jq 1.4 (finally) released! Get it on the [download](download/) page.
|
||||
jq 1.5rc1 is available. Get it on the
|
||||
[releases](https://github.com/stedolan/jq/releases) page.
|
||||
|
||||
- date: 2013-05-19
|
||||
- date: 09 June 2014
|
||||
body: |
|
||||
|
||||
jq 1.4 (finally) released! Get it on the [download](/jq/download/) page.
|
||||
|
||||
- date: 19 May 2013
|
||||
body: |
|
||||
|
||||
jq 1.3 released.
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
jq(1) -- Command-line JSON processor
|
||||
====================================
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
`jq` can transform JSON in various ways, by selecting, iterating,
|
||||
reducing and otherwise mangling JSON documents.
|
||||
|
||||
This version of `jq` was built without a manual, so this manpage is a
|
||||
stub. For full documentation of the `jq` language, see:
|
||||
|
||||
http://stedolan.github.io/jq
|
||||
|
||||
## BUGS
|
||||
|
||||
Presumably. Report them or discuss them at:
|
||||
|
||||
https://github.com/stedolan/jq/issues
|
||||
|
||||
## AUTHOR
|
||||
|
||||
Stephen Dolan `<mu@netsoc.tcd.ie>`
|
||||
@@ -12,7 +12,7 @@ FileETag All
|
||||
</IfModule>
|
||||
</IfModule>
|
||||
|
||||
# Cache, aggressively
|
||||
# Cache, aggressively
|
||||
<IfModule mod_expires.c>
|
||||
ExpiresActive On
|
||||
ExpiresDefault "access plus 10 days"
|
||||
@@ -25,4 +25,4 @@ FileETag All
|
||||
# Mime-types
|
||||
AddType application/vnd.ms-fontobject .eot
|
||||
AddType font/ttf .ttf
|
||||
AddType font/otf .otf
|
||||
AddType font/otf .otf
|
||||
-1058
File diff suppressed because it is too large.
Load diff
@@ -1,9 +0,0 @@
|
||||
/*!
|
||||
* Bootstrap Responsive v2.1.1
|
||||
*
|
||||
* Copyright 2012 Twitter, Inc
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
||||
*/.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.hidden{display:none;visibility:hidden}.visible-phone{display:none!important}.visible-tablet{display:none!important}.hidden-desktop{display:none!important}.visible-desktop{display:inherit!important}@media(min-width:768px) and (max-width:979px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-tablet{display:inherit!important}.hidden-tablet{display:none!important}}@media(max-width:767px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-phone{display:inherit!important}.hidden-phone{display:none!important}}@media(min-width:1200px){.row{margin-left:-30px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:30px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1170px}.span12{width:1170px}.span11{width:1070px}.span10{width:970px}.span9{width:870px}.span8{width:770px}.span7{width:670px}.span6{width:570px}.span5{width:470px}.span4{width:370px}.span3{width:270px}.span2{width:170px}.span1{width:70px}.offset12{margin-left:1230px}.offset11{margin-left:1130px}.offset10{margin-left:1030px}.offset9{margin-left:930px}.offset8{margin-left:830px}.offset7{margin-left:730px}.offset6{margin-left:630px}.offset5{margin-left:530px}.offset4{margin-left:430px}.offset3{margin-left:330px}.offset2{margin-left:230px}.offset1{margin-left:130px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.564102564102564%;*margin-left:2.5109110747408616%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.45299145299145%;*width:91.39979996362975%}.row-fluid .span10{width:82.90598290598291%;*width:82.8527914166212%}.row-fluid .span9{width:74.35897435897436%;*width:74.30578286961266%}.row-fluid .span8{width:65.81196581196582%;*width:65.75877432260411%}.row-fluid .span7{width:57.26495726495726%;*width:57.21176577559556%}.row-fluid .span6{width:48.717948717948715%;*width:48.664757228587014%}.row-fluid .span5{width:40.17094017094017%;*width:40.11774868157847%}.row-fluid .span4{width:31.623931623931625%;*width:31.570740134569924%}.row-fluid .span3{width:23.076923076923077%;*width:23.023731587561375%}.row-fluid .span2{width:14.52991452991453%;*width:14.476723040552828%}.row-fluid .span1{width:5.982905982905983%;*width:5.929714493544281%}.row-fluid .offset12{margin-left:105.12820512820512%;*margin-left:105.02182214948171%}.row-fluid .offset12:first-child{margin-left:102.56410256410257%;*margin-left:102.45771958537915%}.row-fluid .offset11{margin-left:96.58119658119658%;*margin-left:96.47481360247316%}.row-fluid .offset11:first-child{margin-left:94.01709401709402%;*margin-left:93.91071103837061%}.row-fluid .offset10{margin-left:88.03418803418803%;*margin-left:87.92780505546462%}.row-fluid .offset10:first-child{margin-left:85.47008547008548%;*margin-left:85.36370249136206%}.row-fluid .offset9{margin-left:79.48717948717949%;*margin-left:79.38079650845607%}.row-fluid .offset9:first-child{margin-left:76.92307692307693%;*margin-left:76.81669394435352%}.row-fluid .offset8{margin-left:70.94017094017094%;*margin-left:70.83378796144753%}.row-fluid .offset8:first-child{margin-left:68.37606837606839%;*margin-left:68.26968539734497%}.row-fluid .offset7{margin-left:62.393162393162385%;*margin-left:62.28677941443899%}.row-fluid .offset7:first-child{margin-left:59.82905982905982%;*margin-left:59.72267685033642%}.row-fluid .offset6{margin-left:53.84615384615384%;*margin-left:53.739770867430444%}.row-fluid .offset6:first-child{margin-left:51.28205128205128%;*margin-left:51.175668303327875%}.row-fluid .offset5{margin-left:45.299145299145295%;*margin-left:45.1927623204219%}.row-fluid .offset5:first-child{margin-left:42.73504273504273%;*margin-left:42.62865975631933%}.row-fluid .offset4{margin-left:36.75213675213675%;*margin-left:36.645753773413354%}.row-fluid .offset4:first-child{margin-left:34.18803418803419%;*margin-left:34.081651209310785%}.row-fluid .offset3{margin-left:28.205128205128204%;*margin-left:28.0987452264048%}.row-fluid .offset3:first-child{margin-left:25.641025641025642%;*margin-left:25.53464266230224%}.row-fluid .offset2{margin-left:19.65811965811966%;*margin-left:19.551736679396257%}.row-fluid .offset2:first-child{margin-left:17.094017094017094%;*maLine truncated
|
||||
-5224
File diff suppressed because it is too large.
Load diff
-9
@@ -1,9 +0,0 @@
|
||||
/*!
|
||||
* Bootstrap v2.1.1
|
||||
*
|
||||
* Copyright 2012 Twitter, Inc
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
||||
*/article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{width:auto\9;height:auto;max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:20px;color:#333;background-color:#fff}a{color:#08c;text-decoration:none}a:hover{color:#005580;text-decoration:underline}.img-rounded{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.img-polaroid{padding:4px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.1)}.img-circle{-webkit-border-radius:500px;-moz-border-radius:500px;border-radius:500px}.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.span12{width:940px}.span11{width:860px}.span10{width:780px}.span9{width:700px}.span8{width:620px}.span7{width:540px}.span6{width:460px}.span5{width:380px}.span4{width:300px}.span3{width:220px}.span2{width:140px}.span1{width:60px}.offset12{margin-left:980px}.offset11{margin-left:900px}.offset10{margin-left:820px}.offset9{margin-left:740px}.offset8{margin-left:660px}.offset7{margin-left:580px}.offset6{margin-left:500px}.offset5{margin-left:420px}.offset4{margin-left:340px}.offset3{margin-left:260px}.offset2{margin-left:180px}.offset1{margin-left:100px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.127659574468085%;*margin-left:2.074468085106383%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.48936170212765%;*width:91.43617021276594%}.row-fluid .span10{width:82.97872340425532%;*width:82.92553191489361%}.row-fluid .span9{width:74.46808510638297%;*width:74.41489361702126%}.row-fluid .span8{width:65.95744680851064%;*width:65.90425531914893%}.row-fluid .span7{width:57.44680851063829%;*width:57.39361702127659%}.row-fluid .span6{width:48.93617021276595%;*width:48.88297872340425%}.row-fluid .span5{width:40.42553191489362%;*width:40.37234042553192%}.row-fluid .span4{width:31.914893617021278%;*width:31.861702127659576%}.row-fluid .span3{width:23.404255319148934%;*width:23.351063829787233%}.row-fluid .span2{width:14.893617021276595%;*width:14.840425531914894%}.row-fluid .span1{width:6.382978723404255%;*width:6.329787234042553%}.row-fluid .offset12{margin-left:104.25531914893617%;*margin-left:104.14893617021275%}.row-fluid .offset12:first-child{margin-left:102.12765957446808%;*margin-left:102.02127659574467%}.row-fluid .offset11{margin-left:95.74468085106382%;*margin-left:95.6382978723404%}.row-fluid .offset11:first-child{margin-left:93.61702127659574%;*margin-left:93.51063829787232%}.row-fluid .offset10{margin-left:87.23404255319149%;*margin-left:87.12765957446807%}.row-fluid .offset10:first-child{margin-left:85.1063829787234%;*margin-left:84.99999999999999%}.row-fluid .offset9{margin-left:78.72340425531914%;*margin-left:78.61702127659572%}.row-fluid .offset9:first-child{margin-left:76.59574468085106%;*margin-left:76.48936170212764%}.row-fluiLine truncated
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
-2027
File diff suppressed because it is too large.
Load diff
-6
@@ -1,6 +0,0 @@
|
||||
/*!
|
||||
* Bootstrap.js by @fat & @mdo
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
*/
|
||||
!function(e){e(function(){"use strict";e.support.transition=function(){var e=function(){var e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},n;for(n in t)if(e.style[n]!==undefined)return t[n]}();return e&&{end:e}}()})}(window.jQuery),!function(e){"use strict";var t='[data-dismiss="alert"]',n=function(n){e(n).on("click",t,this.close)};n.prototype.close=function(t){function s(){i.trigger("closed").remove()}var n=e(this),r=n.attr("data-target"),i;r||(r=n.attr("href"),r=r&&r.replace(/.*(?=#[^\s]*$)/,"")),i=e(r),t&&t.preventDefault(),i.length||(i=n.hasClass("alert")?n:n.parent()),i.trigger(t=e.Event("close"));if(t.isDefaultPrevented())return;i.removeClass("in"),e.support.transition&&i.hasClass("fade")?i.on(e.support.transition.end,s):s()},e.fn.alert=function(t){return this.each(function(){var r=e(this),i=r.data("alert");i||r.data("alert",i=new n(this)),typeof t=="string"&&i[t].call(r)})},e.fn.alert.Constructor=n,e(function(){e("body").on("click.alert.data-api",t,n.prototype.close)})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.button.defaults,n)};t.prototype.setState=function(e){var t="disabled",n=this.$element,r=n.data(),i=n.is("input")?"val":"html";e+="Text",r.resetText||n.data("resetText",n[i]()),n[i](r[e]||this.options[e]),setTimeout(function(){e=="loadingText"?n.addClass(t).attr(t,t):n.removeClass(t).removeAttr(t)},0)},t.prototype.toggle=function(){var e=this.$element.closest('[data-toggle="buttons-radio"]');e&&e.find(".active").removeClass("active"),this.$element.toggleClass("active")},e.fn.button=function(n){return this.each(function(){var r=e(this),i=r.data("button"),s=typeof n=="object"&&n;i||r.data("button",i=new t(this,s)),n=="toggle"?i.toggle():n&&i.setState(n)})},e.fn.button.defaults={loadingText:"loading..."},e.fn.button.Constructor=t,e(function(){e("body").on("click.button.data-api","[data-toggle^=button]",function(t){var n=e(t.target);n.hasClass("btn")||(n=n.closest(".btn")),n.button("toggle")})})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=n,this.options.slide&&this.slide(this.options.slide),this.options.pause=="hover"&&this.$element.on("mouseenter",e.proxy(this.pause,this)).on("mouseleave",e.proxy(this.cycle,this))};t.prototype={cycle:function(t){return t||(this.paused=!1),this.options.interval&&!this.paused&&(this.interval=setInterval(e.proxy(this.next,this),this.options.interval)),this},to:function(t){var n=this.$element.find(".item.active"),r=n.parent().children(),i=r.index(n),s=this;if(t>r.length-1||t<0)return;return this.sliding?this.$element.one("slid",function(){s.to(t)}):i==t?this.pause().cycle():this.slide(t>i?"next":"prev",e(r[t]))},pause:function(t){return t||(this.paused=!0),this.$element.find(".next, .prev").length&&e.support.transition.end&&(this.$element.trigger(e.support.transition.end),this.cycle()),clearInterval(this.interval),this.interval=null,this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(t,n){var r=this.$element.find(".item.active"),i=n||r[t](),s=this.interval,o=t=="next"?"left":"right",u=t=="next"?"first":"last",a=this,f=e.Event("slide",{relatedTarget:i[0]});this.sliding=!0,s&&this.pause(),i=i.length?i:this.$element.find(".item")[u]();if(i.hasClass("active"))return;if(e.support.transition&&this.$element.hasClass("slide")){this.$element.trigger(f);if(f.isDefaultPrevented())return;i.addClass(t),i[0].offsetWidth,r.addClass(o),i.addClass(o),this.$element.one(e.support.transition.end,function(){i.removeClass([t,o].join(" ")).addClass("active"),r.removeClass(["active",o].join(" ")),a.sliding=!1,setTimeout(function(){a.$element.trigger("slid")},0)})}else{this.$element.trigger(f);if(f.isDefaultPrevented())return;r.removeClass("active"),i.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return s&&this.cycle(),this}},e.fn.carousel=function(n){return this.each(function(){var r=e(this),i=r.data("carousel"),s=e.extend({},e.fn.carousel.defaults,typeof n=="object"&&n),o=typeof n=="string"?n:s.slide;i||r.data("carousel",i=new t(this,s)),typeof n=="number"?i.to(n):o?i[o]():s.interval&&i.cycle()})},e.fn.carousel.defaults={interval:5e3,pause:"hover"},e.fn.carousel.Constructor=t,e(function(){e("body").on("click.carousel.data-api","[data-slide]",function(t){var n=e(this),r,i=e(n.attr("data-target")||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,"")),s=!i.data("modal")&&e.extend({},i.data(),n.data());i.carousel(s),t.preventDefault()})})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.collapse.defaults,n),this.options.parent&&(this.$parent=e(this.options.parent)),this.options.toggle&&this.toggle()};t.prototype={constructor:t,dimension:function(){var e=this.$element.hLine truncated
|
||||
+159
-77
@@ -1,94 +1,32 @@
|
||||
@charset "utf-8";
|
||||
body {
|
||||
padding-top: 60px;
|
||||
padding-top: 80px;
|
||||
}
|
||||
|
||||
footer {
|
||||
background-color: #F5F5F5;
|
||||
padding: 40px 0;
|
||||
height: 100px;
|
||||
margin-top: 40px;
|
||||
color: #999999;
|
||||
.container {
|
||||
max-width: 970px;
|
||||
}
|
||||
|
||||
section {
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
.manual-example {
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
||||
|
||||
.manual-example td {
|
||||
white-space: pre-wrap;
|
||||
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
|
||||
}
|
||||
|
||||
.manual-example td.jqprogram {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.manual-example th {
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.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;
|
||||
bottom: 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
/* index.liquid *******************************************/
|
||||
|
||||
#blurb {
|
||||
padding-top: 40px;
|
||||
padding-right: 50px;
|
||||
}
|
||||
|
||||
#blurb p {
|
||||
font-size: 20pt;
|
||||
}
|
||||
|
||||
#blurb .btn-group {
|
||||
margin-top: 20px;
|
||||
p {
|
||||
font-size: 1.9em;
|
||||
}
|
||||
.btn-group {
|
||||
margin: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
#multiblurb {
|
||||
line-height: 1.7;
|
||||
text-align: center;
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
#multiblurb code {
|
||||
border: 0;
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
h3 code {
|
||||
border: 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
footer {
|
||||
text-align: center;
|
||||
code {
|
||||
border: 0;
|
||||
font-size: 12pt;
|
||||
}
|
||||
}
|
||||
|
||||
#news {
|
||||
@@ -96,4 +34,148 @@ footer {
|
||||
.date {
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* default.liquid *****************************************/
|
||||
|
||||
.tutorial-example {
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
pre {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
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;
|
||||
}
|
||||
.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 {
|
||||
li a {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.manual-example table {
|
||||
border-top: 1px solid #E5E5E5;
|
||||
td {
|
||||
white-space: pre-wrap;
|
||||
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
|
||||
}
|
||||
td.jqprogram {
|
||||
font-weight: bold;
|
||||
}
|
||||
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;
|
||||
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,.2);
|
||||
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
}
|
||||
|
||||
.tt-suggestion {
|
||||
padding: 3px 20px;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
color: #fff;
|
||||
background-color: #446e9b;
|
||||
}
|
||||
&.tt-cursor {
|
||||
color: #fff;
|
||||
background-color: #446e9b;
|
||||
}
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +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) {
|
||||
// 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(/^'(.+)'$/, '$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>');
|
||||
});
|
||||
});
|
||||
+1
-10
@@ -1,18 +1,9 @@
|
||||
# The key value pairs found below are available within the templates.
|
||||
|
||||
:url: http://stedolan.github.io/jq
|
||||
:url: https://stedolan.github.io/jq
|
||||
|
||||
# This line is modified by the Makefile. To change the version number,
|
||||
# edit the Autoconf version number at the top of configure.ac
|
||||
jq_version: "1.4-2-g15c4a7f-dirty"
|
||||
|
||||
root: '/jq'
|
||||
footer: |
|
||||
|
||||
This website is made with [Bonsai](http://www.tinytree.info) and
|
||||
[Twitter Bootstrap](http://twitter.github.com/bootstrap/), themed
|
||||
with [Bootswatch](http://bootswatch.com).
|
||||
|
||||
jq is licensed under the MIT license (code) and the
|
||||
[CC-BY-3.0](http://creativecommons.org/licenses/by/3.0/) license
|
||||
(docs).
|
||||
Vendored
+10
-10
@@ -1,34 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
{% include "shared/head" %}
|
||||
{% include "shared/head" %}
|
||||
|
||||
<body id="{{slug}}">
|
||||
{% include "shared/header" %}
|
||||
|
||||
{% include "shared/navbar" %}
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="row">
|
||||
<h1>{{headline}}</h1>
|
||||
{% for item in body %}
|
||||
{% if item.text %}
|
||||
{{ item.text | replace: '$JQ_VERSION', jq_version | markdownify }}
|
||||
{% endif %}
|
||||
|
||||
{% if item.command %}
|
||||
|
||||
|
||||
{% if item.command %}
|
||||
{% capture resultID %}{{ "result" | unique}}{% endcapture %}
|
||||
<div class="tutorial-example">
|
||||
<div class="accordion-heading">
|
||||
<pre>{{item.command}}</pre>
|
||||
<a data-toggle="collapse" href="#{{resultID}}">Show result</a>
|
||||
</div>
|
||||
<div id="{{resultID}}" class="accordion-body collapse"><pre>{{item.result}}</pre></div>
|
||||
<div id="{{resultID}}" class="accordion-body collapse">
|
||||
<pre>{{item.result}}</pre>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% include "shared/footer" %}
|
||||
|
||||
|
||||
{% include "shared/footer" %}
|
||||
</body>
|
||||
</html>
|
||||
Vendored
+45
-32
@@ -1,60 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
{% include "shared/head" %}
|
||||
{% include "shared/head" %}
|
||||
|
||||
<body id="{{slug}}">
|
||||
{% include "shared/header" %}
|
||||
|
||||
{% include "shared/navbar" %}
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="hero-unit">
|
||||
<img src="{{root}}/jq.png" style="width: 400px; height: 220px; float: left; margin-right: 60px">
|
||||
<div id="blurb">
|
||||
{{blurb | markdownify}}
|
||||
|
||||
<div class="btn-group" style="float:right">
|
||||
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
Download jq-{{jq_version}}
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{{root}}/download/linux64/jq">Linux (64-bit)</a></li>
|
||||
<li><a href="{{root}}/download/osx64/jq">OS X (64-bit)</a></li>
|
||||
<li><a href="{{root}}/download/solaris11-64/jq">Solaris (64-bit)</a></li>
|
||||
<li><a href="{{root}}/download/win64/jq.exe">Windows (64-bit)</a></li>
|
||||
<li><a href="{{root}}/download/">Other platforms, older versions, and source</a></li>
|
||||
</ul>
|
||||
<div class="jumbotron">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<img src="{{root}}/jq.png" class="img-responsive" alt="jq logo"
|
||||
width="400" height="220">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div id="blurb">
|
||||
{{blurb | markdownify}}
|
||||
|
||||
<div class="btn-group" style="float:right">
|
||||
<a class="btn btn-primary" href="http://jqplay.org">
|
||||
Try online at jqplay.org!
|
||||
</a>
|
||||
<div class="btn-toolbar" role="toolbar">
|
||||
<div class="btn-group" role="group">
|
||||
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
Download jq 1.5
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64">Linux (64-bit)</a></li>
|
||||
<li><a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-osx-amd64">OS X (64-bit)</a></li>
|
||||
<li><a href="https://github.com/stedolan/jq/releases/download/jq-1.5/jq-win64.exe">Windows (64-bit)</a></li>
|
||||
<li><a href="/jq/download/">Other platforms, older versions, and source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-primary" href="https://jqplay.org">
|
||||
Try online at jqplay.org!
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row" id="multiblurb">
|
||||
<div class="span4">{{body1 | markdownify}}</div>
|
||||
<div class="span4">{{body2 | markdownify}}</div>
|
||||
<div class="span4">{{body3 | markdownify}}</div>
|
||||
<div class="col-sm-4">{{body1 | markdownify}}</div>
|
||||
<div class="col-sm-4">{{body2 | markdownify}}</div>
|
||||
<div class="col-sm-4">{{body3 | markdownify}}</div>
|
||||
</div>
|
||||
|
||||
<div class="row" style="text-align:center; margin-top: 30px">
|
||||
{{tail | markdownify}}
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<h2>News</h2>
|
||||
<div id="news">
|
||||
<ul>
|
||||
{% for item in news %}
|
||||
<li><span class="date">{{ item.date | date: '%m %B %Y' }}</span>{{item.body | markdownify}}</li>
|
||||
<li>
|
||||
<span class="date">{{item.date}}</span>
|
||||
{{item.body | markdownify}}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% include "shared/footer" %}
|
||||
|
||||
{% include "shared/footer" %}
|
||||
</body>
|
||||
</html>
|
||||
Vendored
+67
-90
@@ -1,122 +1,99 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
{% include "shared/head" %}
|
||||
{% include "shared/head" %}
|
||||
|
||||
<body id="{{slug}}" data-spy="scroll" data-target="#navcolumn" data-offset="100">
|
||||
{% include "shared/header" %}
|
||||
{% include "shared/navbar" %}
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="span3" id="navcolumn">
|
||||
<div class="affix">
|
||||
<div class="affix" id="navcolumn">
|
||||
<h4>Contents</h4>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
{% for section in sections %}
|
||||
<li {% if forloop.first %} class="active" {% endif %}>
|
||||
<a href="#{{section.title | sanitize}}">{{section.title}}</a>
|
||||
<li>
|
||||
<a href="#{{section.title | section_id}}">{{section.title}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<form class="form-search">
|
||||
<script type="text/javascript">
|
||||
var section_map = {
|
||||
{% for section in sections %}
|
||||
{% for entry in section.entries %}
|
||||
{{entry.title | json}} : {{entry.title | sanitize | json}},
|
||||
{% endfor %}
|
||||
{{section.title | json}} : {{section.title | sanitize | json}}
|
||||
{% unless forloop.last %},{% endunless %}
|
||||
{% endfor %}
|
||||
};
|
||||
var section_names = $.map(section_map, function(v,k){return k});
|
||||
$(function(){
|
||||
$('#searchbox').typeahead({source: section_names})
|
||||
$('#searchbox').change(function() {
|
||||
if ($(this).val() in section_map) {
|
||||
location.hash = '#' + section_map[$(this).val()];
|
||||
}
|
||||
});
|
||||
});
|
||||
// add "Run" button to execute examples on jqplay.org
|
||||
$(function() {
|
||||
$.each($('table.manual-example'), 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><th><a href="' + url + '" class="btn btn-primary btn-small">Run</a></th><th></th></tr><tr><th></th><th></th></tr>');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<form class="form-group" onsubmit="go_to_section(); return false;">
|
||||
<input type="text"
|
||||
class="input-medium search-query"
|
||||
placeholder="Search"
|
||||
autocomplete="off"
|
||||
id="searchbox">
|
||||
class="form-control"
|
||||
placeholder="Search"
|
||||
autocomplete="off"
|
||||
id="searchbox">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span9">
|
||||
|
||||
<div id="manualcontent">
|
||||
<h1>{{headline}}</h1>
|
||||
{{ history | markdownify }}
|
||||
{{ body | markdownify }}
|
||||
{% for section in sections %}
|
||||
<section id="{{section.title | sanitize}}">
|
||||
<section id="{{section.title | section_id}}">
|
||||
<h2>{{section.title}}</h2>
|
||||
{{section.body | markdownify}}
|
||||
{% for entry in section.entries %}
|
||||
<section id="{{entry.title | sanitize}}">
|
||||
<h3>
|
||||
{{entry.title | markdownify}}
|
||||
{% if entry.subtitle %}<small>{{entry.subtitle}}</small>{% endif %}
|
||||
</h3>
|
||||
{{entry.body | markdownify}}
|
||||
<section id="{{entry.title | entry_id}}">
|
||||
<h3>
|
||||
{{entry.title | markdownify | no_paragraph}}
|
||||
{% if entry.subtitle %}<small>{{entry.subtitle}}</small>{% endif %}
|
||||
</h3>
|
||||
{{entry.body | markdownify}}
|
||||
|
||||
{% if entry.examples %}
|
||||
<div>
|
||||
{% capture exampleID %}{{ "" | unique }}{% endcapture %}
|
||||
<a data-toggle="collapse" href="#example{{exampleID}}">
|
||||
<i class="icon-chevron-right"></i>
|
||||
{% if entry.examples[1] %}Examples{%else%}Example{%endif%}
|
||||
</a>
|
||||
<div id="example{{exampleID}}" class="collapse">
|
||||
|
||||
{% for example in entry.examples %}
|
||||
<table class="manual-example">
|
||||
<tr><th></th><td class="jqprogram">jq '{{example.program | escape}}'</td></tr>
|
||||
<tr><th>Input</th><td>{{example.input | escape}}</td></tr>
|
||||
{% unless example.output[0] %}
|
||||
<tr>
|
||||
<th>Output</th>
|
||||
<td><i>none</i></td>
|
||||
</tr>
|
||||
{% endunless %}
|
||||
{% for output in example.output %}
|
||||
<tr>
|
||||
{% if forloop.index == 1 %}
|
||||
<th>Output</th>
|
||||
{% else %}
|
||||
<th></th>
|
||||
{% endif %}
|
||||
<td>{{output | escape}}</td>
|
||||
</tr>
|
||||
{% if entry.examples %}
|
||||
<div>
|
||||
{% capture exampleID %}{{ "" | unique }}{% endcapture %}
|
||||
<a data-toggle="collapse" href="#example{{exampleID}}">
|
||||
<i class="glyphicon glyphicon-chevron-right"></i>
|
||||
{% if entry.examples[1] %}Examples{%else%}Example{%endif%}
|
||||
</a>
|
||||
<div id="example{{exampleID}}" class="manual-example collapse">
|
||||
{% for example in entry.examples %}
|
||||
<table>
|
||||
<tr><th></th><td class="jqprogram">jq '{{example.program | escape}}'</td></tr>
|
||||
<tr><th>Input</th><td>{{example.input | escape}}</td></tr>
|
||||
{% unless example.output[0] %}
|
||||
<tr>
|
||||
<th>Output</th>
|
||||
<td><i>none</i></td>
|
||||
</tr>
|
||||
{% endunless %}
|
||||
{% for output in example.output %}
|
||||
<tr>
|
||||
{% if forloop.index == 1 %}
|
||||
<th>Output</th>
|
||||
{% else %}
|
||||
<th></th>
|
||||
{% endif %}
|
||||
<td>{{output | escape}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endfor %}
|
||||
|
||||
</table>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endfor %}
|
||||
</section>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
{% include "shared/footer" %}
|
||||
|
||||
{% include "shared/footer" %}
|
||||
<script>
|
||||
var section_map = {
|
||||
{% for section in sections %}
|
||||
{% for entry in section.entries %}
|
||||
{{entry.title | search_id | json}} : {{entry.title | entry_id | json}},
|
||||
{% endfor %}
|
||||
{{section.title | search_id | json}} : {{section.title | section_id | json}}
|
||||
{% unless forloop.last %},{% endunless %}
|
||||
{% endfor %}
|
||||
};
|
||||
</script>
|
||||
<script src="{{root}}/js/manual-search.js"></script>
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
||||
Vendored
+10
-5
@@ -1,5 +1,10 @@
|
||||
<footer>
|
||||
<div class="container">
|
||||
{{ footer | markdownify }}
|
||||
</div>
|
||||
</footer>
|
||||
<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>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>
|
||||
|
||||
<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>
|
||||
Vendored
+17
-12
@@ -1,12 +1,17 @@
|
||||
<head>
|
||||
<meta charset=UTF-8>
|
||||
<title>{{headline}}</title>
|
||||
<link rel="stylesheet" href="{{root}}/bootstrap/css/bootstrap.css" type="text/css">
|
||||
<link rel="stylesheet" href="{{root}}/css/base.css" type="text/css">
|
||||
<!--[if IE]>
|
||||
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
|
||||
<script src="{{root}}/bootstrap/js/bootstrap.js"></script>
|
||||
|
||||
</head>
|
||||
<head>
|
||||
<script>
|
||||
if ((window.location.host == "stedolan.github.io") && (window.location.protocol != "https:"))
|
||||
window.location.protocol = "https";
|
||||
</script>
|
||||
<meta charset="utf-8">
|
||||
<title>{{headline}}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<link rel="canonical" href="{{url}}{{permalink | remove:'/index'}}" />
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/spacelab/bootstrap.min.css" rel="stylesheet" integrity="sha256-j7Dtnd7ZjexEiPNbscbopFn9+Cs0b3TLipKsWAPHZIM= sha512-RFhfi6P8zWMAJrEGU+CPjuxPh3r/UUBGqQ+/o6WKPIVZmQqeOipGotH2ihRULuQ8wsMBoK15TSZqc/7VYWyuIw==" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="{{root}}/css/base.css" type="text/css">
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
Vendored
-26
@@ -1,26 +0,0 @@
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="brand" href="{{root}}/">jq</a>
|
||||
<div class="nav-collapse collapse">
|
||||
<ul class="nav">
|
||||
{% for item in navigation %}
|
||||
<li {% if item.permalink == permalink %} class="active" {% endif %}>
|
||||
<a href="{{root}}{{item.permalink}}">{{item.name}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li><a href="https://github.com/stedolan/jq/issues">Issues</a></li>
|
||||
<li><a href="https://github.com/stedolan/jq">Source</a></li>
|
||||
<li><a href="http://jqplay.org">Try online!</a></li>
|
||||
<li><a href="https://raw.githubusercontent.com/stedolan/jq/master/NEWS">News</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#nav-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="{{root}}/">jq</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse" id="nav-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
{% for item in navigation %}
|
||||
<li {% if item.permalink == permalink %} class="active" {% endif %}>
|
||||
<a href="{{root}}{{item.permalink}}">{{item.name}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li><a href="https://github.com/stedolan/jq/issues">Issues</a></li>
|
||||
<li><a href="https://github.com/stedolan/jq">Source</a></li>
|
||||
<li><a href="https://jqplay.org">Try online!</a></li>
|
||||
<li><a href="https://raw.githubusercontent.com/stedolan/jq/master/NEWS">News</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,39 +0,0 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "JQ" "1" "May 2013" "" ""
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBjq\fR \- Command\-line JSON processor
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
\fBjq\fR can transform JSON in various ways, by selecting, iterating, reducing and otherwise mangling JSON documents\.
|
||||
.
|
||||
.P
|
||||
This version of \fBjq\fR was built without a manual, so this manpage is a stub\. For full documentation of the \fBjq\fR language, see:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
http://stedolan\.github\.com/jq
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "BUGS"
|
||||
Presumably\. Report them or discuss them at:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
https://github\.com/stedolan/jq/issues
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "AUTHOR"
|
||||
Stephen Dolan \fB<mu@netsoc\.tcd\.ie>\fR
|
||||
+274
-73
@@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "JQ" "1" "July 2015" "" ""
|
||||
.TH "JQ" "1" "February 2017" "" ""
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBjq\fR \- Command\-line JSON processor
|
||||
@@ -52,7 +52,7 @@ Output the jq version and exit with zero\.
|
||||
\fB\-\-seq\fR:
|
||||
.
|
||||
.IP
|
||||
Use the \fBapplication/json\-seq\fR MIME type scheme for separating JSON texts in jq\'s input and output\. This means that an ASCII RS (record separator) character is printed before each value on output and an ASCII LF (line feed) is printed after every output\. Input JSON texts that fail to parse are ignored (but warned about), discarding all subsequent input until the next RS\. This more also parses the output of jq without the \fB\-\-seq\fR option\.
|
||||
Use the \fBapplication/json\-seq\fR MIME type scheme for separating JSON texts in jq\'s input and output\. This means that an ASCII RS (record separator) character is printed before each value on output and an ASCII LF (line feed) is printed after every output\. Input JSON texts that fail to parse are ignored (but warned about), discarding all subsequent input until the next RS\. This mode also parses the output of jq without the \fB\-\-seq\fR option\.
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
\fB\-\-stream\fR:
|
||||
@@ -178,13 +178,13 @@ This option reads all the JSON texts in the named file and binds an array of the
|
||||
Do not use\. Use \fB\-\-slurpfile\fR instead\.
|
||||
.
|
||||
.IP
|
||||
(This option is like \fB\-\-slurpfile\fR, but when the file has just one text, then that is used, else an array of texts is used as in \fB\-\-slurfile\fR\.)
|
||||
(This option is like \fB\-\-slurpfile\fR, but when the file has just one text, then that is used, else an array of texts is used as in \fB\-\-slurpfile\fR\.)
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
\fB\-\-run\-tests [filename]\fR:
|
||||
.
|
||||
.IP
|
||||
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 consts 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\.
|
||||
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\.
|
||||
.
|
||||
.IP
|
||||
Be warned that this option can change backwards\-incompatibly\.
|
||||
@@ -277,7 +277,7 @@ The \fB\.[10:15]\fR syntax can be used to return a subarray of an array or subst
|
||||
The \fB\.[2]\fR 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
|
||||
The \fB\.foo\fR syntax only works for simply keys i\.e\. keys that are all alphanumeric characters\. \fB\.[<string>]\fR works with keys that contain special charactors such as colons and dots\. For example \fB\.["foo::bar"]\fR and \fB\.["foo\.bar"]\fR work while \fB\.foo::bar\fR and \fB\.foo\.bar\fR would not\.
|
||||
The \fB\.foo\fR syntax only works for simply keys i\.e\. keys that are all alphanumeric characters\. \fB\.[<string>]\fR works with keys that contain special characters such as colons and dots\. For example \fB\.["foo::bar"]\fR and \fB\.["foo\.bar"]\fR work while \fB\.foo::bar\fR and \fB\.foo\.bar\fR would not\.
|
||||
.
|
||||
.P
|
||||
The \fB?\fR "operator" can also be used with the slice operator, as in \fB\.[10:15]?\fR, which outputs values where the inputs are slice\-able\.
|
||||
@@ -376,6 +376,12 @@ The | operator combines two filters by feeding the output(s) of the one on the l
|
||||
.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 \fB\.[] | \.foo\fR retrieves the "foo" field of each element of the input array\.
|
||||
.
|
||||
.P
|
||||
Note that \fB\.a\.b\.c\fR is the same as \fB\.a | \.b | \.c\fR\.
|
||||
.
|
||||
.P
|
||||
Note too that \fB\.\fR is the input value at the particular stage in a "pipeline", specifically: where the \fB\.\fR expression appears\. Thus \fB\.a | \. | \.b\fR is the same as \fB\.a\.b\fR, as the \fB\.\fR in the middle refers to whatever value \fB\.a\fR produced\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
@@ -388,6 +394,21 @@ jq \'\.[] | \.name\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "Parenthesis"
|
||||
Parenthesis work as a grouping operator just as in any typical programming language\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'(\. + 2) * 5\'
|
||||
1
|
||||
=> 15
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "TYPES AND VALUES"
|
||||
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"\.
|
||||
.
|
||||
@@ -573,7 +594,7 @@ jq \'{a: 1} + {b: 2} + {c: 3} + {a: 42}\'
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "Subtraction \- \-"
|
||||
As well as normal arithmetic subtraction on numbers, the \fB\-\fR operator can be used on arrays to remove all occurences of the second array\'s elements from the first array\.
|
||||
As well as normal arithmetic subtraction on numbers, the \fB\-\fR operator can be used on arrays to remove all occurrences of the second array\'s elements from the first array\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@@ -592,13 +613,13 @@ jq \'\. \- ["xml", "yaml"]\'
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "Multiplication, division, modulo \- *, /, and %"
|
||||
These operators only work on numbers, and do the expected\.
|
||||
These infix operators behave as expected when given two numbers\. Division by zero raises an error\. \fBx % y\fR computes x modulo y\.
|
||||
.
|
||||
.P
|
||||
Multiplying a string by a number produces the concatenation of that string that many times\.
|
||||
Multiplying a string by a number produces the concatenation of that string that many times\. \fB"x" * 0\fR produces \fBnull\fR\.
|
||||
.
|
||||
.P
|
||||
Dividing a string by another splits the first using the second as separators\. Division by zero raises an error\.
|
||||
Dividing a string by another splits the first using the second as separators\.
|
||||
.
|
||||
.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\.
|
||||
@@ -647,6 +668,21 @@ jq \'\.[] | length\' [[1,2], "string", {"a":2}, null] => 2, 6, 1, 0
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "utf8bytelength"
|
||||
The builtin function \fButf8bytelength\fR outputs the number of bytes used to encode a string in UTF\-8\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'utf8bytelength\'
|
||||
"\eu03bc"
|
||||
=> 2
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "keys, keys_unsorted"
|
||||
The builtin function \fBkeys\fR, when given an object, returns its keys in an array\.
|
||||
.
|
||||
@@ -698,7 +734,7 @@ jq \'map(has(2))\'
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "in"
|
||||
The builtin function \fBin\fR returns 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 \fBhas\fR\.
|
||||
The builtin function \fBin\fR 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 \fBhas\fR\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@@ -716,8 +752,33 @@ jq \'map(in([0,1]))\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "map(x), map_values(x)"
|
||||
For any filter \fBx\fR, \fBmap(x)\fR will run that filter for each element of the input array, and return the outputs in a new array\. \fBmap(\.+1)\fR will increment each element of an array of numbers\.
|
||||
.
|
||||
.P
|
||||
Similarly, \fBmap_values(x)\fR will run that filter for each element, but it will return an object when an object is passed\.
|
||||
.
|
||||
.P
|
||||
\fBmap(x)\fR is equivalent to \fB[\.[] | x]\fR\. In fact, this is how it\'s defined\. Similarly, \fBmap_values(x)\fR is defined as \fB\.[] |= x\fR\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'map(\.+1)\'
|
||||
[1,2,3]
|
||||
=> [2,3,4]
|
||||
|
||||
jq \'map_values(\.+1)\'
|
||||
{"a": 1, "b": 2, "c": 3}
|
||||
=> {"a": 2, "b": 3, "c": 4}
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "path(path_expression)"
|
||||
Outputs array representations of the given path expression in \fB\.\fR\. The outputs are arrays of strings (keys in objects0 and/or numbers (array indices\.
|
||||
Outputs array representations of the given path expression in \fB\.\fR\. The outputs are arrays of strings (object keys) and/or numbers (array indices)\.
|
||||
.
|
||||
.P
|
||||
Path expressions are jq expressions like \fB\.a\fR, but also \fB\.[]\fR\. There are two types of path expressions: ones that can match exactly, and ones that cannot\. For example, \fB\.a\.b\.c\fR is an exact match path expression, while \fB\.a[]\.b\fR is not\.
|
||||
@@ -766,11 +827,68 @@ jq \'del(\.[1, 2])\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "getpath(PATHS)"
|
||||
The builtin function \fBgetpath\fR outputs the values in \fB\.\fR found at each path in \fBPATHS\fR\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'getpath(["a","b"])\'
|
||||
null
|
||||
=> null
|
||||
|
||||
jq \'[getpath(["a","b"], ["a","c"])]\'
|
||||
{"a":{"b":0, "c":1}}
|
||||
=> [0, 1]
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "setpath(PATHS; VALUE)"
|
||||
The builtin function \fBsetpath\fR sets the \fBPATHS\fR in \fB\.\fR to \fBVALUE\fR\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'setpath(["a","b"]; 1)\'
|
||||
null
|
||||
=> {"a": {"b": 1}}
|
||||
|
||||
jq \'setpath(["a","b"]; 1)\'
|
||||
{"a":{"b":0}}
|
||||
=> {"a": {"b": 1}}
|
||||
|
||||
jq \'setpath([0,"a"]; 1)\'
|
||||
null
|
||||
=> [{"a":1}]
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "delpaths(PATHS)"
|
||||
The builtin function \fBdelpaths\fR sets the \fBPATHS\fR in \fB\.\fR\. \fBPATHS\fR must be an array of paths, where each path is an array of strings and numbers\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'delpaths([["a","b"]])\'
|
||||
{"a":{"b":1},"x":{"y":2}}
|
||||
=> {"a":{},"x":{"y":2}}
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "to_entries, from_entries, with_entries"
|
||||
These functions convert between an object and an array of key\-value pairs\. If \fBto_entries\fR is passed an object, then for each \fBk: v\fR entry in the input, the output array includes \fB{"key": k, "value": v}\fR\.
|
||||
.
|
||||
.P
|
||||
\fBfrom_entries\fR does the opposite conversion, and \fBwith_entries(foo)\fR is a shorthand for \fBto_entries | map(foo) | from_entries\fR, useful for doing some operation to all keys and values of an object\. \fBfrom_entries\fR accepts key, Key, Name, value and Value as keys\.
|
||||
\fBfrom_entries\fR does the opposite conversion, and \fBwith_entries(foo)\fR is a shorthand for \fBto_entries | map(foo) | from_entries\fR, useful for doing some operation to all keys and values of an object\. \fBfrom_entries\fR accepts key, Key, name, Name, value and Value as keys\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@@ -869,31 +987,6 @@ jq \'try error("\e($__loc__)") catch \.\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "map(x), map_values(x)"
|
||||
For any filter \fBx\fR, \fBmap(x)\fR will run that filter for each element of the input array, and produce the outputs a new array\. \fBmap(\.+1)\fR will increment each element of an array of numbers\.
|
||||
.
|
||||
.P
|
||||
Similarly, \fBmap_values(x)\fR will run that filter for each element, but it will return an object when an object is passed\.
|
||||
.
|
||||
.P
|
||||
\fBmap(x)\fR is equivalent to \fB[\.[] | x]\fR\. In fact, this is how it\'s defined\. Similarly, \fBmap_values(x)\fR is defined as \fB\.[] |= x\fR\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'map(\.+1)\'
|
||||
[1,2,3]
|
||||
=> [2,3,4]
|
||||
|
||||
jq \'map_values(\.+1)\'
|
||||
{"a": 1, "b": 2, "c": 3}
|
||||
=> {"a": 2, "b": 3, "c": 4}
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "paths, paths(node_filter), leaf_paths"
|
||||
\fBpaths\fR outputs the paths to all the elements in its input (except it does not output the empty list, representing \. itself)\.
|
||||
.
|
||||
@@ -946,7 +1039,7 @@ jq \'add\'
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "any, any(condition), any(generator; condition)"
|
||||
The filter \fBany\fR takes as input an array of boolean values, and produces \fBtrue\fR as output if any of the the elements of the array is \fBtrue\fR\.
|
||||
The filter \fBany\fR takes as input an array of boolean values, and produces \fBtrue\fR as output if any of the elements of the array are \fBtrue\fR\.
|
||||
.
|
||||
.P
|
||||
If the input is an empty array, \fBany\fR returns \fBfalse\fR\.
|
||||
@@ -978,7 +1071,7 @@ jq \'any\'
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "all, all(condition), all(generator; condition)"
|
||||
The filter \fBall\fR takes as input an array of boolean values, and produces \fBtrue\fR as output if all of the the elements of the array are \fBtrue\fR\.
|
||||
The filter \fBall\fR takes as input an array of boolean values, and produces \fBtrue\fR as output if all of the elements of the array are \fBtrue\fR\.
|
||||
.
|
||||
.P
|
||||
The \fBall(condition)\fR form applies the given condition to the elements of the input array\.
|
||||
@@ -1009,7 +1102,7 @@ jq \'all\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "[Requires 1\.5] flatten, flatten(depth)"
|
||||
.SS "flatten, flatten(depth)"
|
||||
The filter \fBflatten\fR 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
|
||||
@@ -1528,7 +1621,7 @@ jq \'implode\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "split"
|
||||
.SS "split(str)"
|
||||
Splits an input string on the separator argument\.
|
||||
.
|
||||
.IP "" 4
|
||||
@@ -1546,6 +1639,9 @@ jq \'split(", ")\'
|
||||
.SS "join(str)"
|
||||
Joins the array of elements given as input, using the argument as separator\. It is the inverse of \fBsplit\fR: that is, running \fBsplit("foo") | join("foo")\fR over any input string returns said input string\.
|
||||
.
|
||||
.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\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
@@ -1553,6 +1649,10 @@ Joins the array of elements given as input, using the argument as separator\. It
|
||||
jq \'join(", ")\'
|
||||
["a","b,c,d","e"]
|
||||
=> "a, b,c,d, e"
|
||||
|
||||
jq \'join(" ")\'
|
||||
["a",1,2\.3,true,null,false]
|
||||
=> "a 1 2\.3 true false"
|
||||
.
|
||||
.fi
|
||||
.
|
||||
@@ -1664,6 +1764,25 @@ jq \'recurse(\. * \.; \. < 20)\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "walk(f)"
|
||||
The \fBwalk(f)\fR 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\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'walk(if type == "array" then sort else \. end)\'
|
||||
[[4, 1, 7], [8, 5, 2], [3, 6, 9]]
|
||||
=> [[1,4,7],[2,5,8],[3,6,9]]
|
||||
|
||||
jq \'walk( if type == "object" then with_entries( \.key |= sub( "^_+"; "") ) else \. end )\'
|
||||
[ { "_a": { "__b": 2 } } ]
|
||||
=> [{"a":{"b":2}}]
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "\.\."
|
||||
Short\-hand for \fBrecurse\fR without arguments\. This is intended to resemble the XPath \fB//\fR operator\. Note that \fB\.\.a\fR does not work; use \fB\.\.|a\fR instead\. In the example below we use \fB\.\.|\.a?\fR to find all the values of object keys "a" in any object found "below" \fB\.\fR\.
|
||||
.
|
||||
@@ -1783,7 +1902,7 @@ Calls \fBtostring\fR, see that function for details\.
|
||||
\fB@json\fR:
|
||||
.
|
||||
.IP
|
||||
Serialises the input as JSON\.
|
||||
Serializes the input as JSON\.
|
||||
.
|
||||
.TP
|
||||
\fB@html\fR:
|
||||
@@ -1828,7 +1947,7 @@ This syntax can be combined with string interpolation in a useful way\. You can
|
||||
.
|
||||
.nf
|
||||
|
||||
@uri "http://www\.google\.com/search?q=\e(\.search)"
|
||||
@uri "https://www\.google\.com/search?q=\e(\.search)"
|
||||
.
|
||||
.fi
|
||||
.
|
||||
@@ -1841,7 +1960,7 @@ will produce the following output for the input \fB{"search":"what is jq?"}\fR:
|
||||
.
|
||||
.nf
|
||||
|
||||
"http://www\.google\.com/search?q=what%20is%20jq%3F"
|
||||
"https://www\.google\.com/search?q=what%20is%20jq%3F"
|
||||
.
|
||||
.fi
|
||||
.
|
||||
@@ -1922,6 +2041,45 @@ jq \'strptime("%Y\-%m\-%dT%H:%M:%SZ")|mktime\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "SQL\-Style Operators"
|
||||
jq provides a few SQL\-style operators\.
|
||||
.
|
||||
.TP
|
||||
INDEX(stream; index_expression):
|
||||
.
|
||||
.IP
|
||||
This builtin produces an object whose keys are computed by the given index expression applied to each value from the given stream\.
|
||||
.
|
||||
.TP
|
||||
JOIN($idx; stream; idx_expr; join_expr):
|
||||
.
|
||||
.IP
|
||||
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\.
|
||||
.
|
||||
.TP
|
||||
JOIN($idx; stream; idx_expr):
|
||||
.
|
||||
.IP
|
||||
Same as \fBJOIN($idx; stream; idx_expr; \.)\fR\.
|
||||
.
|
||||
.TP
|
||||
JOIN($idx; idx_expr):
|
||||
.
|
||||
.IP
|
||||
This builtin joins the input \fB\.\fR to the given index, applying the given index expression to \fB\.\fR to compute the index key\. The join operation is as described above\.
|
||||
.
|
||||
.TP
|
||||
IN(s):
|
||||
.
|
||||
.IP
|
||||
This builtin outputs \fBtrue\fR if \fB\.\fR appears in the given stream, otherwise it outputs \fBfalse\fR\.
|
||||
.
|
||||
.TP
|
||||
IN(source; s):
|
||||
.
|
||||
.IP
|
||||
This builtin outputs \fBtrue\fR if any value in the source stream appears in the second stream, otherwise it outputs \fBfalse\fR\.
|
||||
.
|
||||
.SH "CONDITIONALS AND COMPARISONS"
|
||||
.
|
||||
.SS "==, !="
|
||||
@@ -1949,7 +2107,7 @@ jq \'\.[] == 1\'
|
||||
Checking for false or null is a simpler notion of "truthiness" than is found in Javascript or Python, but it means that you\'ll sometimes have to be more explicit about the condition you want: you can\'t test whether, e\.g\. a string is empty using \fBif \.name then A else B end\fR, you\'ll need something more like \fBif (\.name | length) > 0 then A else B end\fR instead\.
|
||||
.
|
||||
.P
|
||||
If the condition A produces multiple results, it is considered "true" if any of those results is not false or null\. If it produces zero results, it\'s considered false\.
|
||||
If the condition \fBA\fR produces multiple results, then \fBB\fR is evaluated once for each result that is not false or null, and \fBC\fR is evaluated once for each false or null\.
|
||||
.
|
||||
.P
|
||||
More cases can be added to an if using \fBelif A then B\fR syntax\.
|
||||
@@ -1965,18 +2123,7 @@ jq \'if \. == 0 then
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
"zero" elif \. == 1 then "one" else "many" end\'
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
2
|
||||
=> "many"
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
"zero" elif \. == 1 then "one" else "many" end\' 2 => "many"
|
||||
.
|
||||
.SS ">, >=, <=, <"
|
||||
The comparison operators \fB>\fR, \fB>=\fR, \fB<=\fR, \fB<\fR return whether their left argument is greater than, greater than or equal to, less than or equal to or less than their right argument (respectively)\.
|
||||
@@ -2232,7 +2379,7 @@ jq \-n \'("test", "TEst", "teST", "TEST") | test( "(?i)te(?\-i)st" )\'
|
||||
.P
|
||||
evaluates to: true, true, false, false\.
|
||||
.
|
||||
.SS "[Requires 1\.5] test(val), test(regex; flags)"
|
||||
.SS "test(val), test(regex; flags)"
|
||||
Like \fBmatch\fR, but does not return match objects, only \fBtrue\fR or \fBfalse\fR for whether or not the regex matches the input\.
|
||||
.
|
||||
.IP "" 4
|
||||
@@ -2251,7 +2398,7 @@ jq \'\.[] | test("a b c # spaces are ignored"; "ix")\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "[Requires 1\.5] match(val), match(regex; flags)"
|
||||
.SS "match(val), match(regex; flags)"
|
||||
\fBmatch\fR outputs an object for each match it finds\. Matches have the following fields:
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
@@ -2316,7 +2463,7 @@ jq \'[ match("\."; "g")] | length\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "[Requires 1\.5] capture(val), capture(regex; flags)"
|
||||
.SS "capture(val), capture(regex; flags)"
|
||||
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\.
|
||||
.
|
||||
.IP "" 4
|
||||
@@ -2331,19 +2478,19 @@ jq \'capture("(?<a>[a\-z]+)\-(?<n>[0\-9]+)")\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "[Requires 1\.5] scan(regex), scan(regex; flags)"
|
||||
.SS "scan(regex), scan(regex; flags)"
|
||||
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 \fB[ expr ]\fR, e\.g\. \fB[ scan(regex) ]\fR\.
|
||||
.
|
||||
.SS "split(regex; flags)"
|
||||
For backwards compatibility, \fBsplit\fR splits on a string, not a regex\.
|
||||
.
|
||||
.SS "[Requires 1\.5] splits(regex), splits(regex; flags)"
|
||||
.SS "splits(regex), splits(regex; flags)"
|
||||
These provide the same results as their \fBsplit\fR counterparts, but as a stream instead of an array\.
|
||||
.
|
||||
.SS "[Requires 1\.5] sub(regex; tostring) sub(regex; string; flags)"
|
||||
.SS "sub(regex; tostring) sub(regex; string; flags)"
|
||||
Emit the string obtained by replacing the first match of regex in the input string with \fBtostring\fR, after interpolation\. \fBtostring\fR should be a jq string, and may contain references to named captures\. The named captures are, in effect, presented as a JSON object (as constructed by \fBcapture\fR) to \fBtostring\fR, so a reference to a captured variable named "x" would take the form: "(\.x)"\.
|
||||
.
|
||||
.SS "[Requires 1\.5] gsub(regex; string), gsub(regex; string; flags)"
|
||||
.SS "gsub(regex; string), gsub(regex; string; flags)"
|
||||
\fBgsub\fR is like \fBsub\fR but all the non\-overlapping occurrences of the regex are replaced by the string, after interpolation\.
|
||||
.
|
||||
.SH "ADVANCED FEATURES"
|
||||
@@ -2524,7 +2671,7 @@ def increment: \. + 1;
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
From then on, \fBincrement\fR 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:
|
||||
From then on, \fBincrement\fR 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:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@@ -2537,7 +2684,7 @@ def map(f): [\.[] | f];
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
Arguments are passed as filters, not as values\. The same argument may be referenced multiple times with different inputs (here \fBf\fR 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:
|
||||
Arguments are passed as \fIfilters\fR (functions with no arguments), \fInot\fR as values\. The same argument may be referenced multiple times with different inputs (here \fBf\fR 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:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@@ -2580,10 +2727,10 @@ def addvalue($f): \.\.\.;
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
With either definition, \fBaddvalue(\.foo)\fR will add the current input\'s \fB\.foo\fR field to each element of the array\.
|
||||
With either definition, \fBaddvalue(\.foo)\fR will add the current input\'s \fB\.foo\fR field to each element of the array\. Do note that calling \fBaddvalue(\.[])\fR will cause the \fBmap(\. + $f)\fR part to be evaluated once per value in the value of \fB\.\fR at the call site\.
|
||||
.
|
||||
.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\.
|
||||
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\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@@ -2601,6 +2748,12 @@ jq \'def addvalue(f): f as $x | map(\. + $x); addvalue(\.[0])\'
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SS "Scoping"
|
||||
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
|
||||
For example, in the following expression there is a binding which is visible "to the right" of it, \fB\.\.\. | \.*3 as $times_three | [\. + $times_three] | \.\.\.\fR, but not "to the left"\. Consider this expression now, \fB\.\.\. | (\.*3 as $times_three | [\.+ $times_three]) | \.\.\.\fR: here the binding \fB$times_three\fR is \fInot\fR visible past the closing parenthesis\.
|
||||
.
|
||||
.SS "Reduce"
|
||||
The \fBreduce\fR 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 \fB[3,2,1]\fR to this expression:
|
||||
.
|
||||
@@ -2624,10 +2777,25 @@ For each result that \fB\.[]\fR produces, \fB\. + $item\fR is run to accumulate
|
||||
0 | (3 as $item | \. + $item) |
|
||||
(2 as $item | \. + $item) |
|
||||
(1 as $item | \. + $item)
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
If the reduction update expression outputs \fBempty\fR (that is, no values), then the reduction state is left as\-is\. For example, \fBreduce range(4) as $n ({}; if \.==2 then empty else \.[$n|tostring] |= $n)\fR will produce \fB{"0":0,"1":1,"3":3}\fR\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
jq \'reduce \.[] as $item (0; \. + $item)\'
|
||||
[10,2,5,3]
|
||||
=> 20
|
||||
|
||||
jq \'reduce \.[] as $n ([]; if $n%2==0 then empty else \. + [$n] end)\'
|
||||
[0,1,2,3,4,5]
|
||||
=> [1,3,5]
|
||||
.
|
||||
.fi
|
||||
.
|
||||
@@ -2709,7 +2877,7 @@ jq \'[foreach \.[] as $item ([[],[]]; if $item == null then [[],\.[0]] else [(\.
|
||||
As described above, \fBrecurse\fR uses recursion, and any jq function can be recursive\. The \fBwhile\fR builtin is also implemented in terms of recursion\.
|
||||
.
|
||||
.P
|
||||
Tail calls are optmized 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\.
|
||||
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
|
||||
For example:
|
||||
@@ -2766,17 +2934,32 @@ jq \'def while(cond; update): def _while: if cond then \., (update | _while) els
|
||||
jq currently only has IEEE754 double\-precision (64\-bit) floating point number support\.
|
||||
.
|
||||
.P
|
||||
Besides simple arithmetic operators such as \fB+\fR, jq also has most standard math functions from the C math library\. C math functions that take a single input argument (e\.g\., \fBsin()\fR) are available as zero\-argument jq functions\. C math functions that take two input arguments (e\.g\., \fBpow()\fR) are available as two\-argument jq functions that ignore \fB\.\fR\.
|
||||
Besides simple arithmetic operators such as \fB+\fR, jq also has most standard math functions from the C math library\. C math functions that take a single input argument (e\.g\., \fBsin()\fR) are available as zero\-argument jq functions\. C math functions that take two input arguments (e\.g\., \fBpow()\fR) are available as two\-argument jq functions that ignore \fB\.\fR\. C math functions that take three input arguments are available as three\-argument jq functions that ignore \fB\.\fR\.
|
||||
.
|
||||
.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
|
||||
One\-input C math functions: \fBacos\fR \fBacosh\fR \fBasin\fR \fBasinh\fR \fBatan\fR \fBatanh\fR \fBcbrt\fR \fBceil\fR \fBcos\fR \fBcosh\fR \fBerf\fR \fBerfc\fR \fBexp\fR \fBexp10\fR \fBexp2\fR \fBexpm1\fR \fBfabs\fR \fBfloor\fR \fBgamma\fR \fBj0\fR \fBj1\fR \fBlgamma\fR \fBlog\fR \fBlog10\fR \fBlog1p\fR \fBlog2\fR \fBlogb\fR \fBnearbyint\fR \fBpow10\fR \fBrint\fR \fBround\fR \fBsignificand\fR \fBsin\fR \fBsinh\fR \fBsqrt\fR \fBtan\fR \fBtanh\fR \fBtgamma\fR \fBtrunc\fR \fBy0\fR \fBy1\fR\.
|
||||
.
|
||||
.P
|
||||
Two\-input C math functions: \fBatan2\fR \fBcopysign\fR \fBdrem\fR \fBfdim\fR \fBfmax\fR \fBfmin\fR \fBfmod\fR \fBfrexp\fR \fBhypot\fR \fBjn\fR \fBldexp\fR \fBmodf\fR \fBnextafter\fR \fBnexttoward\fR \fBpow\fR \fBremainder\fR \fBscalb\fR \fBscalbln\fR \fByn\fR\.
|
||||
.
|
||||
.P
|
||||
Three\-input C math functions: \fBfma\fR\.
|
||||
.
|
||||
.P
|
||||
See your system\'s manual for more information on each of these\.
|
||||
.
|
||||
.SH "I/O"
|
||||
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, \fBinput\fR and \fBinputs\fR, that read from the same sources (e\.g\., \fBstdin\fR, 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
|
||||
One builtin provides minimal output capabilities, \fBdebug\fR\. (Recall that a jq program\'s output values are always output as JSON texts on \fBstdout\fR\.) The \fBdebug\fR builtin can have application\-specific behavior, such as for executables that use the libjq C API but aren\'t the jq executable itself\.
|
||||
.
|
||||
.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\.
|
||||
.
|
||||
.SS "input"
|
||||
Outputs one new input\.
|
||||
.
|
||||
@@ -2805,7 +2988,7 @@ However, streaming isn\'t easy to deal with as the jq program will have \fB[<pat
|
||||
Several builtins are provided to make handling streams easier\.
|
||||
.
|
||||
.P
|
||||
The examples below use the the streamed form of \fB[0,[1]]\fR, which is \fB[[0],1],[[1,0],2],[[1,0]],[[1]])]\fR\.
|
||||
The examples below use the streamed form of \fB[0,[1]]\fR, which is \fB[[0],0],[[1,0],1],[[1,0]],[[1]]\fR\.
|
||||
.
|
||||
.P
|
||||
Streaming forms include \fB[<path>, <leaf\-value>]\fR (to indicate any scalar value, empty array, or empty object), and \fB[<path>]\fR (to indicate the end of an array or object)\. Future versions of jq run with \fB\-\-stream\fR and \fB\-seq\fR may output additional forms such as \fB["error message"]\fR when an input text fails to parse\.
|
||||
@@ -2861,6 +3044,12 @@ Assignment works a little differently in jq than in most programming languages\.
|
||||
.P
|
||||
If an object has two fields which are arrays, \fB\.foo\fR and \fB\.bar\fR, and you append something to \fB\.foo\fR, then \fB\.bar\fR will not get bigger\. Even if you\'ve just set \fB\.bar = \.foo\fR\. 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
|
||||
All the assignment operators in jq have path expressions on the left\-hand side\.
|
||||
.
|
||||
.P
|
||||
Values in jq are always immutable\. Internally, assignment works by using a reduction to compute new, replacement values for \fB\.\fR that have had all the desired assignments applied to \fB\.\fR, then outputting the modified value\. This might be made clear by this example: \fB{a:{b:{c:1}}} | (\.a\.b|=3), \.\fR\. This will output \fB{"a":{"b":3}}\fR and \fB{"a":{"b":{"c":1}}}\fR because the last sub\-expression, \fB\.\fR, sees the original value, not the modified value\.
|
||||
.
|
||||
.SS "="
|
||||
The filter \fB\.foo = 1\fR 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,
|
||||
.
|
||||
@@ -2874,7 +3063,13 @@ will not have the side\-effect of setting \.bar\.baz to be set to 1, as the simi
|
||||
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
|
||||
Note that the left\-hand side of \'=\' refers to a value in \fB\.\fR\. Thus \fB$var\.foo = 1\fR won\'t work as expected; use \fB$var | \.foo = 1\fR instead\.
|
||||
Note that the left\-hand side of \'=\' refers to a value in \fB\.\fR\. Thus \fB$var\.foo = 1\fR won\'t work as expected (\fB$var\.foo\fR is not a valid or useful path expression in \fB\.\fR); use \fB$var | \.foo = 1\fR instead\.
|
||||
.
|
||||
.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 \fB\.\fR\. For example, \fB(\.a,\.b)=range(2)\fR outputs \fB{"a":0,"b":0}\fR, then \fB{"a":1,"b":1}\fR\. The "update" assignment forms (see below) do not do this\.
|
||||
.
|
||||
.P
|
||||
Note too that \fB\.a,\.b=0\fR does not set \fB\.a\fR and \fB\.b\fR, but \fB(\.a,\.b)=0\fR sets both\.
|
||||
.
|
||||
.SS "|="
|
||||
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 \fB\.\fR 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\.
|
||||
@@ -2895,7 +3090,13 @@ The former will set the "a" field of the input to the "b" field of the input, an
|
||||
The left\-hand side can be any general path expression; see \fBpath()\fR\.
|
||||
.
|
||||
.P
|
||||
Note that the left\-hand side of \'|=\' refers to a value in \fB\.\fR\. Thus \fB$var\.foo |= \. + 1\fR won\'t work as expected; use \fB$var | \.foo |= \. + 1\fR instead\.
|
||||
Note that the left\-hand side of \'|=\' refers to a value in \fB\.\fR\. Thus \fB$var\.foo |= \. + 1\fR won\'t work as expected (\fB$var\.foo\fR is not a valid or useful path expression in \fB\.\fR); use \fB$var | \.foo |= \. + 1\fR instead\.
|
||||
.
|
||||
.P
|
||||
If the right\-hand side outputs no values (i\.e\., \fBempty\fR), then the left\-hand side path will be deleted, as with \fBdel(path)\fR\.
|
||||
.
|
||||
.P
|
||||
If the right\-hand side outputs multiple values, only the first one will be used (NOTE: it used to be that only the last one was used)\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
|
||||
@@ -5,7 +5,7 @@ Name: jq
|
||||
Version: %{myver}
|
||||
Release: %{myrel}%{?dist}
|
||||
Source0: jq-%{myver}.tar.gz
|
||||
URL: http://stedolan.github.io/jq
|
||||
URL: https://stedolan.github.io/jq
|
||||
License: BSD
|
||||
AutoReqProv: no
|
||||
#BuildPrereq: autoconf, libtool, automake, flex, bison, python
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
#ifdef HAVE_ACOS
|
||||
LIBM_DD(acos)
|
||||
#else
|
||||
LIBM_DD_NO(acos)
|
||||
#endif
|
||||
#ifdef HAVE_ACOSH
|
||||
LIBM_DD(acosh)
|
||||
#else
|
||||
LIBM_DD_NO(acosh)
|
||||
#endif
|
||||
#ifdef HAVE_ASIN
|
||||
LIBM_DD(asin)
|
||||
#else
|
||||
LIBM_DD_NO(asin)
|
||||
#endif
|
||||
#ifdef HAVE_ASINH
|
||||
LIBM_DD(asinh)
|
||||
#else
|
||||
LIBM_DD_NO(asinh)
|
||||
#endif
|
||||
#ifdef HAVE_ATAN
|
||||
LIBM_DD(atan)
|
||||
#else
|
||||
LIBM_DD_NO(atan)
|
||||
#endif
|
||||
#ifdef HAVE_ATANH
|
||||
LIBM_DD(atanh)
|
||||
#else
|
||||
LIBM_DD_NO(atanh)
|
||||
#endif
|
||||
#ifdef HAVE_CBRT
|
||||
LIBM_DD(cbrt)
|
||||
#else
|
||||
LIBM_DD_NO(cbrt)
|
||||
#endif
|
||||
#ifdef HAVE_COS
|
||||
LIBM_DD(cos)
|
||||
#else
|
||||
LIBM_DD_NO(cos)
|
||||
#endif
|
||||
#ifdef HAVE_COSH
|
||||
LIBM_DD(cosh)
|
||||
#else
|
||||
LIBM_DD_NO(cosh)
|
||||
#endif
|
||||
#ifdef HAVE_EXP2
|
||||
LIBM_DD(exp2)
|
||||
#else
|
||||
LIBM_DD_NO(exp2)
|
||||
#endif
|
||||
#ifdef HAVE_EXP
|
||||
LIBM_DD(exp)
|
||||
#else
|
||||
LIBM_DD_NO(exp)
|
||||
#endif
|
||||
#ifdef HAVE_FLOOR
|
||||
LIBM_DD(floor)
|
||||
#else
|
||||
LIBM_DD_NO(floor)
|
||||
#endif
|
||||
#ifdef HAVE_J0
|
||||
LIBM_DD(j0)
|
||||
#else
|
||||
LIBM_DD_NO(j0)
|
||||
#endif
|
||||
#ifdef HAVE_J1
|
||||
LIBM_DD(j1)
|
||||
#else
|
||||
LIBM_DD_NO(j1)
|
||||
#endif
|
||||
#ifdef HAVE_LOG10
|
||||
LIBM_DD(log10)
|
||||
#else
|
||||
LIBM_DD_NO(log10)
|
||||
#endif
|
||||
#ifdef HAVE_LOG2
|
||||
LIBM_DD(log2)
|
||||
#else
|
||||
LIBM_DD_NO(log2)
|
||||
#endif
|
||||
#ifdef HAVE_LOG
|
||||
LIBM_DD(log)
|
||||
#else
|
||||
LIBM_DD_NO(log)
|
||||
#endif
|
||||
#ifdef HAVE_SIN
|
||||
LIBM_DD(sin)
|
||||
#else
|
||||
LIBM_DD_NO(sin)
|
||||
#endif
|
||||
#ifdef HAVE_SINH
|
||||
LIBM_DD(sinh)
|
||||
#else
|
||||
LIBM_DD_NO(sinh)
|
||||
#endif
|
||||
#ifdef HAVE_SQRT
|
||||
LIBM_DD(sqrt)
|
||||
#else
|
||||
LIBM_DD_NO(sqrt)
|
||||
#endif
|
||||
#ifdef HAVE_TAN
|
||||
LIBM_DD(tan)
|
||||
#else
|
||||
LIBM_DD_NO(tan)
|
||||
#endif
|
||||
#ifdef HAVE_TANH
|
||||
LIBM_DD(tanh)
|
||||
#else
|
||||
LIBM_DD_NO(tanh)
|
||||
#endif
|
||||
#ifdef HAVE_TGAMMA
|
||||
LIBM_DD(tgamma)
|
||||
#else
|
||||
LIBM_DD_NO(tgamma)
|
||||
#endif
|
||||
#ifdef HAVE_Y0
|
||||
LIBM_DD(y0)
|
||||
#else
|
||||
LIBM_DD_NO(y0)
|
||||
#endif
|
||||
#ifdef HAVE_Y1
|
||||
LIBM_DD(y1)
|
||||
#else
|
||||
LIBM_DD_NO(y1)
|
||||
#endif
|
||||
#ifdef HAVE_POW
|
||||
LIBM_DDD(pow)
|
||||
#else
|
||||
LIBM_DDD_NO(pow)
|
||||
#endif
|
||||
#ifdef HAVE_JN
|
||||
LIBM_DID(jn)
|
||||
#endif
|
||||
#ifdef HAVE_YN
|
||||
LIBM_DID(yn)
|
||||
#endif
|
||||
#ifdef HAVE_ATAN2
|
||||
LIBM_DDD(atan2)
|
||||
#else
|
||||
LIBM_DDD_NO(atan2)
|
||||
#endif
|
||||
#ifdef HAVE_HYPOT
|
||||
LIBM_DDD(hypot)
|
||||
#else
|
||||
LIBM_DDD_NO(hypot)
|
||||
#endif
|
||||
#ifdef HAVE_REMAINDER
|
||||
LIBM_DDD(remainder)
|
||||
#else
|
||||
LIBM_DDD_NO(remainder)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#ifdef HAVE_SCALBN
|
||||
LIBM_DDI(scalbn)
|
||||
#endif
|
||||
#ifdef HAVE_LGAMMA_R
|
||||
LIBM_DDIP(lgamma_r)
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script is used to cross-compile binaries for
|
||||
# This script is used to cross-compile binaries for
|
||||
# platforms other than the current one
|
||||
|
||||
# Usage: $0 <platformname> <configure options>
|
||||
@@ -38,5 +38,6 @@ set -x
|
||||
for jq in `find . -type f \( -name jq -o -name jq.exe \) -print`; do
|
||||
cp "$jq" ..
|
||||
done
|
||||
cd ..
|
||||
rm -rf tmp
|
||||
|
||||
@@ -7,10 +7,9 @@ mask = lambda n: (1 << n) - 1
|
||||
|
||||
def print_table(type, name, t):
|
||||
print("static const %s %s[] =" % (type, name))
|
||||
first = True
|
||||
for i in range(0,len(t),16):
|
||||
print ((" {" if i == 0 else " ") +
|
||||
", ".join("0x%02x"%n for n in t[i:i+16]) +
|
||||
", ".join("0x%02x"%n for n in t[i:i+16]) +
|
||||
("," if i + 16 < len(t) else "};"))
|
||||
|
||||
|
||||
@@ -22,7 +21,7 @@ def utf8info(c):
|
||||
if 0xE0 <= c <= 0xEF: return 3, mask(4)
|
||||
if 0xF0 <= c <= 0xF4: return 4, mask(3)
|
||||
if 0xF4 <= c <= 0xFF: return 0, 0
|
||||
|
||||
|
||||
table = lambda i: [utf8info(c)[i] for c in range(256)]
|
||||
|
||||
print("#define UTF8_CONTINUATION_BYTE ((unsigned char)255)")
|
||||
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script builds the website from the docs directory of
|
||||
# the current branch and copies it over to the gh-pages
|
||||
# branch.
|
||||
|
||||
set -eu
|
||||
set -o xtrace
|
||||
|
||||
# build website
|
||||
scriptdir=`dirname "$0"`
|
||||
cd "$scriptdir"/../docs
|
||||
rm -rf output
|
||||
rake build
|
||||
cd ..
|
||||
|
||||
# copy to /tmp
|
||||
tmpdir=$(mktemp -d -t jq.website.XXXXXXXXXX)
|
||||
cp -r docs/output/* "$tmpdir"
|
||||
cp .gitignore "$tmpdir"
|
||||
|
||||
# copy to gh-pages
|
||||
git checkout gh-pages
|
||||
cp -r "$tmpdir"/* .
|
||||
cp "$tmpdir"/.gitignore .
|
||||
|
||||
# clean up
|
||||
rm -rf "$tmpdir"
|
||||
echo SUCCESS
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# RUN ME after pulling the code from git!
|
||||
#
|
||||
# This script is handy after pulling the code out of git without having
|
||||
# to remember all the typing needed to build up and tear down all the
|
||||
# crap that autotools puts in your source repo. The intent is to keep
|
||||
# all generated files out of git.
|
||||
|
||||
if [ "clean" == "$1" ]; then
|
||||
make distclean || echo "continuing..."
|
||||
find config/m4 -type f \( -name libtool\* -o -name lt\* \) | xargs rm -f
|
||||
find config -name m4 -prune \
|
||||
-o -name .gitignore -prune \
|
||||
-o -type f -print | xargs rm -f
|
||||
rm -rf autom4te.cache
|
||||
rm -f Makefile.in aclocal.m4 configure
|
||||
elif [ "superclean" == "$1" ]; then
|
||||
# if autoconf errors during distcheck, it leaves files that need chmod'ing
|
||||
ver=$(scripts/version|tr -d '\n')
|
||||
if [ "x${ver}" != "x" ]; then
|
||||
if [ -d jq-${ver} ]; then
|
||||
chmod -R u+w jq-${ver}
|
||||
rm -rf jq-${ver}
|
||||
fi
|
||||
rm -f jq-${ver}*
|
||||
fi
|
||||
else
|
||||
autoreconf --install
|
||||
./configure --disable-valgrind
|
||||
make -j8
|
||||
make check -j4
|
||||
fi
|
||||
@@ -0,0 +1,41 @@
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Comment: jq Release Signing Key 0xAF19040C71523402
|
||||
|
||||
mQINBFYayakBEADL6biudAZ3V1//e3gdWMN6lbz+m5o6avu1vnbtCul/MxOF2Ygd
|
||||
SeXCn5gV3+F+xdrA3/Mhv9cWXzzDTp0D2U75mHw1n4OcArFvKm/RV5yOlc/wvblp
|
||||
WfWd/hCIIZhdHpRWdCko2ByXx9XlBRn46nGyxCFScLcHbicPjq2kIpZ7oad29gs4
|
||||
bThj65G5XS48FyqixGHy0o2S0nQXNIyB1XTPm4mwHNAeOMFaYj6nhb6b5vu+RhlK
|
||||
syirTGU7pZYd13FM5y9NZrbxfKnGz5bdKPgb4jRi3YmBTKRzlW4IZl3SGO3kPi9a
|
||||
wJR4vP+cf1eEAWulrt9i4DA3/3/lpPpFh5bSo7nKW49PdOjfLWzBLtCsVhJReF97
|
||||
sSPVpNmf6RrfBXnPlEBw+aU4wGRbmpA9AGV2rKsvxZbU2AqDS93Pn6S0u4XNNnjH
|
||||
TGxe2P9gSEH+xNuEyFcDbt0XP6Te3vSE7oMGIPhXq1FKuXygEQGV2fXa2Dovxi+q
|
||||
YTvbtzG5PV5lQqeexoNMUHzgHVWib/NIt7JTkBflJt33re7oayZd5DSE5zy/4n5d
|
||||
LH9prYJWqVGgb92Lzlk6uYDp3ztBlFdoRR+6L25iUCPRq5yS7J4Rk3ahask2CsQc
|
||||
aANz5xkESnS5DcakDoVtbiC1UY8eM+vXui/UF2uYCTLrz+SIIZJHPQ0fdQARAQAB
|
||||
tC5qcSBSZWxlYXNlIFNpZ25pbmcgS2V5IDxqcUBzdGVkb2xhbi5naXRodWIuaW8+
|
||||
iQI4BBMBAgAiBQJWGsmpAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRCv
|
||||
GQQMcVI0AoHwD/4s1L10OiimSELwTZ3x+btmKdaFBdlUhjBZd/GDE3P1pV+63D2+
|
||||
LhLpZLQ3yOrplUDHGBG02Hx7/lY2YE5rRVNMyR8FqD9aMrOwQE3uERjkwFQ7Q69r
|
||||
S6kFLiOxUWDXNQ0wXeZ/Na6uYi6AI/oCYWnDIO3lugDUoXtHanYqK1BvJsBEvWpe
|
||||
UB18VcqxBQuOMPD+xNzVDSFn1uYiKKBkv4XJNLHRqdLpwmAVcLDkKTHWEy+223CZ
|
||||
4zwahQKw9wPdUlakXP7v+wIxzGXaGk0yJOsYVPykQ4AkoMgvqqxyx23d6hjncR1o
|
||||
36muLAiL+qELZ/rxUytduaK1Owr8cNJgPzRAEbeSRdw2hZYyEnHgNPC3atUN0wIk
|
||||
khzP/GHMBYIU90CdiWjGvjJeHv047Ty4S9PEYPZLQx1s8cdIeozEFt/lTqFp+9Si
|
||||
f2DWUKHpzQ3wfUudTD4pzSy28XJ760Kq54f1cf2CWqp577xrxRfcKKoyufF8pwqf
|
||||
sAno03N6MpxiK0qVwZ/0Qb2BfAI2rpxxc98qhuErlBE8WjPj7M93eaHNMTtCqCIG
|
||||
Hke6kMjYuwGu8NK/O0SqGqsHoXxxIvlZNda9MCPJo9xl77dphurOq/D/d9rfy/Uk
|
||||
5D8ssNUBhM3s6sQl27L1avnSS12UuRdGSQwU33XbAuNG7y0a/zRnX+GqE4kCHAQQ
|
||||
AQIABgUCVhrKpwAKCRD5uhQ7lf9tgo26D/0WFFkhmUjSV9K/q8zSSJhuQfzoeM+n
|
||||
Z2DfYBfKdawbJH9/Yfg1nIFzih2lnvzk/kx8WbLSDMb0sHn6ZUZ6cVoBvrBxSgah
|
||||
bwPF9M8Xf4J/oBYHq8ZYjPHOWnHbEPuoNzPreqOhtSLBtP5dfZlEI6DLR2+WKj22
|
||||
EmHfmBFoKZ90N2MQWQLV98DAFfsxS7Bqc9xSCbh405qCIGr/4r4P0BaIdJ2jW/9k
|
||||
AHwnsmJnf5lI7dn8BEMYgM3vcG4dyaWNf+eoI3cJnq+Y782KoyFjof4t1bLF2H1C
|
||||
vbiJ9xWv4uCeTVlTwiVJFkSUxBgmsyVofcboHF7/06HtVXDpG/ihZEOoqNPKPD4d
|
||||
56V2t0hEulUpyqfs0Ic8r+sGWgvDCSqAVrXak2n0ULJ+RkpRB6ekcgOY7HdYKX1H
|
||||
UifaytQSxjUBXfo9HAC0Br2fyGh9s5zBcnrIrWHxwQw/RCIIv9CkZB7s6/NFYBKw
|
||||
Q27xTpXjHnGoEHNAA2xSyMXw9VoH3qoze/1iraK0zSFGAXpmL57HMBnOrLj7oq+O
|
||||
tB/cLd9o4+XFJjXHGAsXoOD5cCADkgMSMcouvPFKySfK0Kz5ScWVSsc5FvG44j/L
|
||||
T1WvjBgIrNAeQJ2efPYVmg5f/ALkjgnKy+lkafBk4OwXtWZCTf+9vcOF7FQ2B6N+
|
||||
7qQPymxSJxBSEg==
|
||||
=AiyG
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzhJAAoJEK8ZBAxxUjQC8xMQAMgSl+2aYa/c/LuYKDWtVnHO
|
||||
G16rAq+oruc/IrEwEKqcwqTvK8M7xlAxUt5aPtAY0kRkvxadFtX8vZy1SEqAFcC5
|
||||
sw7J+Oswl+5dJF0Y3j3I0hA6JuOe/+RP4r64pGlwQ0mVIJuTWqinzO9JqTOskeXy
|
||||
5vSN50A0vFXzDu661UFr1v8q5+b8WhIrJhuOZtaPap33Gu9bS6fz93VBm4LE3a04
|
||||
KjDydbNUoyA5HX4QVTgFON8oeVJevtqV3krnsU/ncOeTB0ThT9yywcq8HCbh7dqo
|
||||
EhfyATOmk3RZf3RsSAOG5CZ9cFjof6/SqVG8Cbp14MRVMkKi37mvHkqFER/WRtsv
|
||||
Ul1OzFfv8Jwv+cItTSB5c80kbbRfrqwf6NgZW9oTxZP3G3I5JjCTYhCaWlzO0wZ1
|
||||
QAAJDBAv5GNB4rn9LXGdj2DhcCh00lJY83Bpup4LRc2RuJuJH7IUIkfRW4CAVoRd
|
||||
p6w5W4jYNdrrTkhfkNxSqi7FtKN23+eD2r0knPvhsWxyUcXrGhFqaImHmzQWIsX5
|
||||
AviEK+nQUcuhTKolsN/97NPkRYUT9C4IVNdI8m1+EsAuwGodSvRrUwBIOoVQlYA7
|
||||
MFLZZ23Su/8T5NnruP+iXmy0Y3Nf9W+GLHNn3H+9027zAs5Esd2Hy4R6W65BwWuI
|
||||
yYHFx8O6bi5ke72ByCUI
|
||||
=ru7X
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzhxAAoJEK8ZBAxxUjQCb2EP/08Lgfoc0rDv5IirCjXIFWxM
|
||||
8C56aVfaF/8gaG75SuN3QUVBuWx3VB60Cgh/msTFrZ/jkWr+tYArNzwNAjI8a9T8
|
||||
nE40SJH3kvwVrr9ALSgk9fEvikfZVKwYTc0k4h1hBataE5Z+7Di7VYPUmdLTd/ih
|
||||
dcJfDe6zPcYmaW6fl0glP2GLaDuLI3vxAid0MzDS1RU52z+usc/fjXWmaJwPVp76
|
||||
Sd8/Uz3X6ZiFwpkfhp6XTcqkQhMZd4GS9cjnPAdRp9HFLI7S2UJ4RNj/YQIHrhQL
|
||||
5Ko3KdXEWeSvD8wcr8VcZ66NfmyCls0diEU+TUv1I7VmLzVQGx9/4/uVWpfxry9D
|
||||
8MLEHEJTTDT5W3hX47g29JRFJzv8PUyugkpXjQrpSoFbe/3vRxZeQNO9rjTx9t3x
|
||||
hdkWIjbwTg8SGH0XK+UNfR50A3VlrlPDpW5Ju2Io7/OuKRWN4i6ktFx0akFMmHUV
|
||||
D5u/FhEux7kJCNHnF7a7YJ1Ys4OSPUzoH3z35zhyVcW+iiX7KIKHNamWaPBw3iYa
|
||||
MwYVKHT6NUQiVQbTZvWJZXGArEnwq/z6jAjRQNKoTjbcVoYJunY/DZcJjnRIux9T
|
||||
yYnTa7IbpWZmWZWQfnb8zuSoXnhaSHZItIeUklH4K03xjpEXW7pGPLPznyDoBQeC
|
||||
1WVcwpviS/Y24eSmmxaA
|
||||
=MlHu
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzh+AAoJEK8ZBAxxUjQCyb4QALrsqZ/QkI2a/uVPnwAh22B4
|
||||
mtbplxOS8swCB4g56tG+JMuria9l1ACmpbc9eTJ/Q9z9LLwq3vBkpy0utAQp/iAQ
|
||||
ijZbTG7E3S/LtOzZ5MSbkGeyuDWu4YCI7DuxTZH+R43fiA/ShHUHf7rO/vofAjTu
|
||||
MZr7TpBRjut5htbkNrUKoYjK97hehvY0S3h1oqMSSuHS4Em9xMvv5bAsEn37+L3g
|
||||
o5Y5kHQ55Lu3qH1Uk87VMz+gtO4pxN+ZrNNrY2lX/hwnV7p5YDza2H0uOopBrTi4
|
||||
X99x9JzdHoSrySRwS1ZDc+XYDgXP7JO9qDmNh18nXJlyCWFzDHajQS+4Hn0O5zM0
|
||||
PHWasVC8tmxT0XXZlG1kPuaCkg0BFh1NXNjCUa7Ru9XHfOkaW4TyKGQa3eboyx56
|
||||
q7MDvODUd3JSW4xmLJ7NFSYRCPMRiCMorQ8u8afy2OWt2W13M8OIH378dMcFoubW
|
||||
GB00i127dhuI95lwNsTV1seKO59bMbAJjP7ITqqDiOafg6AmTric6BJNakSsrc66
|
||||
yCzhOfxqwfeRekPSirrf8nv9D7dW45yLEiXn9Irn+KghdL4KCLCB8dyc6OalITVF
|
||||
c01SK5xNzPRfFVzTqMdmi/dYpDL0KSMwg3O3DhPQ0LrRZDXKXj6A4KGAthpVLmRr
|
||||
IHj2hlGlr4hqLXUU1wE5
|
||||
=I3PU
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGziCAAoJEK8ZBAxxUjQCkGcQAMpxoK6aHzDIeVjp5kQ4MOFu
|
||||
dOE0xjXlPpudUfUORKqfsnPvvxJTvqlDrUhMq6d6S1Eic9ZAbfpmHGbw02tvQ7+4
|
||||
hvyy/KbfBUcLZRIwZ1eej/rFUXd2fmxPwoj07SpTOgjKF+8duUzSlxBg+Kes77pj
|
||||
ZuMO3KUa3isaOp+kufh0+miAqHisEWzQWCfHBrVIwW63L2bf2ZSUvp4JqwfRKfr2
|
||||
3hBfoll0M+iaLHr4/wGUIxRL+23afTtvQikyOXzB3rKXf+QmDePZ29isZVg94yi4
|
||||
/XiDVmDM/6GpfI7u0fIoDcEgH+LE35HL/CT4zA8IzA/QwB5bCO1bPEA7DfDQq01R
|
||||
oghTvH5Qu0eu8tjap7EXAmch25nPys4NzPoIRnbu4i4wQUsFqGzmSFKEuU6pwDIm
|
||||
lsEBPbHRcGcaui2KidUNi7iQmje819KgRDhRxX65Bye9sKsD/HvMzQRce1RFYQg3
|
||||
uqISuhWu8qj67J/ii2zFF+lo5HgHLqzXKcye1kY5KYq2dTIa3khq89Xkf3trsnNL
|
||||
IKZ+8P2eiVDjDr3UPIvVCX1JvNTdcQDMUlmoKk8g1qwuTp2PTi+c6FKicZGUMMnv
|
||||
o/hThK2JwnL/Iv0bJHvBU6aCXSnKLTLIdT02UvUppiN/GTMHsagvE0DRA1B1yFim
|
||||
/o/n4edysfzI1Pxe0b3c
|
||||
=ZOqW
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGziHAAoJEK8ZBAxxUjQCG6cP/RNQd9g+Te+fgpFvnFDhAVyW
|
||||
EKZ+2B+V64m4GzrRFnGwBMqju4kFf0dZ4craagJ2gLVQ74FhvorMtphjX0MYgxtt
|
||||
wXyIqImlBake3GEkjUI6XW8QmlFmPix7+2fG4oEdLHwgE2/ii1DFlhTQgYYwH+Be
|
||||
z6wo6Nfl9OxykEHG1hl0A4AiHT1ubWogbjD87yZRO2M1rp2nHJu1TujqkjwWLXtr
|
||||
0xVBSgtutfYRBvpPGhtLb4nqzkeW+lFW99A2aUo1KroyBdcrEKTJ4XMRqjYJLkSN
|
||||
68e4gZqHmR6M1nA4h81bU26lhrN3LbYiOwBu67N5PnSOQE87zFPK6Dac4QyG7vzt
|
||||
pR2xht0QwwraxOeIrMrKs9vhUOKm9RDpNcD3z1xa+k6Qej+nP8A2zmMvUz3+C8F9
|
||||
ITESyjk/28Eku5jEUs5Niz/znGvuU3A2fk/qHs7U0I8tvNWsxj29GCTzgPDoH3Vs
|
||||
sJKuSozoSqecBf+2x23PnGjGttL6BK6lo762qeVw6npCi/nqGFbMWpuopgJ2PiNP
|
||||
t2RdNzvX7v1V7ZfBOGl5iAeG/XJ18uD+hplCiUePN7Jv/3bpaJ9jlo//kIwddUP2
|
||||
p89zfLPjeptAIxvkWph4ZL59pj7zsid7rSMd0WIOOqE61PKpl5jBgrdiBgKbcmJe
|
||||
AIRZewlOq/0l0cVtK10b
|
||||
=3nBK
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGziKAAoJEK8ZBAxxUjQCP14P/jkKiLUgiZkXYVQs+hBJqJD2
|
||||
rOsHVGmoxpjnQ8L9gUSxfZ0E80+1iTx/9JNWHs0xEKrvWKmCovfuQd8xfxZ30g5z
|
||||
wMa/7QWZtLdfIGkQje79WgA/+xDWSLa0T+dbcMjCwDdYPQyQE5Vf0I7qoNOj2Dcr
|
||||
CmkSMO6dtoilv/o2WX1x8Z1K5sqGMl64WyM5yR8sEMRBVuVqWRvELrv9+YMW2UYU
|
||||
yXj7tFwulyqZEoUBLlUxZhr7gjah31gBP2qqLeZhq/phdUsi9ckPusW3Un5SMaRf
|
||||
xEPo+y83Qrpusm9UDGsm3t90TWva3oMiExjFatFKuKvLbFCZRK0EIqdUOUMlptV6
|
||||
kS3xKsvAq+vM53FfwcWx/9gcZQv5XTw7McmWZ9vZmHH24AUjuFFFZLoWxPg73Vek
|
||||
HaD5xTsxfYEqGRaJbYoSkSs39fw+tH0ajRoMVcZw2O2c94qAgzR/Qne9t2nQ0ypg
|
||||
hOzsIIdIxj9XZShkkVmlK8naf0YH0Wc3Yo3wBxkTy7QKVWtcF+x67wth2XjKHBbh
|
||||
lh9Gc3R/CUvRhk9gOSqHYAsy7lEIpFGjuIqYTZcXRO3BCJgjc3hV9jBiIy1iQWGg
|
||||
Kuh+egThw8U9z3PueP++yVjImze9Y/+78dc/rHAwXkFIysBs6vle/9ILDl5Komvv
|
||||
91rFNBLkjvmJoRw4hUpG
|
||||
=WNFH
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,6 @@
|
||||
cf4b0b3e505958843375ac153d84ad6ee40196aa76ee373b0409f858b3cbf925 jq-linux-x86
|
||||
dbacac81ebc00a7387e4c5e539a7a475981a1ac6ada20a2f6b1d8f950027751e jq-linux-x86_64
|
||||
4095a48b50b754c8b3199b9c069fa9c3da0e737d8809af3205d1bf69f87cab6e jq-osx-x86
|
||||
bce52800c943ff10d1ffd9c1a7e7aeddbc7bcecd7a2b05c6afb828399dbfa39f jq-osx-x86_64
|
||||
c8e2ffb5b0536a50430ef9b4708a40686e4352db5c01ae90a98ba96660e5bc36 jq-win32.exe
|
||||
d041fdfd8b3aa3832eedf2aafad5002f2b47fb59373b71190a01422de825911f jq-win64.exe
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzjvAAoJEK8ZBAxxUjQC5KsQAMt1IwBrIn8dvTe44djO3QYk
|
||||
H/qaNSRgChJI81GA+B4suTcgh+PUJcHF1EWls7CCfjfp1haocikXpNSuY7mF+43M
|
||||
SMdz2ZA4+N542ratUTv7YlG/igIvz6IbDysjowU3QQsCcjthmO6OF/6fd2qRhggB
|
||||
3K80AMESOBBi7TkFTLw1G4M8uU6VvN+LWrG6fOcPXoRLlqShGzskDqxpobL1+o6J
|
||||
Cf56Z+ZVLQ6DPjW2pxK2R88788DjoJ4j53wsBqzgnHMeGzWVzvQ836rYSD4dhpSn
|
||||
YopiAesAYLu0hJszHbJrigt/jUGsNekQ+/ihqGXhbtDVjpYLU7At42b2w2AgjNSK
|
||||
GFBJmICTQZapz4o/lCCli82PngGmIVqgf6fc7qZq+HHtrcBeNYjMHMPMJroGqanJ
|
||||
DhCnLmE1906RpJ3VvCM5Sd9lSQQpSVzmFAh5MMnprxvsAmDbL+Ty//a/cOU4WPAJ
|
||||
MgXH2REmeByg8EX6SPhtshxxdIQf0CX4uh2r1aHQFtg/sNPL/EWGcRq+DVbaz/8R
|
||||
TJCfu9Ov0GhJlZSMHbkN9cvrjeE5CNM+7Q66JbhOMp7uOo4I9+JyknNJP7L0Nvot
|
||||
IcC6qsw8jMINHexW3RSDbX6b2S+0BskojAxp6IYHv0y82aaJ5I3+4UD3A5+Q34iM
|
||||
g1kqYu4WnPOZ+cihvGKO
|
||||
=8ZEt
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzjzAAoJEK8ZBAxxUjQCTVwQAKoTbAddyfciZzgaxSWqc0Yz
|
||||
f9njjvPHRtUfa0X5lDQghlpTrDY2CxqU71KknLgxW4VpnErf13KlVoMBvGJwCmU5
|
||||
JcO2aE3iQDxpf6GnYa57caSsj2pR5Fi+/5nvxr2ovoCzGea3k61j7G+GV+znccAr
|
||||
K3c+03aq7p1LGfsqQSGPGH/nLnrqtcFonNVPxsaBuFpGMpaP4DuI+zhd5bGGo4g4
|
||||
k23mWbOee/SEdYgiMNtVnkoQMZmSdae9O8VuTMoTSv8R2aLmDTrrLa/3z8m7rQAe
|
||||
rGQkaHhRg/fH6gLgBGJe7enqDgbNCmKp+zxfI6p5RbFvs5oH+M/wV1edG2KFUpI+
|
||||
fv79Aj5XTVinNSCewrJLVHkzd328KhAeXzm319wJ0Q2sRbvO/3rhqslkRPCW9Uan
|
||||
uxo5dLMYqfzksy2Cwhv+c9r7Xfi7tjKidPLbwdz620eERquXSx7+kZLQyOw/mx6O
|
||||
ufnZKMDfhxZXt/KkNzraqkYKvZ6eO7r270ao7tdSZLDC+zELMGzIXINkOPXQDA0x
|
||||
m3Zz97jmfMQ6JwWU/1jCIOs+CpMueBYw3VyyqKNAUvYIjkw9A6SZFYhwcTc9k0Xh
|
||||
0XSGZNjiKxTe1UJdBXG/nwNb6p5rMWwyesbiqvWiCIQ6aBX6SluODZsd4479bcVb
|
||||
1fYsg+Lu9V7FiGY7ZlCz
|
||||
=oGfI
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzjzAAoJEK8ZBAxxUjQCmKQQAIei/vszKSXY7gyirM1FmUEO
|
||||
jPEzjHPJvYOEIw06/I9Jkn8ufsTQYtP+S19C8kGLRcZIonlXZxqQmbYQUv02NqEn
|
||||
UDRlCxiQZiGLO6i54vBWi5VhB4VNWgEbrctQ6oR+mV6MXs7RZo+2SGEJT+r4z8om
|
||||
HpFGQkfdfwNRbAXkIDHCx259pzL1gy/YrWV/8F0VdAH70dmqidWCQ4Lt+oymUhno
|
||||
0f9gBOwIFZJXJRhhGz8unHk9XHdDlrpdvEb5XpuU1Alvt3BKa8vJslbTY48a+nI8
|
||||
3XsfQhAXItAhUIWHTq1dnqmJzDvFzkZVEQQ2Zt+e7HsA9TG4StLCaYCIorUp7fbo
|
||||
BbxS6I9TUCbp5YBa2EHiq65/jNBlRz8+GB1cjZ3oCTpQQUTd2pFR/fdXXKxvKerr
|
||||
5Gxc2CZqaOGW30iLwvtowNt5y34nf33WCTtBAPpY44aD3TkFkHcQq0hnZQI9gpV3
|
||||
eB5uUoLrr3znLVIs3IX4B2/L0cKP+Dbal7iDQ5nsmEHGBy5P3yOgLbHUg80pG+lX
|
||||
b2wQMTCyTrl/lahJY/0n2r31yBgmHHMBNmY0dWLsXwzemh4TlVQ6IiFl1rF1PPQC
|
||||
F7bhTHQh1/DrhW94C/uFU83O0LveTb/U0FobAMCMgrd9Ew3C+gwXOKP96DHx6mmY
|
||||
ldHhiLTbmjLbfiDMaWw4
|
||||
=dzyb
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzj0AAoJEK8ZBAxxUjQCeTYP/jt8hRyHNKtFfahjW50EcAab
|
||||
nSqUr5VXz80BL6vSrvixMoffv1RDFuzEZgFlYZGXErXjK7Rpo3NAE+e7EUH5vbgk
|
||||
kJaZjzGfw8Kx0ZCZFlmDmI5U93xYiSeIPPP8jaUEg/Al01CH/Y584bgNjyxi3zC5
|
||||
RKO+/HTYd7KR5jAWNzKqV3tGvXJdi+a7Msw65OiJLRoVFX4ps/CGaI8Dh+vbbPi4
|
||||
zPjG2DChoMdaRNxjQNcj/FW7M53rXIUHbXAmR1jDOSsTk16V3kX0eX9RSBsgTkjn
|
||||
b6/BrXnTMmTJR1osHIznuzuQ0sB84+k5CF1ZBwqYjmIr697qEl7r+bWODCN7NcJ+
|
||||
Lo8re6lTAJZBqy7IKgPb6lwFg2tqd2P7UCv0Qx6dLUQGzqeUBDv5GDR5DjTQ1LqV
|
||||
CpyZbOFkA4UaKbmTp+DOGE5TV2D/hzUAcX/HzEo3RVAKSJIutlcxHpMyIazZbRQr
|
||||
RWNU4GiNr0Sbpl00oa6GU7OO/d+j+BFcEKrJ8Ud6zv0M4OCFkP0FW5CKxbl0aql2
|
||||
y8cxcrdMmUhMwn/Jv7pX/N4Hqa4Jjzyy719LKRXp9yjtXV/AnEY2aQQqR+I1Q3VN
|
||||
DBvw7qLJe2hzQhacwOGDNHc7L5JgOC49wDw7L7MNlBGHPdEGKDMdEc/k+Nn/VnOU
|
||||
l2JS9gVb1lP3p1TPKSIG
|
||||
=PKfI
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzj1AAoJEK8ZBAxxUjQC7PUP/3J4uNx0zpw4SlnB+yBzrKqn
|
||||
Zk2JahOg8wWRFbMACjMAjTMGmi9vYlLQRjesdi9WdvvlD1iW12Pi9ogA8OzFRkH+
|
||||
A6It1g74k63WVtyfNHfLTeh2euQsLUc1UJZ+36FPs7lxZPsJmAL4kB1M6aHy3w/K
|
||||
aZT+h4iZhFeC3/JFvLhd2j6/RDf+FkAiEbRlSXoNmeBTLnNo82liEinZFUvEsglO
|
||||
EIVyPBGp3mtlBE8sf6WGd57IpxV4bl1mXZAap1xPVpK8hrjwXS5t2midd11ENBmK
|
||||
UeKcvZpmFb6qLTiep9kaUljB6nOzTYyhg6S9gaJAUDl6Wam7gtBFTIMmndoGiwQO
|
||||
NV+Lsj3dVFz+7kO+sZx/acC0PXfnMO2o6zBTva1RpDoHJFLmKTnPDbUFl0rZtMB9
|
||||
R+HBlqRR35PWKWC3ggYPzfU5bZOVp8G97WFJlKkf5hMWzKiNoiR4hAM6IZYn1rGB
|
||||
S31YKV1yvLIcI4mbhogBlfvXEcgqkQt4cZip16qqpy+X5n1zEA/w6cXcpushbhpf
|
||||
8G6b27PysLT/u5wViSPklpN7x/SbS4rVGzLGPvN7hYR3FgaPqADDrkZYZEIpl6Zd
|
||||
+Gj1M4YjcSDwInnBeaSA+n41Cg9hbudM5R2cdyZzcViLgebnjyt80H+03TDRi/aT
|
||||
dGs6zbsjUQWFGqP+FpgT
|
||||
=bERX
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzj1AAoJEK8ZBAxxUjQCZ9UQAIlJSA4wU8lFakjVI1QfJ8AA
|
||||
v0FUY8KPmk2RgSHzeCRZaWuA0FJAOVNmJtW7kKT1Zg4iJ2f8enX+6QTRbWO5pges
|
||||
6Ib8CltoSa1yS/RZOecyn4LtmJEkh22mhuOJdPzf7+6UmSGaMhE8yep5wg63i+GA
|
||||
o9vaQvllmiReR7qOjvI9cFYTdy/4iX+Nf4TBQPSJPBcXtwtH+iq72IzizgPo7fFd
|
||||
YoLz3V55DlAWBJsyMhVF4rgWcBcCOcMOwaZ/AsKVcKE7+NiPfFsZw0qqtBKAkYBP
|
||||
mKDheZmbX43rDp9Un17w3JbZZ6Uj7nglPpE8SVk9tlJJhznCmFg1ls8vdzkwjkht
|
||||
Cr8IlnFT8ZS3i7w9CLO8nCLuMYY2UECre/wELY915fwRGY+fP3EinO65/xBWxUdl
|
||||
zsq3DchIxKDorD3OiAduZIqC1ZW3XSSsiXzs2+PJwzW5ryvLxGSptVTTr35qVDdo
|
||||
0igUW41pdwV1Mnltncah1+NOAWcSQzXx2E4dtPmGjEcTXSsGvt1vqTZtfFL60GKs
|
||||
nwONhA+mK/eMOjZ+rtJhHecpqB2moTixToq2RkOWmIhToq9jLWpOnswrUklIj5pC
|
||||
yxkdCU/OZDTYYU+AMXlGSQoiXems5typ+/oJsKVGPGHt6XkC+WTIX6Si1N4q7CFN
|
||||
8qiYRPH8G2A1QOv5uj6L
|
||||
=+6XW
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzj2AAoJEK8ZBAxxUjQCJygQAJfXI0fZjCgdicjtwN2RbKP4
|
||||
nLpao2BLcEkHQFmbCZXKQzy/oAGBR5xupoDbIFShum7ZEYe88Bn5W1LrKa8ELJ1C
|
||||
5EQGzEsxRe5jT6YsdAJfjjEIZiDL0U6HtSq2U08iNOIIuSC6sI0FElotMUOKYqKf
|
||||
oExRULIkDVfYKBQEmbbUEi/gJ0d6kD8AT0ts7VQU0Ad3jCZnDnFGLZvk4XCiL9wY
|
||||
OIjqmA/okDHuuD4+lgexiABxgYYtJFDIIunk02LPJ6R/S5Qn7mou+HgqBJo2g16P
|
||||
CFwTf+f/MxBNjQOhGJtS297tAJWjjRlkZyUOraYFa0eos8Drc9PpwjJyjgyuMiPt
|
||||
lvFa/Lx9kwnotP8cuzZV1GY7SV60NcItIKyeoTK1QNv/Qw6DeXJ8txSGOqo8x+bV
|
||||
LJxLRXNHseY6+C0/1WJCIz0PF4wt7tAXmqpA9wRBJWKRaLaLnshhDMDRR18d0Ejw
|
||||
/4oggqNc2S1J+lF5ziUyGYyL8HjtX4ngghMhvvWlmH+UDGQlwUA/R8G/u/ESHUXU
|
||||
bebc9bHbo9b5TAolkCbmb8/tT+ZFTZ7oAexYgOjsv9auB82ggMTlKnN0SJag7wUy
|
||||
owPgSReGONDlFJ3JKWL4HLvJT/UFvqV0dnbHMmlKlebvre9v3B1sV9hl1R5Sl5du
|
||||
T0dL3Ha3NTeppVXq+HRr
|
||||
=wUMJ
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzj2AAoJEK8ZBAxxUjQCao4QALTCDd7W7SZ8tyVNSmOsILmi
|
||||
7OcRdEdw3WNEpIXhYIo/NX1Sddtq1KgzHAgRb1tR3imB4UwVQfxD2olgIgoJTaMj
|
||||
P5jnRBIK98ht4iPXFkFmz3zOCBHSH/pXTy0jMjG0uC9czT2OWMlazA+brqaMI6oD
|
||||
JtgJEPIK1HfRdv0EfYCToj5LLi6iz4PVukk7i+8dqW/xFt1Lqny2ehggBFaIpG5D
|
||||
FAuuDbvnmzHODy7xpzPnRgBttpo6bIsQriVHrw81IWyhQJOKefjdiETB6N84+Lox
|
||||
ylgvk4Y5JiIrFVSoQGxbo3FlFth0CZlLSE8GuNSekAqYd+TjPIgtBmaHPuQc00sy
|
||||
CSw+NuaOkhq3y+rSkJgr5b04KDfvDhce2vF9maXtVPVEQ/r62WXNuCUoBVyift1J
|
||||
ViA+Ko9RISDlypHQBUj9KaWAUxTe14pKkaVggkrbM5c1+fvmjxr+FAZVSrnz8EOF
|
||||
K0J2834mNKNZWTo36NZ033BzoWE40HtSG+iDo6vGXNbAp8pFdRrjSaBO+Lklw6o4
|
||||
uMixmPDABielcUIaZiu23vW2qzOhuEIav5d7lu72XI+8ZdHrUymwra3EAs9Mmg7i
|
||||
0NPAwMHOPjdliswo8rp2hY7Shd7oMyNqxWj8BaPLCsxl82ofoPAtTcI4HCW2JXt4
|
||||
u2hOqXKZ5LihwcfgQHpO
|
||||
=By7M
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,8 @@
|
||||
1dee4bd2516f699723f373b2629c9173ce123b92c3a72520d0e25fcd8e3df45c jq-linux-x86
|
||||
b9b63aa4b3cc85df8bdca884effb69d66e9ebd717454a9e212d9423ffe3e955f jq-linux-x86_64
|
||||
6ab184edfa04d6f662a696d8594f19532ed78bc6fd05acf4cf506e789914300f jq-osx-x86
|
||||
335a99a68eb9a1ecacfc947550003f103cfed627d3116c8bcae9ac11dd26d337 jq-osx-x86_64
|
||||
2c1382b65a91fa27f2b9373331684de1e4ca577abeb724c3c79f4733af89b854 jq-solaris11-32
|
||||
da5e4ab2879022f365b77b9babbcfbc01f30a98b884a31120031e218d676ac71 jq-solaris11-64
|
||||
e08ca23dc637e8c0fe1577f592a9367e036f5b3f4c10b189c53943b0c8868866 jq-win32.exe
|
||||
1c96fd65fd60763b92a28c7ee1290eeb974bc69b71b963d0e45cbfca1625565e jq-win64.exe
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzltAAoJEK8ZBAxxUjQCbHIQAMU3mjBvi24X5CfTkyOmDOb9
|
||||
sxxsuTOiH8Zjiy+5NP7a1YLDD/yznLmuu4fm+XzCE8DYdzkq57jSyjr8rqN5poTM
|
||||
bk3+9P/Jf0Kae+tpTP8mjvtJ6bVPweV/Zg+m8YwE6/iUHQHi00AyQ6/obfXx7otn
|
||||
X9k2IIJATAvR7WJ+5+Uc390MkVNNvuINfuuLWdSPdIbwFf9lvZ2ZmwanrWo6Gzdr
|
||||
/TW3MCwZjWjENGQBYNTJwswTdWww5Mo7MrEK/eHEy4DlozJyyzwe5xsWRz+ERKSJ
|
||||
CXe3+DTSVoc4DVuFEhU3T+7jU+Fev0FOqLlu0jD64Ma7epk8/gP/gzzV8JmkX1tV
|
||||
xwqZAdlPl+wNs1ZQw+9dsTZiRIT/qQBxa4y7bunnjkxaSa2ovTz6EUaioeUk62z2
|
||||
e6zXNh92ZfjNKJT8An0Diq8i1P5EDH3dBHX3+2b9Qc15SFXE8vdXLqjIvTzwZ7hw
|
||||
fkxF37eMPfc527YKvktVUuXKkx458ossrHaYdcFnVh+etl6T/hQASE8Kp5rgVd/g
|
||||
5/P6/JrkrY3JTHM8qVC74YLqQh/w3xaiBzcz+za255EcKwU3qb8G0iPJ6i30yvCC
|
||||
l/Hj2IREDHyogPefgq8PYah5RvVXbiWJ/UKz+qm/vinm1DUU23F18Ezakxd0Q726
|
||||
Ok76sclCtAR8SCEu/3eU
|
||||
=fBEA
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWKaLsAAoJEK8ZBAxxUjQCv7UQAIEPihgkz3swMhxQVsRSd/dy
|
||||
d8sQMup6KFP3jAOABLSYyi6MrmCZhejodNd276ydxSgB/6rPClPZC6kSQsrv8fyj
|
||||
2CSaQOv1cItzPSObL39xNHAoj8LOkSbb+4jultfbntWU8iuAaBzrKc6jH9VR6zgJ
|
||||
YfeQun2LI8AqqBK0nClSwXLXFcjxmzR7KDwX5EPeBQdM1uG0iHO+CsZWKjC+pHPy
|
||||
WkNqOubVpo1zFFx6pTFmDNraPOxdLvMVMZ7fuHBbdv95NEi31CE4cmQzIhLd6BbX
|
||||
0xrOfT5xsib/uqlyhtUMjcqdrVcex8hptdsxrh5w9cZyhAinmpIEt59yS7Sbcg1m
|
||||
Cs6EdXJjjRGk5KVlyjuZJYOZxtCmdOYrLZVp7Nv2swIrUebkqWnXUAQk7Jdu8XmV
|
||||
2UzkhFvlWaTVb4dJ5s1zb6C9Yv9hqACsjXzM3vstcu2tiGmaH/TGCggqmubn72Ag
|
||||
Ok+YdhveZxnL8iF2odz7IdpC+kC/vVfCY9ndHv3Sf3i6uLuohuT2x45R3iz8GIMI
|
||||
ZuexdQGz/69blhw+ZsqVpxodgZIqnCOwIk2nTkrLOw2cJbtlDWh1s/9udW+nMmPJ
|
||||
Z2lzSP5A9jJzMCnkb5104LdpyqbGcUO016Tn1OKyLQNssViKlV/kcP/jZ4T0vuPI
|
||||
NIP2sEDPJQFBmsBmFR4B
|
||||
=f2Mr
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzlxAAoJEK8ZBAxxUjQCFqIQAL2JdiZNp9GZm+SK115N5Twz
|
||||
mjI66fKWg+1ckSfiCdYwSzg0u7AFSECy+S8vq9WzSKsvIptGPJokIehnIrwpuw+l
|
||||
s7sfDA585XkRxpVoEwAdPalTRqXvmku8Sc4P1519K2DZDvtvWPY3N+tWIRE9jfcW
|
||||
04KDTuWB35N8e+Mgg8z9P0NJiDanP6SUHp4r8Pc7KFQ/gOK4HKq9dFa3nsmkAq25
|
||||
XJTFYPS6VU5tj/ZyTPNtMh1Nb0vp7+qeXGV+pBMwohmNoBFUyx65olwegD+dSswb
|
||||
Cfh59P+aWec7V6exJq7EW7ptIaZzp1LeoPfcABDjSOTEeez6ywIcsPnmfIjAh98e
|
||||
WovH2iiWH9XvLT6EC7gUcdlMJtvz46OkXilQAo0rK3X3pFX0T2aSqp/afdPtIvpK
|
||||
bErpQKt65XNsRprBkBlM1Jo6K7Cwh/SYKlbSJuvYvieORQ9w+0oqmYRCk7MZ7OOG
|
||||
Nxz3yEvEnzQPaXnSnJ/cK0xb9Yjj72LRV3Ors+ni9HfLm14xN7zBx+g6rudf9hy1
|
||||
UFcvrxJSRFP5bZZxorWc6busisRi5E9sRQm/kGlTUUbrJrV1iae7h7s7+OqnY3aG
|
||||
H2lF4Gfb1eVsltQZ3DCRNiBiTD+3cmzEayD0ktHRnubOQCc331RoEwSNBsV02rkH
|
||||
2ZijCFT/AmHOl/fqmX86
|
||||
=b++s
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzlyAAoJEK8ZBAxxUjQCiLMQAKBpyaj6un1mLebzt4JDQmEf
|
||||
qzzYK/q5RLS0vGzcYAl/ylBPdbBv6j7oT2JfPA9YfZaUPOd5O6eqk6R8OVrEipNe
|
||||
kvfIMnzk5joo+LDomdZvOhv6A0f/Q6eKnlr8k36INQxtbQA/xzUAuQthoo5Xn5ze
|
||||
d7lEHcWCpyaRne3dC5W642qG6X1hUN27lfx4MRHfSvFsSS4YIyPQHPiKPkQ9BzyZ
|
||||
p2XmWLwNSQRaVQU/fG8LbcRFeu7CBIFlQ0IvRfARNvJGFO+Eu6JDNZg+w8b1GL4O
|
||||
Td3rEb5tiJ1LEZxe2HDUV/b7/k2BywrRGnMbLFbohtyr2BmFCAzqy6UySNA/DU3H
|
||||
5owLGNw0F3tWHg9yqGkTMcMTp0nfIbNKbjQcfSWKO+9gkoNyn+o78ggerRJAAt0U
|
||||
0vcoLbfTMBTRfxNHaRB0dd3YxbkHvr3tAY9A1sqkBGB0SJoZ6WkLsso2tBsivq/X
|
||||
K9x4pXY15LSKu8opFJ1PY82Ng2FdRlkYs1CDNB5IM52mp5IAgmxGzHCy4S/XRBCq
|
||||
i0RSwg5xwCRllqmfRkgHQDFT8lKOLwMnLrzqQVsBneddvT//A13pHAI+vsloHbiB
|
||||
PwNgEdbvFVrxMaY8ampzQZ7vw15qOGcmGTJolIEhPdxvP9J9zTcf5nzF4WSJPdMC
|
||||
IF2dukcTW+c/C37F5nQu
|
||||
=+j1U
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzlyAAoJEK8ZBAxxUjQCopgQAIII75ovkAQmCS2aU5Ph2Yfk
|
||||
xLj40CVL7KThOWcfqKYy2Sv4+QV2dIjx14Uni/4w/dVGG0shtw1teUlfotBczR88
|
||||
iyWvSVavbJLlyHESN7z4M4uApHikncNDlFJm/CuQWSVkGhtWvZZzJdoS/prypfai
|
||||
1+sjtiDidNTZEJj5nfkvZ90UKpzNPJD8RGpsN5qvGyVnIYmXWZ1xe4pwKiNaUthJ
|
||||
0wUBUcisTruZWCdSkV5cQMvb23sH8Qt+OZYgxJvx0Eq3+fG7Bh1J4YJLluMB1cSQ
|
||||
lqpOn7yJ4VptkgYeXoPMhbvN3I1/t+w43fL2P4jo5YTYuyVjxkS+VhEIGOgl7khN
|
||||
P0zzc1fdUw857dTP1/gXHTgMq3mWVAoQZnqcZEl1wnM155i+PYuN2kG0N2q4nt3p
|
||||
oQd58tZD/KmCV+QTegtt/gpavztxqWr6aagI+UynBfVKaOxY6AB+0+1oaQTX6iYK
|
||||
iqCqbhDi6ak8e7sXflAKrMhlnA4X+XCINdSwnYR96t/JY9tMFDiDapvbfgzdCi/D
|
||||
+0v7S8G0cu4pEjQw8rcotoPU2qF9cjMpmi2RsFDHpGsLv5r7avz5jDFxu9yEVMMd
|
||||
sp85aDh09bZfBACY4+t9m1AHCZO5LbkLremHv+nHA8ds/wiMmcCmRIgJQKvOA5l+
|
||||
C/380YfJeepNvCnoIpr1
|
||||
=NVrs
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIbBAABAgAGBQJWGzlzAAoJEK8ZBAxxUjQCW1AP9j8jyZcTFFzBAqLbxrn5Ljbj
|
||||
6VXIDrutvXqcL1/KiPt2zT0deAqh08yCZh0RIQuq/o86nOXKumcK1E1jIcZPQ0p0
|
||||
g3Pik4yvnJo7HCrJzzOXatfb9PokTEmM1Vo7qrJvQ1DPC8PyCS+fd2BLV4km2Uvp
|
||||
IMF3Wsa1nfRlcb/6Xmq/QJDhOG8MoIJ6Ldo+nFlCDqvKzGpQmmGo1gj3x32LkTUE
|
||||
aA8wtZ4RsCSEY959w5NVxhcX6H0iv0yzGtpOPRwaOOmymxuA0w7035P9TDrGExhU
|
||||
t3tMiTBWLucJgHPYH8XunBKjVzFDj8TT7gOq18MzuCJxUhPaJZZWAndFxQ8rxgNA
|
||||
ZUzmOpaX95DuRF9a5SMP8OpAOCOsM0lySCyJGWLoQ0Su55uaThLOVaDqBmXF13IU
|
||||
lviJ0DWPzDTPZ1Tn77kwhAWXglcsE6S2pBhkLID76kW2GtXVhatBPls0mE2Oe0AS
|
||||
p69dW/ynDuXyf0UjpcIH9UPVwsmXPX5LXztAh/2r6raW6VdnvGCjb2dWmPgFJP38
|
||||
HuIKPnx6F3MeNSwKHlky3xfe7X4GNiciwTqbd6EEeIHGHMDbKSA91tuhbiBDGulC
|
||||
f+lGNWXPZTN+zqbUaDAArLno3vg+vQKhvvkdwfRhFYYqeFJwdKGXo5aEH5g/t/n0
|
||||
8sewgmHKqlUa73LzABM=
|
||||
=WcIy
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,5 @@
|
||||
264118228c08abf4db8d9e907b9638914f3eadb5cd50dc1471a84463f7991be0 jq-linux32
|
||||
c6b3a7d7d3e7b70c6f51b706a3b90bd01833846c54d32ca32f0027f00226ff6d jq-linux64
|
||||
386e92c982a56fe4851468d7a931dfca29560cee306a0e66c6a1bd4065d3dac5 jq-osx-amd64
|
||||
1860c77bc2816b74f91705b84c7fa0dad3a062b355f021aa8c8e427e388e23fc jq-win32.exe
|
||||
ebecd840ba47efbf66822868178cc721a151060937f7ac406e3d31bd015bde94 jq-win64.exe
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzk2AAoJEK8ZBAxxUjQCJ8cQAJJQoCwUiFf5MHqGHGaSC07L
|
||||
bKyvm2OmSzVscld2lb7MsTHRUJ3RR613CpuYsNEG/nVbtaUntzgmtyMWabuGap0I
|
||||
QRQb08by5wP5Mve7QCOxfO9o56k/m2MJluMFv2xdJrfbLBlJuffV8rTWCNSNFpaD
|
||||
MLTiMnSx0APGxEoN34wOZ7ZDL6yIb+7z3Ip9P8lni4f3B+fJGCwKr9Sr5NztZVGL
|
||||
fDwfTBDLHwgpPvXlddg+oEDqVoSodWW9LZYKVo3q0IrT1nI4TdCsc1Fautpz7Y31
|
||||
J2rcZR5qwE9jy+fkm3+vX9Hbg/QlND07ZX21bJh1suE+1ggELrVwh1iCEfBIVEZN
|
||||
3tat62QUePL5ymAaElbeX5nIxuNW8U5jP5fjtVu2uEZKRdPz0I1JcGzILi479TCK
|
||||
/AcBhoXvdvd6sXjqgNs8ZbNBoklNqwrbLw1ESzwzaGfKytvMIO8rN8E26CO82d0v
|
||||
3gob2Bc9KE6+hdobdax/SdXzjdAsyL4fDezRQGk1LvLV3I5rLs6cdR2HRjbH2uFU
|
||||
auNQgDLTo1PAYgsTDvDUt61O6K1m2Fx4RZgc6pligHDxlcvPJw+DkSsU+QRD0ODk
|
||||
2IYhdakVFOaG+OMcCfcLFJ/3mJnhmFl/VQVdLlrELy5r6NaQo7bkLL1asU9LJLlL
|
||||
N5ZHYSx7HvRCAz++hd3r
|
||||
=GYEt
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzk5AAoJEK8ZBAxxUjQCJZ8QAIlRnnKW3A6yLpAGSNsQ/Rm1
|
||||
34ElcCgwwGsQFaBz7ZjzYPwFNmbrQYi4uJA14Sh0MAWgJiIfjJs+nS2YiC/6etdh
|
||||
uCEg4NdYtF6kPlBMQ1MJN1+OLv7ACst3kajezpoCHraEQkcFgF4CSTq2zBVeSltp
|
||||
QxVJkMn6CM308cbimWI+wB8z//28Sxer7KyeIbZ9Mjt0YGHYsxIeNhPtDNgVzutd
|
||||
4lYGS/YRbRKrVKje/20BCmU7QnyGnWIZDx3A8ofhGbLUnKX80eBuHLWUkruGbyL7
|
||||
KMuXPbKAyqtMiGRziqiqkvKRe+aQc+kvJVNUYORnV/nSBFYqqp9WpaZGy0VrXcVS
|
||||
szAiIxPFULeAPBiycaLyPrs2sANnbLSaK5OYc/OQl3fQd8K4HycHn7gWzTrsSiJ0
|
||||
O2u7YpIZwhnJusZQFbvicU5TEnTnUs68PkBRjI/MJYGna5CrE0dhEjxQ7xfqHds4
|
||||
daBHctNOo/v/Wx6cUOklpdygZK0l0DWdNNgf4u0ID/qrI/r+F2WYTMO9FTxuquID
|
||||
AnOcKJAnW/uoDx3eEl/Xf92Be1pvsBSU2gwJZ97UYXT1DKPdsoO8ubUNTjDL2BCL
|
||||
7mVQShAasKvCB416kg2v0NqR83v2iLzfERbmyZhhR67WwjSi23r9UXPjgBGsux6h
|
||||
0uohePJ5f76elv2W/8rO
|
||||
=4Qhb
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzk6AAoJEK8ZBAxxUjQC2tMP/jitj5yEkh4PL/apImNJBZSd
|
||||
PPRWhOgdBvSV5kycstS3ni/sU2ZcHtf122BLonIJHJN0cL/jVZypJNIZ2gNTA4sn
|
||||
pi85vNuwhEKYfgMbLnVG03KoMtdjZ/kPSJn8UK+5ShEwm9HgbLbe1Pp7XQJW1nAG
|
||||
hdNT6ldqbyZ0j74r0yekN516VdpPPVp1R5rDVxcZMOKNeTbNlX4juEK+BsKvp1gT
|
||||
/SWxC6Y048ogMT1YnVySnh6Q1/2/riIhlw2u26Is4MHP9Dc7wxNyegTU6UU4uAXd
|
||||
Ejg81FpkhRZzF876ZOEfjlDsKLAYIEAYd5ozq/VpCA+rB30Y20tOCPuhilnuWQ53
|
||||
9Le9ybgfJOGwloh3vfU3O9fbQKrL6TjA+crK/OmZvjSsyj2ef98vjWdFG8fhUr4f
|
||||
HVTnmJcg6R7WIBHxVnxfT9D3hIV0+l8qCWu3TtTlfdGcXqI0NcY7Exee6WbNdmkj
|
||||
0nESSddP2nEb1eCEw9IlVliZevJYqwNaSmcN92EWTzJEwj9g7+yK0XWs+ZfDNTUD
|
||||
+iQoFY+W/skSfNr5XCyj2wlSElIHUlQtCVZvrnbRz/QmjZfUMTBdKkkVucDGvldy
|
||||
YyauXVEIvhFdeY59E2FzoZpdn7LzyzGbg2dA2QwGI7WB39L1QnLMrRPOmBwMJRvc
|
||||
JBQycWmsgKzAre48vKpD
|
||||
=LnUB
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,3 @@
|
||||
dfbb2d073d2df9ee0bec44b60bd81e213b7881b27fc38d7438daee9eded2b75e jq-linux-x86_64-static
|
||||
bc370e22a11c85c525ba1965760faa5273aa3cd0ae69b030de4091fc776538b2 jq-win32.exe
|
||||
6fb6f39d847df57b481d36941216c770ccf5f97c36e5373a0c93e63b5506c9f8 jq-win64.exe
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzlUAAoJEK8ZBAxxUjQC6acQAIREc1GPBwDiL3STKWVEUYC5
|
||||
r+Cti+tWisdNGvAapCdGcwcavZ06PM3lMejBpQ5v2WghvsXhFvxDnwyQHKhbjIdG
|
||||
Uw3btu3ykjabHfqi5L5neQjFJwK//zsan59VSTzRWxjPHpAEoFsEihddKdx8kWzI
|
||||
KfPx1sn7ftO5weFcl0MU9ks9kbADJpviAvCk1mxKeNbv5KE9EYiUMjEg0kW6JmBM
|
||||
rIJoWc4fUR7rHbnK8fKpEuBzPLRBppFOG+ma7dx/4tCMjZmzmGIzqrCwgRStoS6j
|
||||
mr1Ws1f+j4y9ZdCXqubDVpzesIQ5fWc99H3kNuzIHBku4o70OOaGKdqvi5JBSiJf
|
||||
E6hD6FrN0ugu92IvRHNG4Vkg1hfNiff97ZX4lEHicFy2Bbpql56yHc136wAlLkvN
|
||||
8ns9xIE1APTZI6J/6lHfUDStWgKOlsgf51UuT/sJQeE0N2RscSJ7cxhR2F96RQ+Y
|
||||
Vb+hMg8QLA99B4OWbohkKR9eePoEjLz9u9kgG/AOJy24m76pjO3az8Xee9I4LFMp
|
||||
ws78NtQgGi+ZJ6JP4QsEx9ZakpdWGnpDgIskQE+LL7MH0mXR07CpXXEMTnEIBMj9
|
||||
ll/pFQ7bFJiPSXZZhRQVSiNhL3a6DeLe/Ik9xY/djH4WAMuOpEQsbI3cRxOktp26
|
||||
FsUWKNf6I+CrLaXbbrBB
|
||||
=lABc
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzlWAAoJEK8ZBAxxUjQCmrMP/1jfOkKVG7FZgArN0ZYBgJiR
|
||||
jP5L6/zlMG9SDecNnEVJ+PX7YdiBlnIQ7icV6iveBsSvkVyY1Mp+0ibzIePtNV8I
|
||||
0SScmo4Da1gQwxaX8lKIfCTemOSvhxl0xqdOsYHq7nRxnxSmh4MFnDqXLS8ryW02
|
||||
/N4NsFaUCjEvyFVfNjRGDwxyR3RhXr643p3vp+JZvZ8wLeZhM+ZXg0VDdXAFFVHJ
|
||||
EjIvedxV/IU4brVkqgRDPmAKdaVbLRezGl2uj7PYg1fcNXevUSHEY6bsxp9FSanU
|
||||
LWkD/0rElPdsV+B5ST2f3K7vTSjDOBA+6L3AEUR2tViCe/FOJGTMvVrJTG3/r7hh
|
||||
STARqZHX9q/1oEFQAZY1PX3mKCUrXKTBLkTWNWg78jtYXtV8JagQQPV5CcmaqPVA
|
||||
u0M5lNKDhgx5Qwy/Ap3FYkKtFHFuDxK6Y+px4J7hGRuH2casB1lYX+4YS4J8h4my
|
||||
9dnmly/fpOI5nuONzXweX9zizNcmolqf9RAvWE0umurBj8Qyo5vMeEfiHVU3DSxw
|
||||
tIDAnT1bQv6s0mEBvFX2Fx6AJHc8wY4+iyu/fOMpSdMfbJ8lXeXYFH+SzV4uwseq
|
||||
c4j9eQ+Ab8SoCUMsFiS7KDAhsiMYk6rKn+aJthl/72GVBbnoLbYJs0frjlAsZmz+
|
||||
ReXdr1sBmm2qFoJ43w+9
|
||||
=UxxZ
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzlXAAoJEK8ZBAxxUjQC3YwP/23mNNa+XscTIWHKPihfNoNn
|
||||
TIgGXP5znWOUmkNarIDl2ir5qi8oq6kBLoz917uz1X/KY3yB1rDoz+apB3Co1Ayh
|
||||
S+oRMeHUCE2V5OIBPsJyMHM3cgfdbVx3fNwZitpv4Tw7s9ilRG7SWD/2Ev2GKx/h
|
||||
Qn4j9JLrxJdvoSS488oyjK7rIXLSDM5R97qFS52Cl4beO0dJTdy8D7QOCF84soHb
|
||||
SUgrXZkNuzjs7qQRMJb60mhQeIkuUC55VoOUufoXTwpBZJNNoyqT1eNNlZXE884Z
|
||||
kvKJ2q0FYD7jh1Ct9KFr6gfx0HIjxMb2YYtCEilkKSCHG8JUHgCY5cpAMDZrVa5K
|
||||
ss9Iu+dkor96Qv7nyJ+zhjEscl1rpfvYKJbMLhC+M/lHpZc+5rtZBPFmZv8wedzB
|
||||
a3/hkyPpxp2YPa32CAZ4UVFE3h+lBLvT/PV5pB8UvYPbDrWzLx/V2aNLP1joZKH0
|
||||
y4DECAVMAD2a3dv+xuee7ZJcmL4gK8a6sZbYuOWgnIjjGQ4W951Dz/CoiojqofKO
|
||||
9QmcDiEOQQdnjpfuObSX6wNV3583z4GEHIuKLQiM7rtmIvzA2x1RCF/txZoxg9+T
|
||||
vwvyz+689ju/mIdUjdCGwPW6qljoMWRPXHJ11mD0CBTQmNEJiMbhE5lt/yH3/big
|
||||
mVPHv/DkOEM8pLdpMHlj
|
||||
=+eGW
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzlXAAoJEK8ZBAxxUjQCwSQP/3hRFwE5XzTNpBbMFiThq8GP
|
||||
xON/4/6H0ql/weVZPRyoVVuToKY+oym5j6IhwBp8eswQKMF0p5FpBjFJFFeXM9RC
|
||||
iSmYL7NGKSZJMLQHFLM37I/eDbaIOo4OobtzD0CAg8ZN8nlIHajxZ+vsmcuU/L6k
|
||||
nC5++MJEBWoUMYUdqII0F+ivlZFwngrnCgeLIVwWt55ojntbBjjs32S2gT8HugPz
|
||||
11zAnx5C7KfDTnDNgMPFDPL3T/yVoyasVxidTB4sQrFeR2vns4F3uDugEBAWMb9A
|
||||
3WRSzcuYdlrVOzB8WoHS3E0esEeuqtPIz7y3mvrvYsZcpIPpXaagmKALG8zZ7p87
|
||||
/s9zpQdFWTe+boI6CdjG1+UKY/QhDAl3zalIQiqFSiBsbk/yhDtNug6oqGO/2fQw
|
||||
/xWlj3CmQsSMI9KjlrcIv2k4ugbYtIxVRvEJqqI8Qb47Lmav+F+VNhrwCcFdlMiD
|
||||
swD4xfT2Knfkx7OOfDv7fCRE7njBBOTumYu1o7G8HbZokSkAtS5sovrzLWEzXRPz
|
||||
lV4Of454G5Quif+MQIw0P55XgFCLLCEpcbt4vOtkCK/GaLuV2+JKoyJMoFEG2mAr
|
||||
T2ufop5Re1z0hvNe2VLsMhcUpSUKsFl4h1aM+YYhsOnlGG7uXA0bTAMmU1+n2uKE
|
||||
k/rOwLp4Lyh9gw78IB8T
|
||||
=A99j
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1
|
||||
|
||||
iQIcBAABAgAGBQJWGzlYAAoJEK8ZBAxxUjQC6bQP/3WzIL/KgnUmI3ziUJcaKgLx
|
||||
EOkMA7Ib5o5w75gg9img3pvYCLZnlf40TiRAhc/gQ+uIw8uLs2wqZFPSNE6G1U6i
|
||||
L2AQbcl4e7P4glvsd+PjXKz9lzCFyPtCgEeFA/T4UP07ef3yRpreFmYcW4A/5Saf
|
||||
WWn8nKyVL6vLS2vG4zZi6g61Rw9mlWFC6VeVLe+/IHMH3y6WtT71SDw3h0OFH+Ui
|
||||
DVSFXeu5Fiu/NEiZUyb2BLK/a817zhQ5xq2/mCoYrKLgLzbKaSuqMe47Qn6Yjkbo
|
||||
82F+lDakDS3bsoIcvDkR2w8ABsPwPX+xDk8Z2Usyq2wcCEvSTKoB0AiczYfe6Eod
|
||||
uz66AoDZY/v3XXs9F3NWJqLRfRzu+fHcw9fvfzLET6gVkmbc5+Z7fDNXOtJlS2oT
|
||||
KKImd1vuEoffjgblera4Dg+v2f7rY7yFCQEsYGLnhyEb1/G4nb/MvQJ49NOB9AXJ
|
||||
pVvslWnwWJVy0pzo0VqjpldKGg2EAFcJ19+pgUOFFCF2Ax1HsvJhuxiyOKBDbn2q
|
||||
N8ivnjv79B62epIdUc/zGLP1In9yoQcDfenYlBI1PJL7nw4JdxFGBS5ajE/SftAD
|
||||
FwsuKvIlToO2s0bn+d6famRnxigWOhjr+/Bm/8AP7HAJdD3Jes6AJLsuUANNUfW6
|
||||
aOU4u35qnEb1KZIrvozH
|
||||
=ZZtM
|
||||
-----END PGP SIGNATURE-----
|
||||
@@ -0,0 +1,5 @@
|
||||
7ece904edef3f951ca0c6f68cdb14e782d52aa46624fe2de9cfabfbd98fe5797 jq-linux-x86
|
||||
cced974e1f2c50d6203e09c2e3ede44075c4f35601233378deaf7bfedb2b4aa9 jq-linux-x86_64
|
||||
25f930463c94414fbff1ba5d76a9547259073e8acb19f709880e913ab58586e1 jq-osx-x86_64
|
||||
8bf6bad065dfe5bfaa4c22a9ca80fddf8bdffc06b8fc768040e4fd88fbe5f58a jq-win32.exe
|
||||
f8301b1279ac95e09fa9bfb1b38d411e68590bedcbe70d27ede7a70955d855dd jq-win64.exe
|
||||
+78
-290
@@ -1,6 +1,12 @@
|
||||
#define _BSD_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#define _XOPEN_SOURCE
|
||||
#ifndef __sun__
|
||||
# define _XOPEN_SOURCE
|
||||
# define _XOPEN_SOURCE_EXTENDED 1
|
||||
#else
|
||||
# define _XPG6
|
||||
# define __EXTENSIONS__
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
@@ -104,9 +110,24 @@ static jv f_ ## name(jq_state *jq, jv input, jv a, jv b) { \
|
||||
return ret; \
|
||||
}
|
||||
#define LIBM_DDD_NO(name)
|
||||
|
||||
#define LIBM_DDDD(name) \
|
||||
static jv f_ ## name(jq_state *jq, jv input, jv a, jv b, jv c) { \
|
||||
if (jv_get_kind(a) != JV_KIND_NUMBER || jv_get_kind(b) != JV_KIND_NUMBER) \
|
||||
return type_error(input, "number required"); \
|
||||
jv_free(input); \
|
||||
jv ret = jv_number(name(jv_number_value(a), jv_number_value(b), jv_number_value(c))); \
|
||||
jv_free(a); \
|
||||
jv_free(b); \
|
||||
jv_free(c); \
|
||||
return ret; \
|
||||
}
|
||||
#define LIBM_DDDD_NO(name)
|
||||
#include "libm.h"
|
||||
#undef LIBM_DDDD_NO
|
||||
#undef LIBM_DDD_NO
|
||||
#undef LIBM_DD_NO
|
||||
#undef LIBM_DDDD
|
||||
#undef LIBM_DDD
|
||||
#undef LIBM_DD
|
||||
|
||||
@@ -367,6 +388,12 @@ static jv f_tostring(jq_state *jq, jv input) {
|
||||
}
|
||||
}
|
||||
|
||||
static jv f_utf8bytelength(jq_state *jq, jv input) {
|
||||
if (jv_get_kind(input) != JV_KIND_STRING)
|
||||
return type_error(input, "only strings have UTF-8 byte length");
|
||||
return jv_number(jv_string_length_bytes(input));
|
||||
}
|
||||
|
||||
#define CHARS_ALPHANUM "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
|
||||
static jv escape_string(jv input, const char* escapings) {
|
||||
@@ -1220,14 +1247,17 @@ static jv f_now(jq_state *jq, jv a) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static jv f_current_filename(jq_state *jq) {
|
||||
static jv f_current_filename(jq_state *jq, jv a) {
|
||||
jv_free(a);
|
||||
|
||||
jv r = jq_util_input_get_current_filename(jq);
|
||||
if (jv_is_valid(r))
|
||||
return r;
|
||||
jv_free(r);
|
||||
return jv_null();
|
||||
}
|
||||
static jv f_current_line(jq_state *jq) {
|
||||
static jv f_current_line(jq_state *jq, jv a) {
|
||||
jv_free(a);
|
||||
return jq_util_input_get_current_line(jq);
|
||||
}
|
||||
|
||||
@@ -1239,6 +1269,10 @@ static jv f_current_line(jq_state *jq) {
|
||||
{(cfunction_ptr)f_ ## name, "_" #name, 3},
|
||||
#define LIBM_DDD_NO(name)
|
||||
|
||||
#define LIBM_DDDD(name) \
|
||||
{(cfunction_ptr)f_ ## name, "_" #name, 4},
|
||||
#define LIBM_DDDD_NO(name)
|
||||
|
||||
static const struct cfunction function_list[] = {
|
||||
#include "libm.h"
|
||||
{(cfunction_ptr)f_plus, "_plus", 3},
|
||||
@@ -1273,6 +1307,7 @@ static const struct cfunction function_list[] = {
|
||||
{(cfunction_ptr)f_greatereq, "_greatereq", 3},
|
||||
{(cfunction_ptr)f_contains, "contains", 2},
|
||||
{(cfunction_ptr)f_length, "length", 1},
|
||||
{(cfunction_ptr)f_utf8bytelength, "utf8bytelength", 1},
|
||||
{(cfunction_ptr)f_type, "type", 1},
|
||||
{(cfunction_ptr)f_isinfinite, "isinfinite", 1},
|
||||
{(cfunction_ptr)f_isnan, "isnan", 1},
|
||||
@@ -1305,8 +1340,10 @@ static const struct cfunction function_list[] = {
|
||||
{(cfunction_ptr)f_current_filename, "input_filename", 1},
|
||||
{(cfunction_ptr)f_current_line, "input_line_number", 1},
|
||||
};
|
||||
#undef LIBM_DDDD_NO
|
||||
#undef LIBM_DDD_NO
|
||||
#undef LIBM_DD_NO
|
||||
#undef LIBM_DDDD
|
||||
#undef LIBM_DDD
|
||||
#undef LIBM_DD
|
||||
|
||||
@@ -1339,9 +1376,15 @@ static block bind_bytecoded_builtins(block b) {
|
||||
{
|
||||
// Note that we can now define `range` as a jq-coded function
|
||||
block rangevar = gen_op_var_fresh(STOREV, "rangevar");
|
||||
block init = BLOCK(gen_op_simple(DUP), gen_call("start", gen_noop()), rangevar);
|
||||
block range = BLOCK(init,
|
||||
block rangestart = gen_op_var_fresh(STOREV, "rangestart");
|
||||
block range = BLOCK(gen_op_simple(DUP),
|
||||
gen_call("start", gen_noop()),
|
||||
rangestart,
|
||||
gen_call("end", gen_noop()),
|
||||
gen_op_simple(DUP),
|
||||
gen_op_bound(LOADV, rangestart),
|
||||
// Reset rangevar for every value generated by "end"
|
||||
rangevar,
|
||||
gen_op_bound(RANGE, rangevar));
|
||||
builtins = BLOCK(builtins, gen_function("range",
|
||||
BLOCK(gen_param("start"), gen_param("end")),
|
||||
@@ -1351,292 +1394,39 @@ static block bind_bytecoded_builtins(block b) {
|
||||
return block_bind_referenced(builtins, b, OP_IS_CALL_PSEUDO);
|
||||
}
|
||||
|
||||
#define LIBM_DD(name) "def " #name ": _" #name ";",
|
||||
#define LIBM_DDD(name) "def " #name "(a;b): _" #name "(a;b);",
|
||||
#define LIBM_DD_NO(name) "def " #name ": \"Error: " #name "() not found at build time\"|error;",
|
||||
#define LIBM_DDD_NO(name) "def " #name "(a;b): \"Error: " #name "() not found at build time\"|error;",
|
||||
#define LIBM_DD(name) "def " #name ": _" #name ";"
|
||||
#define LIBM_DDD(name) "def " #name "(a;b): _" #name "(a;b);"
|
||||
#define LIBM_DDDD(name) "def " #name "(a;b;c): _" #name "(a;b;c);"
|
||||
#define LIBM_DD_NO(name)
|
||||
#define LIBM_DDD_NO(name)
|
||||
#define LIBM_DDDD_NO(name)
|
||||
|
||||
static const char* const jq_builtins[] = {
|
||||
"def error: error(.);",
|
||||
"def map(f): [.[] | f];",
|
||||
"def select(f): if f then . else empty end;",
|
||||
"def sort_by(f): _sort_by_impl(map([f]));",
|
||||
"def group_by(f): _group_by_impl(map([f]));",
|
||||
"def unique: group_by(.) | map(.[0]);",
|
||||
"def unique_by(f): group_by(f) | map(.[0]);",
|
||||
"def max_by(f): _max_by_impl(map([f]));",
|
||||
"def min_by(f): _min_by_impl(map([f]));",
|
||||
static const char* const jq_builtins =
|
||||
/* Include supported math functions first */
|
||||
#include "libm.h"
|
||||
"def add: reduce .[] as $x (null; . + $x);",
|
||||
"def del(f): delpaths([path(f)]);",
|
||||
"def _assign(paths; value): value as $v | reduce path(paths) as $p (.; setpath($p; $v));",
|
||||
"def _modify(paths; update): reduce path(paths) as $p (.; setpath($p; getpath($p) | update));",
|
||||
"def map_values(f): .[] |= f;",
|
||||
/* Include jq-coded builtins next (some depend on math) */
|
||||
#include "src/builtin.inc"
|
||||
|
||||
// recurse
|
||||
"def recurse(f): def r: ., (f | select(. != null) | r); r;",
|
||||
"def recurse(f; cond): def r: ., (f | select(cond) | r); r;",
|
||||
"def recurse: recurse(.[]?);",
|
||||
"def recurse_down: recurse;",
|
||||
|
||||
"def to_entries: [keys_unsorted[] as $k | {key: $k, value: .[$k]}];",
|
||||
"def from_entries: map({(.key // .Key // .Name): (if has(\"value\") then .value else .Value end)}) | add | .//={};",
|
||||
"def with_entries(f): to_entries | map(f) | from_entries;",
|
||||
"def reverse: [.[length - 1 - range(0;length)]];",
|
||||
"def indices($i): if type == \"array\" and ($i|type) == \"array\" then .[$i]"
|
||||
" elif type == \"array\" then .[[$i]]"
|
||||
" elif type == \"string\" and ($i|type) == \"string\" then _strindices($i)"
|
||||
" else .[$i] end;",
|
||||
"def index($i): indices($i) | .[0];", // TODO: optimize
|
||||
"def rindex($i): indices($i) | .[-1:][0];", // TODO: optimize
|
||||
"def paths: path(recurse(if (type|. == \"array\" or . == \"object\") then .[] else empty end))|select(length > 0);",
|
||||
"def paths(node_filter): . as $dot|paths|select(. as $p|$dot|getpath($p)|node_filter);",
|
||||
"def any(generator; condition):"
|
||||
" [label $out | foreach generator as $i"
|
||||
" (false;"
|
||||
" if . then break $out elif $i | condition then true else . end;"
|
||||
" if . then . else empty end)] | length == 1;",
|
||||
"def any(condition): any(.[]; condition);",
|
||||
"def any: any(.);",
|
||||
"def all(generator; condition): "
|
||||
" [label $out | foreach generator as $i"
|
||||
" (true;"
|
||||
" if .|not then break $out elif $i | condition then . else false end;"
|
||||
" if .|not then . else empty end)] | length == 0;",
|
||||
"def all(condition): all(.[]; condition);",
|
||||
"def all: all(.);",
|
||||
"def isfinite: type == \"number\" and (isinfinite | not);",
|
||||
"def arrays: select(type == \"array\");",
|
||||
"def objects: select(type == \"object\");",
|
||||
"def iterables: arrays, objects;",
|
||||
"def booleans: select(type == \"boolean\");",
|
||||
"def numbers: select(type == \"number\");",
|
||||
"def normals: select(isnormal);",
|
||||
"def finites: select(isfinite);",
|
||||
"def strings: select(type == \"string\");",
|
||||
"def nulls: select(type == \"null\");",
|
||||
"def values: select(. != null);",
|
||||
"def scalars: select(. == null or . == true or . == false or type == \"number\" or type == \"string\");",
|
||||
"def scalars_or_empty: select(. == null or . == true or . == false or type == \"number\" or type == \"string\" or ((type==\"array\" or type==\"object\") and length==0));",
|
||||
"def leaf_paths: paths(scalars);",
|
||||
"def join($x): reduce .[] as $i (null; (.//\"\") + (if . == null then $i else $x + $i end))//\"\";",
|
||||
"def _flatten($x): reduce .[] as $i ([]; if $i | type == \"array\" and $x != 0 then . + ($i | _flatten($x-1)) else . + [$i] end);",
|
||||
"def flatten($x): if $x < 0 then error(\"flatten depth must not be negative\") else _flatten($x) end;",
|
||||
"def flatten: _flatten(-1);",
|
||||
"def range($x): range(0;$x);",
|
||||
"def fromdateiso8601: strptime(\"%Y-%m-%dT%H:%M:%SZ\")|mktime;",
|
||||
"def todateiso8601: strftime(\"%Y-%m-%dT%H:%M:%SZ\");",
|
||||
"def fromdate: fromdateiso8601;",
|
||||
"def todate: todateiso8601;",
|
||||
"def match(re; mode): _match_impl(re; mode; false)|.[];",
|
||||
"def match($val): ($val|type) as $vt | if $vt == \"string\" then match($val; null)"
|
||||
" elif $vt == \"array\" and ($val | length) > 1 then match($val[0]; $val[1])"
|
||||
" elif $vt == \"array\" and ($val | length) > 0 then match($val[0]; null)"
|
||||
" else error( $vt + \" not a string or array\") end;",
|
||||
"def test(re; mode): _match_impl(re; mode; true);",
|
||||
"def test($val): ($val|type) as $vt | if $vt == \"string\" then test($val; null)"
|
||||
" elif $vt == \"array\" and ($val | length) > 1 then test($val[0]; $val[1])"
|
||||
" elif $vt == \"array\" and ($val | length) > 0 then test($val[0]; null)"
|
||||
" else error( $vt + \" not a string or array\") end;",
|
||||
"def capture(re; mods): match(re; mods) | reduce ( .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair ({}; . + $pair);",
|
||||
"def capture($val): ($val|type) as $vt | if $vt == \"string\" then capture($val; null)"
|
||||
" elif $vt == \"array\" and ($val | length) > 1 then capture($val[0]; $val[1])"
|
||||
" elif $vt == \"array\" and ($val | length) > 0 then capture($val[0]; null)"
|
||||
" else error( $vt + \" not a string or array\") end;",
|
||||
"def scan(re):"
|
||||
" match(re; \"g\")"
|
||||
" | if (.captures|length > 0)"
|
||||
" then [ .captures | .[] | .string ]"
|
||||
" else .string"
|
||||
" end ;",
|
||||
//
|
||||
// If input is an array, then emit a stream of successive subarrays of length n (or less),
|
||||
// and similarly for strings.
|
||||
"def _nwise(a; $n): if a|length <= $n then a else a[0:$n] , _nwise(a[$n:]; $n) end;",
|
||||
"def _nwise($n): _nwise(.; $n);",
|
||||
//
|
||||
// splits/1 produces a stream; split/1 is retained for backward compatibility.
|
||||
"def splits($re; flags): . as $s"
|
||||
// # multiple occurrences of "g" are acceptable
|
||||
" | [ match($re; \"g\" + flags) | (.offset, .offset + .length) ]"
|
||||
" | [0] + . +[$s|length]"
|
||||
" | _nwise(2)"
|
||||
" | $s[.[0]:.[1] ] ;",
|
||||
"def splits($re): splits($re; null);",
|
||||
//
|
||||
// split emits an array for backward compatibility
|
||||
"def split($re; flags): [ splits($re; flags) ];",
|
||||
//
|
||||
// If s contains capture variables, then create a capture object and pipe it to s
|
||||
"def sub($re; s):"
|
||||
" . as $in"
|
||||
" | [match($re)]"
|
||||
" | if length == 0 then $in"
|
||||
" else .[0]"
|
||||
" | . as $r"
|
||||
// # create the \"capture\" object:
|
||||
" | reduce ( $r | .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair"
|
||||
" ({}; . + $pair)"
|
||||
" | $in[0:$r.offset] + s + $in[$r.offset+$r.length:]"
|
||||
" end ;",
|
||||
//
|
||||
// If s contains capture variables, then create a capture object and pipe it to s
|
||||
"def sub($re; s; flags):"
|
||||
" def subg: explode | select(. != 103) | implode;"
|
||||
// # "fla" should be flags with all occurrences of g removed; gs should be non-nil if flags has a g
|
||||
" def sub1(fla; gs):"
|
||||
" def mysub:"
|
||||
" . as $in"
|
||||
" | [match($re; fla)]"
|
||||
" | if length == 0 then $in"
|
||||
" else .[0] as $edit"
|
||||
" | ($edit | .offset + .length) as $len"
|
||||
// # create the "capture" object:
|
||||
" | reduce ( $edit | .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair"
|
||||
" ({}; . + $pair)"
|
||||
" | $in[0:$edit.offset]"
|
||||
" + s"
|
||||
" + ($in[$len:] | if gs then mysub else . end)"
|
||||
" end ;"
|
||||
" mysub ;"
|
||||
" (flags | index(\"g\")) as $gs"
|
||||
" | (flags | if $gs then subg else . end) as $fla"
|
||||
" | sub1($fla; $gs);",
|
||||
//
|
||||
"def sub($re; s): sub($re; s; \"\");",
|
||||
// repeated substitution of re (which may contain named captures)
|
||||
"def gsub($re; s; flags): sub($re; s; flags + \"g\");",
|
||||
"def gsub($re; s): sub($re; s; \"g\");",
|
||||
|
||||
//#######################################################################
|
||||
// range/3, with a `by` expression argument
|
||||
"def range($init; $upto; $by): "
|
||||
" def _range: "
|
||||
" if ($by > 0 and . < $upto) or ($by < 0 and . > $upto) then ., ((.+$by)|_range) else . end; "
|
||||
" if $by == 0 then $init else $init|_range end | select(($by > 0 and . < $upto) or ($by < 0 and . > $upto));",
|
||||
// generic iterator/generator
|
||||
"def while(cond; update): "
|
||||
" def _while: "
|
||||
" if cond then ., (update | _while) else empty end; "
|
||||
" _while;",
|
||||
"def until(cond; next): "
|
||||
" def _until: "
|
||||
" if cond then . else (next|_until) end;"
|
||||
" _until;",
|
||||
"def limit($n; exp): if $n < 0 then exp else label $out | foreach exp as $item ([$n, null]; if .[0] < 1 then break $out else [.[0] -1, $item] end; .[1]) end;",
|
||||
"def first(g): label $out | foreach g as $item ([false, null]; if .[0]==true then break $out else [true, $item] end; .[1]);",
|
||||
"def last(g): reduce g as $item (null; $item);",
|
||||
"def nth($n; g): if $n < 0 then error(\"nth doesn't support negative indices\") else last(limit($n + 1; g)) end;",
|
||||
"def first: .[0];",
|
||||
"def last: .[-1];",
|
||||
"def nth($n): .[$n];",
|
||||
"def combinations:"
|
||||
" if length == 0 then [] else"
|
||||
" .[0][] as $x"
|
||||
" | (.[1:] | combinations) as $y"
|
||||
" | [$x] + $y"
|
||||
" end;",
|
||||
"def combinations(n):"
|
||||
" . as $dot"
|
||||
" | [range(n) | $dot]"
|
||||
" | combinations;",
|
||||
// # transpose a possibly jagged matrix, quickly;
|
||||
// # rows are padded with nulls so the result is always rectangular.
|
||||
"def transpose:"
|
||||
" if . == [] then []"
|
||||
" else . as $in"
|
||||
" | (map(length) | max) as $max"
|
||||
" | length as $length"
|
||||
" | reduce range(0; $max) as $j"
|
||||
" ([]; . + [reduce range(0;$length) as $i ([]; . + [ $in[$i][$j] ] )] )"
|
||||
" end;",
|
||||
"def in(xs): . as $x | xs | has($x);",
|
||||
"def inside(xs): . as $x | xs | contains($x);",
|
||||
"def input: _input;",
|
||||
"def repeat(exp): "
|
||||
" def _repeat: "
|
||||
" exp, _repeat;"
|
||||
" _repeat;",
|
||||
"def inputs: try repeat(_input) catch if .==\"break\" then empty else .|error end;",
|
||||
// # like ruby's downcase - only characters A to Z are affected
|
||||
"def ascii_downcase:"
|
||||
" explode | map( if 65 <= . and . <= 90 then . + 32 else . end) | implode;",
|
||||
// # like ruby's upcase - only characters a to z are affected
|
||||
"def ascii_upcase:"
|
||||
" explode | map( if 97 <= . and . <= 122 then . - 32 else . end) | implode;",
|
||||
|
||||
// Streaming utilities
|
||||
"def truncate_stream(stream):"
|
||||
" . as $n | null | stream | . as $input | if (.[0]|length) > $n then setpath([0];$input[0][1:]) else empty end;",
|
||||
"def fromstream(i):"
|
||||
" foreach i as $item ("
|
||||
" [null,false,null,false];"
|
||||
" if ($item[0]|length) == 0 then [null,false,.[2],.[3]]"
|
||||
" elif ($item|length) == 1 and ($item[0]|length) < 2 then [null,false,.[0],.[1]]"
|
||||
" else . end |"
|
||||
" . as $state |"
|
||||
" if ($item|length) > 1 and ($item[0]|length) > 0 then"
|
||||
" [.[0]|setpath(($item|.[0]); ($item|.[1])), "
|
||||
" true, "
|
||||
" $state[2], "
|
||||
" $state[3]] "
|
||||
" else ."
|
||||
" end;"
|
||||
" if ($item[0]|length) == 1 and ($item|length == 1) and .[3] then .[2] else empty end,"
|
||||
" if ($item[0]|length) == 0 then $item[1] else empty end"
|
||||
" );",
|
||||
"def tostream:\n"
|
||||
" {string:true,number:true,boolean:true,null:true} as $leaf_types |\n"
|
||||
" . as $dot |\n"
|
||||
" if $leaf_types[$dot|type] or length==0 then [[],$dot]\n"
|
||||
" else\n"
|
||||
" # We really need a _streaming_ form of `keys`.\n"
|
||||
" # We can use `range` for arrays, but not for objects.\n"
|
||||
" keys as $keys |\n"
|
||||
" $keys[-1] as $last|\n"
|
||||
" ((# for each key\n"
|
||||
" $keys[] | . as $key |\n"
|
||||
" $dot[$key] | . as $dot |\n"
|
||||
" # recurse on each key/value\n"
|
||||
" tostream|.[0]|=[$key]+.),\n"
|
||||
" # then add the closing marker\n"
|
||||
" [[$last]])\n"
|
||||
" end;",
|
||||
|
||||
|
||||
// # Assuming the input array is sorted, bsearch/1 returns
|
||||
// # the index of the target if the target is in the input array; and otherwise
|
||||
// # (-1 - ix), where ix is the insertion point that would leave the array sorted.
|
||||
// # If the input is not sorted, bsearch will terminate but with irrelevant results.
|
||||
"def bsearch(target):"
|
||||
" if length == 0 then -1"
|
||||
" elif length == 1 then"
|
||||
" if target == .[0] then 0 elif target < .[0] then -1 else -2 end"
|
||||
" else . as $in"
|
||||
"" // # state variable: [start, end, answer]
|
||||
"" // # where start and end are the upper and lower offsets to use.
|
||||
" | [0, length-1, null]"
|
||||
" | until( .[0] > .[1] ;"
|
||||
" if .[2] != null then (.[1] = -1)" // # i.e. break
|
||||
" else"
|
||||
" ( ( (.[1] + .[0]) / 2 ) | floor ) as $mid"
|
||||
" | $in[$mid] as $monkey"
|
||||
" | if $monkey == target then (.[2] = $mid)" // # success
|
||||
" elif .[0] == .[1] then (.[1] = -1)" // # failure
|
||||
" elif $monkey < target then (.[0] = ($mid + 1))"
|
||||
" else (.[1] = ($mid - 1))"
|
||||
" end"
|
||||
" end )"
|
||||
" | if .[2] == null then" // # compute the insertion point
|
||||
" if $in[ .[0] ] < target then (-2 -.[0])"
|
||||
" else (-1 -.[0])"
|
||||
" end"
|
||||
" else .[2]"
|
||||
" end"
|
||||
" end;",
|
||||
};
|
||||
/* Include unsupported math functions next */
|
||||
#undef LIBM_DDDD_NO
|
||||
#undef LIBM_DDD_NO
|
||||
#undef LIBM_DD_NO
|
||||
#undef LIBM_DDDD
|
||||
#undef LIBM_DDD
|
||||
#undef LIBM_DD
|
||||
#define LIBM_DD(name)
|
||||
#define LIBM_DDD(name)
|
||||
#define LIBM_DDDD(name)
|
||||
#define LIBM_DD_NO(name) "def " #name ": \"Error: " #name "() not found at build time\"|error;"
|
||||
#define LIBM_DDD_NO(name) "def " #name "(a;b): \"Error: " #name "() not found at build time\"|error;"
|
||||
#define LIBM_DDDD_NO(name) "def " #name "(a;b;c): \"Error: " #name "() not found at build time\"|error;"
|
||||
#include "libm.h"
|
||||
;
|
||||
|
||||
#undef LIBM_DDDD_NO
|
||||
#undef LIBM_DDD_NO
|
||||
#undef LIBM_DD_NO
|
||||
#undef LIBM_DDDD
|
||||
#undef LIBM_DDD
|
||||
#undef LIBM_DD
|
||||
|
||||
@@ -1674,10 +1464,8 @@ int builtins_bind(jq_state *jq, block* bb) {
|
||||
block_free(*bb);
|
||||
return nerrors;
|
||||
}
|
||||
for (int i=(int)(sizeof(jq_builtins)/sizeof(jq_builtins[0]))-1; i>=0; i--) {
|
||||
nerrors = builtins_bind_one(jq, bb, jq_builtins[i]);
|
||||
assert(!nerrors);
|
||||
}
|
||||
nerrors = builtins_bind_one(jq, bb, jq_builtins);
|
||||
assert(!nerrors);
|
||||
*bb = bind_bytecoded_builtins(*bb);
|
||||
*bb = gen_cbinding(function_list, sizeof(function_list)/sizeof(function_list[0]), *bb);
|
||||
return nerrors;
|
||||
File renamed without changes.
+306
@@ -0,0 +1,306 @@
|
||||
def error: error(.);
|
||||
def map(f): [.[] | f];
|
||||
def select(f): if f then . else empty end;
|
||||
def sort_by(f): _sort_by_impl(map([f]));
|
||||
def group_by(f): _group_by_impl(map([f]));
|
||||
def unique: group_by(.) | map(.[0]);
|
||||
def unique_by(f): group_by(f) | map(.[0]);
|
||||
def max_by(f): _max_by_impl(map([f]));
|
||||
def min_by(f): _min_by_impl(map([f]));
|
||||
def add: reduce .[] as $x (null; . + $x);
|
||||
def del(f): delpaths([path(f)]);
|
||||
def _assign(paths; value): value as $v | reduce path(paths) as $p (.; setpath($p; $v));
|
||||
def _modify(paths; update): reduce path(paths) as $p (.; label $out | (setpath($p; getpath($p) | update) | ., break $out), delpaths([$p]));
|
||||
def map_values(f): .[] |= f;
|
||||
|
||||
# recurse
|
||||
def recurse(f): def r: ., (f | r); r;
|
||||
def recurse(f; cond): def r: ., (f | select(cond) | r); r;
|
||||
def recurse: recurse(.[]?);
|
||||
def recurse_down: recurse;
|
||||
|
||||
def to_entries: [keys_unsorted[] as $k | {key: $k, value: .[$k]}];
|
||||
def from_entries: map({(.key // .Key // .name // .Name): (if has("value") then .value else .Value end)}) | add | .//={};
|
||||
def with_entries(f): to_entries | map(f) | from_entries;
|
||||
def reverse: [.[length - 1 - range(0;length)]];
|
||||
def indices($i): if type == "array" and ($i|type) == "array" then .[$i]
|
||||
elif type == "array" then .[[$i]]
|
||||
elif type == "string" and ($i|type) == "string" then _strindices($i)
|
||||
else .[$i] end;
|
||||
def index($i): indices($i) | .[0]; # TODO: optimize
|
||||
def rindex($i): indices($i) | .[-1:][0]; # TODO: optimize
|
||||
def paths: path(recurse(if (type|. == "array" or . == "object") then .[] else empty end))|select(length > 0);
|
||||
def paths(node_filter): . as $dot|paths|select(. as $p|$dot|getpath($p)|node_filter);
|
||||
def any(generator; condition):
|
||||
[label $out | foreach generator as $i
|
||||
(false;
|
||||
if . then break $out elif $i | condition then true else . end;
|
||||
if . then . else empty end)] | length == 1;
|
||||
def any(condition): any(.[]; condition);
|
||||
def any: any(.);
|
||||
def all(generator; condition):
|
||||
[label $out | foreach generator as $i
|
||||
(true;
|
||||
if .|not then break $out elif $i | condition then . else false end;
|
||||
if .|not then . else empty end)] | length == 0;
|
||||
def all(condition): all(.[]; condition);
|
||||
def all: all(.);
|
||||
def isfinite: type == "number" and (isinfinite | not);
|
||||
def arrays: select(type == "array");
|
||||
def objects: select(type == "object");
|
||||
def iterables: arrays, objects;
|
||||
def booleans: select(type == "boolean");
|
||||
def numbers: select(type == "number");
|
||||
def normals: select(isnormal);
|
||||
def finites: select(isfinite);
|
||||
def strings: select(type == "string");
|
||||
def nulls: select(type == "null");
|
||||
def values: select(. != null);
|
||||
def scalars: select(. == null or . == true or . == false or type == "number" or type == "string");
|
||||
def scalars_or_empty: select(. == null or . == true or . == false or type == "number" or type == "string" or ((type=="array" or type=="object") and length==0));
|
||||
def leaf_paths: paths(scalars);
|
||||
def join($x): reduce .[] as $i (null;
|
||||
(if .==null then "" else .+$x end) +
|
||||
($i | if type=="boolean" or type=="number" then tostring else .//"" end)
|
||||
) // "";
|
||||
def _flatten($x): reduce .[] as $i ([]; if $i | type == "array" and $x != 0 then . + ($i | _flatten($x-1)) else . + [$i] end);
|
||||
def flatten($x): if $x < 0 then error("flatten depth must not be negative") else _flatten($x) end;
|
||||
def flatten: _flatten(-1);
|
||||
def range($x): range(0;$x);
|
||||
def fromdateiso8601: strptime("%Y-%m-%dT%H:%M:%SZ")|mktime;
|
||||
def todateiso8601: strftime("%Y-%m-%dT%H:%M:%SZ");
|
||||
def fromdate: fromdateiso8601;
|
||||
def todate: todateiso8601;
|
||||
def match(re; mode): _match_impl(re; mode; false)|.[];
|
||||
def match($val): ($val|type) as $vt | if $vt == "string" then match($val; null)
|
||||
elif $vt == "array" and ($val | length) > 1 then match($val[0]; $val[1])
|
||||
elif $vt == "array" and ($val | length) > 0 then match($val[0]; null)
|
||||
else error( $vt + " not a string or array") end;
|
||||
def test(re; mode): _match_impl(re; mode; true);
|
||||
def test($val): ($val|type) as $vt | if $vt == "string" then test($val; null)
|
||||
elif $vt == "array" and ($val | length) > 1 then test($val[0]; $val[1])
|
||||
elif $vt == "array" and ($val | length) > 0 then test($val[0]; null)
|
||||
else error( $vt + " not a string or array") end;
|
||||
def capture(re; mods): match(re; mods) | reduce ( .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair ({}; . + $pair);
|
||||
def capture($val): ($val|type) as $vt | if $vt == "string" then capture($val; null)
|
||||
elif $vt == "array" and ($val | length) > 1 then capture($val[0]; $val[1])
|
||||
elif $vt == "array" and ($val | length) > 0 then capture($val[0]; null)
|
||||
else error( $vt + " not a string or array") end;
|
||||
def scan(re):
|
||||
match(re; "g")
|
||||
| if (.captures|length > 0)
|
||||
then [ .captures | .[] | .string ]
|
||||
else .string
|
||||
end ;
|
||||
#
|
||||
# If input is an array, then emit a stream of successive subarrays of length n (or less),
|
||||
# and similarly for strings.
|
||||
def _nwise(a; $n): if a|length <= $n then a else a[0:$n] , _nwise(a[$n:]; $n) end;
|
||||
def _nwise($n): _nwise(.; $n);
|
||||
#
|
||||
# splits/1 produces a stream; split/1 is retained for backward compatibility.
|
||||
def splits($re; flags): . as $s
|
||||
# # multiple occurrences of "g" are acceptable
|
||||
| [ match($re; "g" + flags) | (.offset, .offset + .length) ]
|
||||
| [0] + . +[$s|length]
|
||||
| _nwise(2)
|
||||
| $s[.[0]:.[1] ] ;
|
||||
def splits($re): splits($re; null);
|
||||
#
|
||||
# split emits an array for backward compatibility
|
||||
def split($re; flags): [ splits($re; flags) ];
|
||||
#
|
||||
# If s contains capture variables, then create a capture object and pipe it to s
|
||||
def sub($re; s):
|
||||
. as $in
|
||||
| [match($re)]
|
||||
| if length == 0 then $in
|
||||
else .[0]
|
||||
| . as $r
|
||||
# # create the "capture" object:
|
||||
| reduce ( $r | .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair
|
||||
({}; . + $pair)
|
||||
| $in[0:$r.offset] + s + $in[$r.offset+$r.length:]
|
||||
end ;
|
||||
#
|
||||
# If s contains capture variables, then create a capture object and pipe it to s
|
||||
def sub($re; s; flags):
|
||||
def subg: [explode[] | select(. != 103)] | implode;
|
||||
# "fla" should be flags with all occurrences of g removed; gs should be non-nil if flags has a g
|
||||
def sub1(fla; gs):
|
||||
def mysub:
|
||||
. as $in
|
||||
| [match($re; fla)]
|
||||
| if length == 0 then $in
|
||||
else .[0] as $edit
|
||||
| ($edit | .offset + .length) as $len
|
||||
# create the "capture" object:
|
||||
| reduce ( $edit | .captures | .[] | select(.name != null) | { (.name) : .string } ) as $pair
|
||||
({}; . + $pair)
|
||||
| $in[0:$edit.offset]
|
||||
+ s
|
||||
+ ($in[$len:] | if length > 0 and gs then mysub else . end)
|
||||
end ;
|
||||
mysub ;
|
||||
(flags | index("g")) as $gs
|
||||
| (flags | if $gs then subg else . end) as $fla
|
||||
| sub1($fla; $gs);
|
||||
#
|
||||
def sub($re; s): sub($re; s; "");
|
||||
# repeated substitution of re (which may contain named captures)
|
||||
def gsub($re; s; flags): sub($re; s; flags + "g");
|
||||
def gsub($re; s): sub($re; s; "g");
|
||||
|
||||
########################################################################
|
||||
# range/3, with a `by` expression argument
|
||||
def range($init; $upto; $by):
|
||||
def _range:
|
||||
if ($by > 0 and . < $upto) or ($by < 0 and . > $upto) then ., ((.+$by)|_range) else . end;
|
||||
if $by == 0 then $init else $init|_range end | select(($by > 0 and . < $upto) or ($by < 0 and . > $upto));
|
||||
# generic iterator/generator
|
||||
def while(cond; update):
|
||||
def _while:
|
||||
if cond then ., (update | _while) else empty end;
|
||||
_while;
|
||||
def until(cond; next):
|
||||
def _until:
|
||||
if cond then . else (next|_until) end;
|
||||
_until;
|
||||
def limit($n; exp): if $n < 0 then exp else label $out | foreach exp as $item ([$n, null]; if .[0] < 1 then break $out else [.[0] -1, $item] end; .[1]) end;
|
||||
def first(g): label $out | g | ., break $out;
|
||||
def last(g): reduce g as $item (null; $item);
|
||||
def nth($n; g): if $n < 0 then error("nth doesn't support negative indices") else last(limit($n + 1; g)) end;
|
||||
def first: .[0];
|
||||
def last: .[-1];
|
||||
def nth($n): .[$n];
|
||||
def combinations:
|
||||
if length == 0 then [] else
|
||||
.[0][] as $x
|
||||
| (.[1:] | combinations) as $y
|
||||
| [$x] + $y
|
||||
end;
|
||||
def combinations(n):
|
||||
. as $dot
|
||||
| [range(n) | $dot]
|
||||
| combinations;
|
||||
# transpose a possibly jagged matrix, quickly;
|
||||
# rows are padded with nulls so the result is always rectangular.
|
||||
def transpose:
|
||||
if . == [] then []
|
||||
else . as $in
|
||||
| (map(length) | max) as $max
|
||||
| length as $length
|
||||
| reduce range(0; $max) as $j
|
||||
([]; . + [reduce range(0;$length) as $i ([]; . + [ $in[$i][$j] ] )] )
|
||||
end;
|
||||
def in(xs): . as $x | xs | has($x);
|
||||
def inside(xs): . as $x | xs | contains($x);
|
||||
def input: _input;
|
||||
def repeat(exp):
|
||||
def _repeat:
|
||||
exp, _repeat;
|
||||
_repeat;
|
||||
def inputs: try repeat(_input) catch if .=="break" then empty else .|error end;
|
||||
# like ruby's downcase - only characters A to Z are affected
|
||||
def ascii_downcase:
|
||||
explode | map( if 65 <= . and . <= 90 then . + 32 else . end) | implode;
|
||||
# like ruby's upcase - only characters a to z are affected
|
||||
def ascii_upcase:
|
||||
explode | map( if 97 <= . and . <= 122 then . - 32 else . end) | implode;
|
||||
|
||||
# Streaming utilities
|
||||
def truncate_stream(stream):
|
||||
. as $n | null | stream | . as $input | if (.[0]|length) > $n then setpath([0];$input[0][$n:]) else empty end;
|
||||
def fromstream(i):
|
||||
foreach i as $item (
|
||||
[null,false,null,false];
|
||||
if ($item[0]|length) == 0 then [null,false,.[2],.[3]]
|
||||
elif ($item|length) == 1 and ($item[0]|length) < 2 then [null,false,.[0],.[1]]
|
||||
else . end |
|
||||
. as $state |
|
||||
if ($item|length) > 1 and ($item[0]|length) > 0 then
|
||||
[.[0]|setpath(($item|.[0]); ($item|.[1])),
|
||||
true,
|
||||
$state[2],
|
||||
$state[3]]
|
||||
else .
|
||||
end;
|
||||
if ($item[0]|length) == 1 and ($item|length == 1) and .[3] then .[2] else empty end,
|
||||
if ($item[0]|length) == 0 then $item[1] else empty end
|
||||
);
|
||||
def tostream:
|
||||
{string:true,number:true,boolean:true,null:true} as $leaf_types |
|
||||
. as $dot |
|
||||
if $leaf_types[$dot|type] or length==0 then [[],$dot]
|
||||
else
|
||||
# We really need a _streaming_ form of `keys`.
|
||||
# We can use `range` for arrays, but not for objects.
|
||||
keys as $keys |
|
||||
$keys[-1] as $last|
|
||||
((# for each key
|
||||
$keys[] | . as $key |
|
||||
$dot[$key] | . as $dot |
|
||||
# recurse on each key/value
|
||||
tostream|.[0]|=[$key]+.),
|
||||
# then add the closing marker
|
||||
[[$last]])
|
||||
end;
|
||||
|
||||
|
||||
# Assuming the input array is sorted, bsearch/1 returns
|
||||
# the index of the target if the target is in the input array; and otherwise
|
||||
# (-1 - ix), where ix is the insertion point that would leave the array sorted.
|
||||
# If the input is not sorted, bsearch will terminate but with irrelevant results.
|
||||
def bsearch(target):
|
||||
if length == 0 then -1
|
||||
elif length == 1 then
|
||||
if target == .[0] then 0 elif target < .[0] then -1 else -2 end
|
||||
else . as $in
|
||||
# state variable: [start, end, answer]
|
||||
# where start and end are the upper and lower offsets to use.
|
||||
| [0, length-1, null]
|
||||
| until( .[0] > .[1] ;
|
||||
if .[2] != null then (.[1] = -1) # i.e. break
|
||||
else
|
||||
( ( (.[1] + .[0]) / 2 ) | floor ) as $mid
|
||||
| $in[$mid] as $monkey
|
||||
| if $monkey == target then (.[2] = $mid) # success
|
||||
elif .[0] == .[1] then (.[1] = -1) # failure
|
||||
elif $monkey < target then (.[0] = ($mid + 1))
|
||||
else (.[1] = ($mid - 1))
|
||||
end
|
||||
end )
|
||||
| if .[2] == null then # compute the insertion point
|
||||
if $in[ .[0] ] < target then (-2 -.[0])
|
||||
else (-1 -.[0])
|
||||
end
|
||||
else .[2]
|
||||
end
|
||||
end;
|
||||
|
||||
# Apply f to composite entities recursively, and to atoms
|
||||
def walk(f):
|
||||
. as $in
|
||||
| if type == "object" then
|
||||
reduce keys[] as $key
|
||||
( {}; . + { ($key): ($in[$key] | walk(f)) } ) | f
|
||||
elif type == "array" then map( walk(f) ) | f
|
||||
else f
|
||||
end;
|
||||
|
||||
# SQL-ish operators here:
|
||||
def INDEX(stream; idx_expr):
|
||||
reduce stream as $row ({};
|
||||
.[$row|idx_expr|
|
||||
if type != "string" then tojson
|
||||
else .
|
||||
end] |= $row);
|
||||
def INDEX(idx_expr): INDEX(.[]; idx_expr);
|
||||
def JOIN($idx; idx_expr):
|
||||
[.[] | [., $idx[idx_expr]]];
|
||||
def JOIN($idx; stream; idx_expr):
|
||||
stream | [., $idx[idx_expr]];
|
||||
def JOIN($idx; stream; idx_expr; join_expr):
|
||||
stream | [., $idx[idx_expr]] | join_expr;
|
||||
def IN(s): reduce (first(select(. == s)) | true) as $v (false; if . or $v then true else false end);
|
||||
def IN(src; s): reduce (src|IN(s)) as $v (false; if . or $v then true else false end);
|
||||
File renamed without changes.
File renamed without changes.
@@ -495,23 +495,26 @@ jv block_module_meta(block b) {
|
||||
return jv_null();
|
||||
}
|
||||
|
||||
block gen_import(const char* name, block metadata, const char* as, int is_data) {
|
||||
assert(metadata.first == NULL || block_is_const(metadata));
|
||||
block gen_import(const char* name, const char* as, int is_data) {
|
||||
inst* i = inst_new(DEPS);
|
||||
jv meta;
|
||||
if (block_is_const(metadata))
|
||||
meta = block_const(metadata);
|
||||
else
|
||||
meta = jv_object();
|
||||
jv meta = jv_object();
|
||||
if (as != NULL)
|
||||
meta = jv_object_set(meta, jv_string("as"), jv_string(as));
|
||||
meta = jv_object_set(meta, jv_string("is_data"), is_data ? jv_true() : jv_false());
|
||||
meta = jv_object_set(meta, jv_string("relpath"), jv_string(name));
|
||||
i->imm.constant = meta;
|
||||
block_free(metadata);
|
||||
return inst_block(i);
|
||||
}
|
||||
|
||||
block gen_import_meta(block import, block metadata) {
|
||||
assert(block_is_single(import) && import.first->op == DEPS);
|
||||
assert(block_is_const(metadata) && block_const_kind(metadata) == JV_KIND_OBJECT);
|
||||
inst *i = import.first;
|
||||
i->imm.constant = jv_object_merge(block_const(metadata), i->imm.constant);
|
||||
block_free(metadata);
|
||||
return import;
|
||||
}
|
||||
|
||||
block gen_function(const char* name, block formals, block body) {
|
||||
inst* i = inst_new(CLOSURE_CREATE);
|
||||
for (inst* i = formals.last; i; i = i->prev) {
|
||||
@@ -592,6 +595,10 @@ block gen_const_object(block expr) {
|
||||
is_const = 0;
|
||||
break;
|
||||
}
|
||||
if (jv_get_kind(k) != JV_KIND_STRING) {
|
||||
is_const = 0;
|
||||
break;
|
||||
}
|
||||
o = jv_object_set(o, k, v);
|
||||
k = jv_null();
|
||||
v = jv_null();
|
||||
@@ -697,12 +704,27 @@ static block bind_matcher(block matcher, block body) {
|
||||
|
||||
block gen_reduce(block source, block matcher, block init, block body) {
|
||||
block res_var = gen_op_var_fresh(STOREV, "reduce");
|
||||
block update_var = gen_op_bound(STOREV, res_var);
|
||||
block jmp = gen_op_target(JUMP, body);
|
||||
block loop = BLOCK(gen_op_simple(DUPN),
|
||||
source,
|
||||
bind_matcher(matcher,
|
||||
BLOCK(gen_op_bound(LOADVN, res_var),
|
||||
/*
|
||||
* We fork to the body, jump to
|
||||
* the STOREV. This means that
|
||||
* if body produces no results
|
||||
* (i.e., it just does empty)
|
||||
* then we keep the current
|
||||
* reduction state as-is.
|
||||
*
|
||||
* To break out of a
|
||||
* reduction... use break.
|
||||
*/
|
||||
gen_op_target(FORK, jmp),
|
||||
jmp,
|
||||
body,
|
||||
gen_op_bound(STOREV, res_var))),
|
||||
update_var)),
|
||||
gen_op_simple(BACKTRACK));
|
||||
return BLOCK(gen_op_simple(DUP),
|
||||
init,
|
||||
@@ -32,7 +32,8 @@ block gen_op_var_fresh(opcode op, const char* name);
|
||||
|
||||
block gen_module(block metadata);
|
||||
jv block_module_meta(block b);
|
||||
block gen_import(const char* name, block metadata, const char *as, int is_data);
|
||||
block gen_import(const char* name, const char *as, int is_data);
|
||||
block gen_import_meta(block import, block metadata);
|
||||
block gen_function(const char* name, block formals, block body);
|
||||
block gen_param_regular(const char* name);
|
||||
block gen_param(const char* name);
|
||||
File renamed without changes.
@@ -64,7 +64,7 @@ struct frame {
|
||||
stack_ptr env; // jq stack address of frame to return to
|
||||
stack_ptr retdata; // jq stack address to unwind to on RET
|
||||
uint16_t* retaddr; // jq bytecode return address
|
||||
union frame_entry entries[0]; // nclosures + nlocals
|
||||
union frame_entry entries[]; // nclosures + nlocals
|
||||
};
|
||||
|
||||
static int frame_size(struct bytecode* bc) {
|
||||
File renamed without changes.
+1
-1
@@ -2,7 +2,7 @@
|
||||
#define JQ_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <jv.h>
|
||||
#include "jv.h"
|
||||
|
||||
enum {JQ_DEBUG_TRACE = 1};
|
||||
|
||||
File renamed without changes.
@@ -157,7 +157,7 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata) {
|
||||
printf(" for test at line number %u: %s\n", lineno, prog);
|
||||
pass = 0;
|
||||
}
|
||||
jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOUR|JV_PRINT_REFCOUNT));
|
||||
jv as_string = jv_dump_string(jv_copy(expected), rand() & ~(JV_PRINT_COLOR|JV_PRINT_REFCOUNT));
|
||||
jv reparsed = jv_parse_sized(jv_string_value(as_string), jv_string_length_bytes(jv_copy(as_string)));
|
||||
assert(jv_equal(jv_copy(expected), jv_copy(reparsed)));
|
||||
jv_free(as_string);
|
||||
Loaded 100 of 140 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user