- text: |
- For the rest of the examples, I'll leave out the `curl` command—it's not going to change.
+ 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.
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
+ Data in jq is represented as streams of JSON values - every jq
expression runs for each value in its input stream, and can
produce any number of values to its output stream.
Streams are serialised by just separating JSON values with
- whitespace. This is a `cat`-friendly format—you can just join
+ whitespace. This is a `cat`-friendly format - you can just join
two JSON streams together and get a valid JSON stream.
If you want to get the output as a single array, you can tell jq to
* jq 1.4 is [in Debian](http://packages.debian.org/jq)
+ * jq 1.3.2 is in the official Fedora repository. You can install using
+ `sudo yum install jq`.
+
### OS X
* `brew install jq` using [homebrew](http://mxcl.github.com/homebrew/)
* Or, grab prebuilt jq 1.3 [64-bit binaries](osx64/jq-1.3/jq) or [32-bit
binaries](osx32/jq-1.3/jq)
- ### Solaris 11
+ ### Solaris
+
+ * `pkgutil -i jq` in [OpenCSW](http://www.opencsw.org/p/jq) for Solaris 10+, Sparc and x86
- * jq 1.4 executables for [64-bit](solaris11-64/jq) or [32-bit](solaris11-32/jq)
+ * jq 1.4 executables for Solaris 11 [64-bit](solaris11-64/jq) or [32-bit](solaris11-32/jq)
### Windows
+ * `chocolatey install jq` using [Chocolatey NuGet](https://chocolatey.org/)
+
* jq 1.4 executables for [64-bit](win64/jq.exe) or [32-bit](win32/jq.exe)
+
* jq 1.3 executables for [64-bit](win64/jq-1.3/jq.exe) or [32-bit](win32/jq-1.3/jq.exe)
### From source on Linux, OS X, Cygwin, and other POSIX-like operating systems
- * [Source tarball for jq $JQ_VERSION](source/jq-$JQ_VERSION.tar.gz)
+ * [Source tarball for jq 1.4](source/jq-1.4.tar.gz)
You can build it using the usual `./configure && make && sudo
make install` rigmarole.
input: '[]'
output: ["true"]
- - title: "`flatten`, `flatten(depth)`"
+ - title: "\\[Requires 1.5\\] `flatten`, `flatten(depth)`"
body: |
The filter `flatten` takes as input an array of nested arrays,
evaluates to: true, true, false, false.
entries:
- - title: "`test(val)`, `test(regex; flags)`"
+ - title: "\\[Requires 1.5\\] `test(val)`, `test(regex; flags)`"
body: |
Like `match`, but does not return match objects, only `true` or `false`
input: '["xabcd", "ABC"]'
output: ['true', 'true']
- - title: "`match(val)`, `match(regex; flags)`"
+ - title: "\\[Requires 1.5\\] `match(val)`, `match(regex; flags)`"
body: |
**match** outputs an object for each match it finds. Matches have
output: [3]
- - title: "`capture(val)`, `capture(regex; flags)`"
+ - title: "\\[Requires 1.5\\] `capture(val)`, `capture(regex; flags)`"
body: |
Collects the named captures in a JSON object, with the name
input: '"xyzzy-14"'
output: ['{ "a": "xyzzy", "n": "14" }']
- - title: "`scan(regex)`, `scan(regex; flags)`"
+ - title: "\\[Requires 1.5\\] `scan(regex)`, `scan(regex; flags)`"
body: |
Emit a stream of the non-overlapping substrings of the input
output: ['"ab","cd","ef"']
- - title: "`splits(regex)`, `splits(regex; flags)`"
+ - title: "\\[Requires 1.5\\] `splits(regex)`, `splits(regex; flags)`"
body: |
These provide the same results as their `split` counterparts,
input: '("ab,cd", "ef, gh")'
output: ['"ab"', '"cd"', '"ef"', '"gh"']
- - title: "`sub(regex; tostring)` `sub(regex; string; flags)`"
+ - title: "\\[Requires 1.5\\] `sub(regex; tostring)` `sub(regex; string; flags)`"
body: |
Emit the string obtained by replacing the first match of regex in the
output: '"ZabcZabc"'
- - title: "`gsub(regex; string)`, `gsub(regex; string; flags)`"
+ - title: "\\[Requires 1.5\\] `gsub(regex; string)`, `gsub(regex; string; flags)`"
body: |
`gsub` is like `sub` but all the non-overlapping occurrences of the regex are
headline: jq
blurb: |
-
- jq is a lightweight and flexible command-line JSON processor with
- support for regular expressions.
-
+
+ jq is a lightweight and flexible command-line JSON processor.
+
body1: |
jq is like `sed` for JSON data - you can use it to slice and filter
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.
-
+
tail: |
+
Go read the [tutorial](tutorial/) for more, or the [manual](manual/)
- for *way* more.
+ 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
+ [Freenode](https://webchat.freenode.net/).
news:
+ - date: 2015-01-01
+ body: |
+
+ jq 1.5rc1 Get it on the
+ [releases](https://github.com/stedolan/jq/releases) page.
+
- date: 2014-06-08
body: |
-
+
jq 1.4 (finally) released! Get it on the [download](download/) page.
- date: 2013-05-19
body: |
-
+
jq 1.3 released.
<div class="btn-group" style="float:right">
<a class="btn btn-primary" href="http://jqplay.org">
- Try online!
+ Try online at jqplay.org!
</a>
</div>
}
});
});
+ // 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>
<input type="text"
class="input-medium search-query"