Releases: 01mf02/jaq
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
0.8.0
What's Changed
The largest addition in this release is support for complex assignments: Previously, the left-hand side of assignments in jaq were restricted to simple path expressions, such as .[]
, .a
. Now, jaq also supports assignments with more general left-hand sides, such as if .. then .. else .. end
, recurse(..)
and several others. This enables filters such as (.posts[] | select(.author == "stedolan") | .comments) |= . + ["terrible."]
(taken from the jq manual --- I do not have such strong feelings towards Stephen Dolan's posts ^^).
This release also adds support for several new filters:
inputs
,input
: These filters make it now possible to process input lazily with state. This effectively makes jaq an impure programming language --- but impurity is restricted to modifying the stream of input values.foreach xs as $x (init; update)
: This is a powerful tool, in particular in conjunction withinputs
. For example,foreach inputs as $x (null; .+$x)
builds a cumulative sum of the input elements, lazily...
: shorthand forrecurse(.[]?)
while
,until
: thanks to @capezotte
Smaller changes include:
- Configurable color usage via
--color
- Escaped characters in strings: It is now possible to write something like
"\""
. - Increased compatibility with jq: thanks to @itchyny for finding several places where jq and jaq diverged
- Homebrew installation, thanks to @chenrui333
Full Changelog: v0.7.0...v0.8.0
0.7.0
What's Changed
This version adds a bunch of new command-line options:
-c
/--compact
: output JSON compactly (thanks to @alex-ozdemir!)-i
/--in-place
: replace input files by their output--arg
: set contents of variables from the command-line- JSON input files can be passed as arguments
Furthermore, the try operator (?
) is now supported. In a nutshell, f?
yields those values for which f
does not return an error.
New Contributors
- @sanpii made their first contribution in #8
- @alex-ozdemir made their first contribution in #9
Full Changelog: v0.6.0...v0.7.0