Releases: 01mf02/jaq
1.1
jaq is a jq clone with an emphasis on correctness, speed, and simplicity.
The largest change in jaq 1.1 is the support for filter arguments in recursive filters. This means that you can now write something like:
def repeat(f): f, repeat(f); repeat(1, 2)
However, unlike in jq, this specific example will currently fail with a stack overflow after a certain number of values (about 12,000 on my machine). To address this issue, tail-call optimisation is necessary, which is planned to be supported in jaq 1.2.
Furthermore, several expressions that were evaluated strictly are now evaluated lazily, in particular cartesian products and objects.
That means that some filters that would previously never yield any input, now can yield an infinite number of inputs.
The API of jaq 1.1 is fully backwards compatible with the API of jaq 1.0.
Full Changelog: v1.0.0...v1.1.0
1.0
jaq is a jq clone with an emphasis on correctness, speed, and simplicity.
jaq 1.0 brings lots of features compared to the last stable release (0.10).
A short summary with examples:
- Recursive/nested function definitions:
def walk(f): def rec: (.[]? |= rec) | f; rec;
- Variable arguments:
def foo($v; f): ...
- String interpolation:
@uri "https://www.google.com/search?q=\(.search)"
- if-then expressions without else branch:
if . < 0 then - . end
- try-catch expressions:
try . * 10 catch "NaN"
- Many, many new filters
- Native filter API: allows you to create custom versions of jaq where you can supply your own filters written in Rust
- Automatically built binaries
For more details on these changes, see the alpha, beta, and gamma release information.
Given that this is an 1.0 release, I will try to maintain a stable API.
Among others, future improvements that should be possible within the current API include optimisation of tail recursive calls (for better recursion performance) as well as parallel execution.
Thanks again to all contributors since the last stable release!
Full Changelog: v1.0.0-gamma...v1.0.0
1.0 gamma
This release brings support for string interpolation, including custom formatters (thanks to @kklingenberg). That means that you can now write something like @uri "https://www.google.com/search?q=\(.search)"
and have it interpreted like in jq.
Furthermore, like in the upcoming jq 1.7, else
branches in if-then-else expressions can now be omitted.
This version is planned to be the last one before 1.0. No new features are supposed to be integrated into 1.0, only bug fixes.
From this release on, binaries are automatically built. It would be great if someone with an Apple system could test it on their machine.
Smaller changes
Full Changelog: v1.0.0-beta...v1.0.0-gamma
1.0 beta
This release includes a large number of new filters, mostly for:
- strings (@baod-rate, #84, #82),
- arrays (@kklingenberg #74),
- dates (@baod-rate, #85), and
- math (@kklingenberg, #96).
Furthermore, it adds support for the try f catch g
syntax (@kklingenberg, #100), and strings can now be multiplied with integers to repeat them (@nouritsu, #86).
The CLI supports the option --nul-output
(@baod-rate, #91) and matches jq’s exit code with --exit-status
when there is no output (@baod-rate, #92).
Under the hood, the API has changed considerably in order to accommodate for the changes implied by native filters. Most notably, the jaq-interpret crate (containing the interpreter, i.e. the heart of jaq) was split off from jaq-core, and the jaq-syn crate (containing only data types for the syntax) was split off from jaq-parse.
Thanks again to @baod-rate and @kklingenberg for their tremendous efforts!
New Contributors
- @baod-rate made their first contribution in #80
- @nouritsu made their first contribution in #86
- @kklingenberg made their first contribution in #74
Full Changelog: v1.0.0-alpha...v1.0.0-beta
0.10.1
This release fixes a critical bug that can occur when binding multiple variables. Furthermore, it uses a newer version of the regex crate to allow for a simpler installation.
Full Changelog: v0.10.0...v0.10.1
1.0 alpha
This release adds a lot of new features to jaq:
- Recursive & nested functions: see the README for restrictions of recursive functions
- Variable arguments:
def foo($v; f): ...
- Variables bound via command-line arguments (
--arg
) can be referred to from definitions now - New filters:
walk(f)
,group_by(f)
,unique
,unique_by(f)
,paths
- Tests (
--run-tests
)
Thanks are due especially to @passcod for having implemented native filters. Users that use jaq as part of their own programs via the API can now implement filters as Rust functions and expose them to jaq. The API is still subject to change, see #70.
Given the extent of these new features, I think that the time is ripe for a 1.0 release.
However, this is an alpha release because especially recursive/nested functions have not yet received the amount of testing that I would expect from a 1.0 release.
As I will be going this week on a cycling trip that will last about two months, I will not be available during this time to address issues myself. However, it is my hope that this time allows users to test the new functions and to report issues (and in the optimal case submit PRs to fix the problems), in order to allow for a more polished 1.0 release later.
New Contributors
- @Shirtpantswallet made their first contribution in #65
- @passcod made their first contribution in #70
Full Changelog: v0.10.0...v1.0.0-alpha
0.10.0
jaq is a jq clone with a focus on correctness, speed, and simplicity.
jaq 0.10.0 improves JSON parsing speed, supports regular expression filters and walk(f)
, and improves compatibility of foreach
syntax and arguments handling.
Details:
- JSON parsing: This release parses JSON using the new hifijson crate instead of serde_json.
This increases JSON parsing performance, in one benchmark by up to 87% compared to jaq 0.9.0 and by 68% compared to jq. - Regular expressions: The filters
test
,scan
,match
,capture
,splits
,sub
,gsub
are now supported.
Note that for named capture groups, the syntax(?<name>exp)
is not supported when installing jaq bycargo install jaq
;
however, it is supported when installing jaq usingcargo build
,cargo install --path jaq
orcargo install --git https://github.com/01mf02/jaq
.
This is because the underlying crate for parsing regular expressions,regex-syntax
, does not support the(?<name>exp)
syntax at the time of writing, so jaq currently uses a patched version of this crate, which is however not considered bycargo install jaq
. In the future, the(?<name>exp)
syntax is likely to be included inregex-syntax
, which will make the(?<name>exp)
syntax available also when installing jaq viacargo install jaq
. foreach
,for
: In jq 0.9, the semantics offoreach xs as $x (init; f)
were changed such that it yielded the output ofinit
, unlike jq. Following some discussion, the suggestion by @pkoppstein was implemented that restored the previous semantics offoreach
, while introducing a new filterfor xs as $x (init; f)
that yields the output ofinit
. More information can be found in the README.- Arguments handling: The
--slurpfile
and--rawfile
options are now supported. Furthermore, arguments (such as passed by--arg a b
) are now bound to$ARGS
.
New Contributors
Full Changelog: v0.9.0...v0.10.0
0.9.0
This release greatly improves performance of file reading by memory mapping. On one benchmark, for example, this change decreased runtime by about 27%. Pass input files as arguments to profit from this; i.e., use jaq 'filter' file.json
instead of jaq 'filter' <file.json
.
Several filters now behave more like in jq, for example assignment (=
) and arithmetic update-assignment (+=
, -=
, ...).
Updates using f as $x | g
or if f then g else h
on the left-hand side are now evaluated correctly if f
yields multiple values.
recurse
, reduce
, and foreach
are now evaluated more lazily.
BREAKING CHANGE: foreach xs as $x(init; f)
does now also output the outputs of init
, and the syntax foreach xs as $x(init; f; proj)
is not supported anymore. This makes the behaviour of foreach
easier to describe and reason about, greatly simplifies the implementation and makes foreach
behave more like reduce
. See the README for details.
Users of jaq-core
(the library powering jaq
) might be happy to know that Filter
s are now Send
and Sync
. That means that it is now possible to execute a filter on multiple threads, processing multiple values in parallel. The jaq
application itself does not make use of this (yet).
Full Changelog: v0.8.2...v0.9.0
0.8.2
This release adds the --raw-input
/ -R
command-line option to jaq.
This is particularly useful to try the newly included Brainfuck interpreter (based on @itchyny's work) in examples/bf.jq
. :)
Under the hood, jaq tries to avoid more clones when destructuring or updating arrays or objects.
For example, this makes [range(1000000) | [.] | .[]] | length
about 6% faster.
Furthermore, expressions such as f[]
, which consist of some filter directly followed by a path, are now evaluated differently.
In particular, f
is now evaluated lazily, whereas before, it was evaluated strictly.
This makes it possible to write a Fibonacci sequence generator as
[0,1] | recurse([.[1], add])[0]
which previously would not have terminated.
Full Changelog: v0.8.1...v0.8.2
0.8.1
The main feature of this release is greatly improved parsing speed (012c9c5).
Apart from this, there are three new filters suggested by @pkoppstein, namely debug
, finites
, and normals
.
Furthermore, the performance of join
has increased vastly.
Last but not least, the command-line interface has been updated to use Clap 4.
Full Changelog: v0.8.0...v0.8.1