diff --git a/css/base.scss~ b/css/base.scss~
deleted file mode 100644
index f3f3717e..00000000
--- a/css/base.scss~
+++ /dev/null
@@ -1,95 +0,0 @@
-@charset "utf-8";
-
-/* HTML resets */
-body, html, div, p, img, h1, h2, h3, h4, h5, h6, ol, ul, li { margin: 0; padding: 0; font-weight: normal; font-size: 100%; outline: none; border: none;}
-
-/* HTML5 block elements */
-header, section, article, footer, aside, nav { display: block; }
-
-/* Put your styles below here */
-#wrapper { margin: 0 auto; width: 660px; }
-
-body { font-family: "Helvetica Neue", Helvetica, Arial, Geneva, sans-serif; }
-
-header {
- margin-top: 5em;
-
- #logo {
- width: 145px;
- height: 145px;
- margin: 0 auto;
- -moz-border-radius: 72px;
- -webkit-border-radius: 72px;
- background-color: black;
-
- a {
- position: absolute;
- margin: 1em 0 0em 1.5em;
- color: white;
- text-align: center;
- text-transform: lowercase;
- text-decoration: none;
- font-weight: 100;
- }
-
- }
-
- #navigation {
- margin: 5em 0;
- text-transform: lowercase;
- text-align: center;
- font-style: italic;
- font-size: 0.8em;
- li:not(:last-child):after { content: " /"; }
-
- a { color: black; text-decoration: none; }
- a:hover { text-decoration: underline; }
-
- }
-}
-
-
-nav li { display: inline; list-style-type: none; }
-
-#breadcrumbs, footer { color: gray; font-size: 0.7em; }
-
-#breadcrumbs {
- li:not(:last-child):after { content: " ➔";}
- border-top: 1px solid lightgray;
- padding-top:5px;
- a { color: inherit; }
-}
-
-#sub-navigation{
- font-size: 0.8em;
- li { display: block; margin-bottom: 5px; }
-}
-
-nav, footer { margin: 1em 0; }
-
-/* Typesetting */
-h1, h2, h3, h4, h5, h6 { margin: 1.25em 0; }
-
-h1 { font-size: 2em; }
-h2 { font-size: 1.6em; }
-h3 { font-size: 1.4em; }
-h4 { font-size: 1.2em; }
-h5 { font-size: 1em; }
-h6 { font-size: 0.9em; }
-
-a { color: #256ec4; }
-p { font-size: 0.8em; line-height: 140%; margin-bottom: 10px; color: #333;}
-
-/* Floating the Magic template */
-.magic article {
- width: 450px;
- float: left;
- border-right: 1px solid lightgray;
- margin-right: 14px;
- padding-right: 15px;
-}
-.magic aside {
- width: 180px;
- float: left
-}
-.clear{ clear: both; }
\ No newline at end of file
diff --git a/download/index.html b/download/index.html
index f488da7c..a24a4790 100644
--- a/download/index.html
+++ b/download/index.html
@@ -53,25 +53,51 @@
Download jq
- jq is written in C and has no runtime dependencies, so it should be possible to build it for nearly any platform. Prebuilt binaries are available for Linux (64-bit x86) and OS X.
+ jq is written in C and has no runtime dependencies, so it should be possible to build it for nearly any platform. Prebuilt binaries are available for Linux, OS X and Windows.
-
-
-The binaries should just run, but you may need to make them executable first using:
-
-chmod +x jq
+The binaries should just run, but on OS X and Linux you may need to make them executable first using chmod +x jq.
jq is licensed under the MIT license. For all of the gory details, read the file COPYING in the source distribution.
-Hacking on jq
+Linux
-If you want to work on jq, grab the source from https://github.com/stedolan/jq .
+
+
+Binaries for 64-bit or 32-bit systems.
+
+
+
+For Arch users, a PKGBUILD for jq-1.1 is in the AUR , as well as a PKGBUILD for the HEAD of master (jq-git ). You can install them using Yaourt or manually by following instructions on Arch Linux’s Wiki .
+
+
+
+Debian/Ubuntu packages are coming Real Soon Now.
+
+
+
+OS X
+
+
+
+Windows
+
+
+
+From source on Linux or OS X
+
+git clone https://github.com/stedolan/jq.git
+cd jq
+make && sudo make install
To build it from a git clone, you’ll need to install a few packages first:
@@ -87,13 +113,13 @@
Make
-Most of these aren’t necessary if you’re just trying to compile jq from the released tarball - that version has the non-platform-specific build steps already done, so you’ll only need a C compiler and make to finish it off.
+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.
-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. I have no idea how to get these installed on OS X, you’re on your own there.
+On OS X, these are all included in Apple’s command line tools, which can be installed from 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 or MacPorts .
flex and bison are used to generate the lexer and parser for jq, and some python scripts generate the UTF8 encoding tables needed for JSON parsing.
-Building the documentation
+Building the documentation
jq’s documentation is compiled into static HTML using Bonsai . To view the documentation locally, run rake serve from the docs/ subdirectory.
diff --git a/download/linux32/jq b/download/linux32/jq
new file mode 100755
index 00000000..59a0cf00
Binary files /dev/null and b/download/linux32/jq differ
diff --git a/download/linux32/jq_test b/download/linux32/jq_test
new file mode 100755
index 00000000..21fea168
Binary files /dev/null and b/download/linux32/jq_test differ
diff --git a/download/linux64/jq b/download/linux64/jq
new file mode 100755
index 00000000..dd3b458d
Binary files /dev/null and b/download/linux64/jq differ
diff --git a/download/linux64/jq_test b/download/linux64/jq_test
new file mode 100755
index 00000000..b8da9209
Binary files /dev/null and b/download/linux64/jq_test differ
diff --git a/download/linux_x86_64/jq b/download/linux_x86_64/jq
deleted file mode 100755
index 4395acc1..00000000
Binary files a/download/linux_x86_64/jq and /dev/null differ
diff --git a/download/osx32/jq b/download/osx32/jq
new file mode 100755
index 00000000..397b20ff
Binary files /dev/null and b/download/osx32/jq differ
diff --git a/download/osx32/jq_test b/download/osx32/jq_test
new file mode 100755
index 00000000..42d253f6
Binary files /dev/null and b/download/osx32/jq_test differ
diff --git a/download/osx64/jq b/download/osx64/jq
new file mode 100755
index 00000000..dde95d45
Binary files /dev/null and b/download/osx64/jq differ
diff --git a/download/osx64/jq_test b/download/osx64/jq_test
new file mode 100755
index 00000000..0e91e1db
Binary files /dev/null and b/download/osx64/jq_test differ
diff --git a/download/osx_64/jq b/download/osx_64/jq
deleted file mode 100755
index c7b521ec..00000000
Binary files a/download/osx_64/jq and /dev/null differ
diff --git a/download/source/jq.tgz b/download/source/jq.tgz
deleted file mode 100644
index 7238a14e..00000000
Binary files a/download/source/jq.tgz and /dev/null differ
diff --git a/download/win32/jq b/download/win32/jq
new file mode 100755
index 00000000..fa0c3d12
Binary files /dev/null and b/download/win32/jq differ
diff --git a/download/win32/jq_test b/download/win32/jq_test
new file mode 100755
index 00000000..93126854
Binary files /dev/null and b/download/win32/jq_test differ
diff --git a/download/win64/jq b/download/win64/jq
new file mode 100755
index 00000000..39175d16
Binary files /dev/null and b/download/win64/jq differ
diff --git a/download/win64/jq_test b/download/win64/jq_test
new file mode 100755
index 00000000..eae2267e
Binary files /dev/null and b/download/win64/jq_test differ
diff --git a/index.html b/index.html
index 60acff43..900d058a 100644
--- a/index.html
+++ b/index.html
@@ -55,12 +55,12 @@
jq is a lightweight and flexible command-line JSON processor.
@@ -71,12 +71,19 @@
-
jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text.
-
jq is written in portable C, and it has zero runtime dependencies. You can download a single binary, scp it to a far away machine, and expect it to work.
-
jq can mangle the data format that you have into the one that you want with very little effort, and the program to do so is often shorter and simpler than you’d expect.
+
jq is like sed for JSON data – you can use it to slice and filter
+and map and transform structured data with the same ease that sed,
+awk, grep and friends let you play with text.
+
jq is written in portable C, and it has zero runtime
+dependencies. You can download a single binary, scp it to a far away
+machine, and expect it to work.
+
jq can mangle the data format that you have into the one that you
+want with very little effort, and the program to do so is often
+shorter and simpler than you’d expect.
diff --git a/index/index.html b/index/index.html
index 60acff43..900d058a 100644
--- a/index/index.html
+++ b/index/index.html
@@ -55,12 +55,12 @@
jq is a lightweight and flexible command-line JSON processor.
@@ -71,12 +71,19 @@
-
jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text.
-
jq is written in portable C, and it has zero runtime dependencies. You can download a single binary, scp it to a far away machine, and expect it to work.
-
jq can mangle the data format that you have into the one that you want with very little effort, and the program to do so is often shorter and simpler than you’d expect.
+
jq is like sed for JSON data – you can use it to slice and filter
+and map and transform structured data with the same ease that sed,
+awk, grep and friends let you play with text.
+
jq is written in portable C, and it has zero runtime
+dependencies. You can download a single binary, scp it to a far away
+machine, and expect it to work.
+
jq can mangle the data format that you have into the one that you
+want with very little effort, and the program to do so is often
+shorter and simpler than you’d expect.
diff --git a/manual/index.html b/manual/index.html
index 9ee2c224..3da7769b 100644
--- a/manual/index.html
+++ b/manual/index.html
@@ -137,6 +137,16 @@
"`tostring`" : "tostring",
+ "`sort, sort_by`" : "sortsort_by",
+
+ "`group_by`" : "group_by",
+
+ "`min`, `max`, `min_by`, `max_by`" : "minmaxmin_bymax_by",
+
+ "`unique`" : "unique",
+
+ "`contains`" : "contains",
+
"String interpolation - `\\(foo)`" : "Stringinterpolationfoo",
"Builtin operators and functions" : "Builtinoperatorsandfunctions"
@@ -147,6 +157,8 @@
"if-then-else" : "ifthenelse",
+ "`>, >=, <=, <`" : "",
+
"and/or/not" : "andornot",
"Alternative operator - `//`" : "Alternativeoperator",
@@ -195,7 +207,23 @@
jq Manual
-
A jq program is a “filter”: it takes an input, and produces an output. There are a lot of builtin filters for extracting a particular field of an object, or converting a number to a string, or various other standard tasks.
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 array. Generally, things that would be done with loops and iteration in other languages are just done by gluing filters together in jq.
It’s important to remember that every filter has an input and an output. Even literals like “hello” or 42 are filters - they take an input but always produce the same literal as output. Operations that combine two filters, like addition, generally feed the same input to both and combine the results. So, you can implement an averaging filter as add / length - feeding the input array both to the add filter and the length filter and dividing the results.
But that’s getting ahead of ourselves. :) Let’s start with something simpler:
+
A jq program is a “filter”: it takes an input, and produces an
+output. There are a lot of builtin filters for extracting a
+particular field of an object, or converting a number to a string,
+or various other standard tasks.
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
+array. Generally, things that would be done with loops and iteration
+in other languages are just done by gluing filters together in jq.
It’s important to remember that every filter has an input and an
+output. Even literals like “hello” or 42 are filters – they take an
+input but always produce the same literal as output. Operations that
+combine two filters, like addition, generally feed the same input to
+both and combine the results. So, you can implement an averaging
+filter as add / length – feeding the input array both to the add
+filter and the length filter and dividing the results.
But that’s getting ahead of ourselves. :) Let’s start with something
+simpler:
Invoking jq
@@ -203,43 +231,51 @@
You can affect how jq reads and writes its input and output using some command-line options:
-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
+* --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.
-
+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
+* --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.
-
+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
+* --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.
-
+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.
-
---ascii-output / -a
+* --colour-output / -C and --monochrome-output / -M:
-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.
-
+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`.
-
---raw-output / -r
+* --ascii-output / -a:
-With this option, if the filter’s result is a string then it will be written directly to standard output rather than being formatted as a JSON string with quotes. This can be useful for making jq filters talk to non-JSON-based systems.
-
-
+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
+making jq filters talk to non-JSON-based systems.
@@ -409,7 +445,7 @@
jq '.[]'
- Input [{name":"JSON", "good":true}, {"name":"XML", "good":false}]
+ Input [{"name":"JSON", "good":true}, {"name":"XML", "good":false}]
@@ -524,7 +560,7 @@
Output
- "d"
+ "e"
@@ -563,7 +599,7 @@
jq '.[] | .name'
- Input [{name":"JSON", "good":true}, {"name":"XML", "good":false}]
+ Input [{"name":"JSON", "good":true}, {"name":"XML", "good":false}]
@@ -772,17 +808,12 @@
jq '.a + 1'
Input {"a": 7}
-
- Output
- none
-
-
Output
- {"a": 8}
+ 8
@@ -997,12 +1028,14 @@
The keys are sorted “alphabetically”, by unicode codepoint order. This is not an order that makes particular sense in any particular language, but you can count on it being the same for any two objects with the same set of keys, regardless of locale settings.
+When keys is given an array, it returns the valid indices for that array: the integers from 0 to length-1.
+
+
+ jq 'keys'
+ Input [42,3,35]
+
+
+
+
+ Output
+
+ [0,1,2]
+
+
+
+
+
@@ -1034,7 +1082,7 @@
The function select(foo) produces its input unchanged if foo returns true for that input, and produces no output otherwise.
-It’s useful for filtering lists: [1,2,3] | select(. >= 2) will give you [3].
+It’s useful for filtering lists: [1,2,3] | map(select(. >= 2)) will give you [3].
@@ -1047,7 +1095,7 @@
- jq 'select(. >= 2)'
+ jq 'map(select(. >= 2))'
Input [1,5,3,0,7]
@@ -1094,7 +1142,14 @@
Output
- 12
+ 1
+
+
+
+
+
+
+ 2
@@ -1187,7 +1242,7 @@
Output
- abc
+ "abc"
@@ -1254,7 +1309,14 @@
Output
- 11
+ 1
+
+
+
+
+
+
+ 1
@@ -1316,6 +1378,303 @@
+
+
+ sort, sort_by
+
+
+ The sort functions sorts its input, which must be an array. Values are sorted in the following order:
+
+
+null
+
+false
+
+true
+
+numbers
+
+strings, in alphabetical order (by unicode codepoint value)
+
+arrays, in lexical order
+
+objects
+
+
+The ordering for objects is a little complex: first they’re compared by comparing their sets of keys (as arrays in sorted order), and if their keys are equal then the values are compared key by key.
+
+sort_by may be used to sort by a particular field of an object, or by applying any jq filter. sort_by(foo) compares two elements by comparing the result of foo on each element.
+
+
+
+
+
+
+ Examples
+
+
+
+
+
+ jq 'sort'
+ Input [8,3,null,6]
+
+
+
+
+ Output
+
+ [null,3,6,8]
+
+
+
+
+
+
+ jq 'sort_by(.foo)'
+ Input [{"foo":4, "bar":10}, {"foo":3, "bar":100}, {"foo":2, "bar":1}]
+
+
+
+
+ Output
+
+ [{"foo":2, "bar":1}, {"foo":3, "bar":100}, {"foo":4, "bar":10}]
+
+
+
+
+
+
+
+
+
+
+
+
+ group_by
+
+
+ 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 array, sorted by the value of the .foo field.
+
+Any jq expression, not just a field access, may be used in place of .foo. The sorting order is the same as described in the sort function above.
+
+
+
+
+
+
+ Example
+
+
+
+
+
+ jq 'group_by(.foo)'
+ Input [{"foo":1, "bar":10}, {"foo":3, "bar":100}, {"foo":1, "bar":1}]
+
+
+
+
+ Output
+
+ [[{"foo":1, "bar":10}, {"foo":1, "bar":1}], [{"foo":3, "bar":100}]]
+
+
+
+
+
+
+
+
+
+
+
+
+ min, max, min_by, max_by
+
+
+ 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 with the smallest foo field.
+
+
+
+
+
+
+ Examples
+
+
+
+
+
+ jq 'min'
+ Input [5,4,2,7]
+
+
+
+
+ Output
+
+ 2
+
+
+
+
+
+
+ jq 'max_by(.foo)'
+ Input [{"foo":1, "bar":14}, {"foo":2, "bar":3}]
+
+
+
+
+ Output
+
+ {"foo":2, "bar":3}
+
+
+
+
+
+
+
+
+
+
+
+
+ unique
+
+
+ The unique function takes as input an array and produces an array of the same elements, in sorted order, with duplicates removed.
+
+
+
+
+
+
+ Example
+
+
+
+
+
+ jq 'unique'
+ Input [1,2,5,3,5,3,1,3]
+
+
+
+
+ Output
+
+ [1,2,3,5]
+
+
+
+
+
+
+
+
+
+
+
+
+ contains
+
+
+ The filter contains(b) will produce true if b is completely contained within the input. A string B is contained in a string A if B is a substring of A. An array B is contained in an array A is all elements in B are contained in any element in A. An object B is contained in object A if all of the values in B are contained in the value in A with the same key. All other types are assumed to be contained in each other if they are equal.
+
+
+
+
+
+
+ Examples
+
+
+
+
+
+ jq 'contains("bar")'
+ Input "foobar"
+
+
+
+
+ Output
+
+ true
+
+
+
+
+
+
+ jq 'contains(["baz", "bar"])'
+ Input ["foobar", "foobaz", "blarp"]
+
+
+
+
+ Output
+
+ true
+
+
+
+
+
+
+ jq 'contains(["bazzzzz", "bar"])'
+ Input ["foobar", "foobaz", "blarp"]
+
+
+
+
+ Output
+
+ false
+
+
+
+
+
+
+ jq 'contains({foo: 12, bar: [{barp: 12}]})'
+ Input {"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]}
+
+
+
+
+ Output
+
+ true
+
+
+
+
+
+
+ jq 'contains({foo: 12, bar: [{barp: 15}]})'
+ Input {"foo": 12, "bar":[1,2,{"barp":12, "blip":13}]}
+
+
+
+
+ Output
+
+ false
+
+
+
+
+
+
+
+
+
+
String interpolation - \(foo)
@@ -1326,11 +1685,11 @@
-
+
Example
-
+
@@ -1371,11 +1730,11 @@
-
+
Example
-
+
@@ -1387,7 +1746,28 @@
Output
- [true, true, false, false]
+ true
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+ false
@@ -1414,11 +1794,11 @@
-
+
Example
-
+
@@ -1447,6 +1827,45 @@ end'
+
+
+ >, >=, <=, <
+
+
+ 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 (respectively).
+
+The ordering is the same as that described for sort, above.
+
+
+
+
+
+
+ Example
+
+
+
+
+
+ jq '. < 5'
+ Input 2
+
+
+
+
+ Output
+
+ true
+
+
+
+
+
+
+
+
+
+
and/or/not
@@ -1464,11 +1883,11 @@ not.
-
+
Examples
-
+
@@ -1576,11 +1995,11 @@ not.
-
+
Examples
-
+
@@ -1674,11 +2093,11 @@ not.
-
+
Example
-
+
@@ -1725,15 +2144,15 @@ not.
-
+
Examples
-
+
- jq 'def addvalue(f): map(. + [$value]); addvalue(.[0])'
+ jq 'def addvalue(f): . + [f]; map(addvalue(.[0]))'
Input [[1,2],[10,20]]
@@ -1748,7 +2167,7 @@ not.
- jq 'def addvalue(f): f as $x | map (. + $x); addvalue(.[0])'
+ jq 'def addvalue(f): f as $x | map(. + $x); addvalue(.[0])'
Input [[1,2],[10,20]]
@@ -1756,7 +2175,7 @@ not.
Output
- [[1,2,[1,2]], [10,20,[1,2]]]
+ [[1,2,1,2], [10,20,1,2]]
@@ -1819,11 +2238,11 @@ not.
-
+
Example
-
+
@@ -1869,7 +2288,8 @@ not.
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."]
+(.posts[] | select(.author == "stedolan") | .comments) |=
+ . + ["terrible."]