1.5 release candidate 1
Pre-releaseSalient new features since 1.4:
-
regexp support (using Oniguruma)
-
an online streaming parser
Included is the ability to control reading of inputs from the jq
program, using the newinput
andinputs
builtins.Finally we can write:
jq -n 'reduce inputs as $i ( ... )' # reduce online!
to reduce inputs without slurping them first. This works with
streaming too. -
try/catch, for catching and handling errors (this makes for a dynamic non-local exit system)
-
a lexical non-local exit system
Using try/catch to break out of control structures was not a good
thing. A lexical mechanism is.You can now say
label $foo | ..... | break $foo
where the break causes control to return to the label $foo, which
then producesempty
(backtracks). There's named and anonymous
labels. -
tail call optimization (TCO), which allows efficient recursion in jq
-
a variety of new control structure builtins (e.g.,
while(cond; exp)
,repeat(exp)
,until(cond; next)
) -
an enhanced form of
reduce
:foreach exp as $name (init_exp; update_exp; extract_exp)
-
a proper module system
import "foo/bar" as bar; # import foo/bar.jq's defs into a bar::* namespace
-
the ability to read module data files
import "foo/bar" as $bar; # read foo/bar.json, bind to $bar::bar
-
--argjson var '<JSON text>'
Using --arg var bit me too many times :)
-
--in-place
/-i
for in-place editing of files -
support for application/json-seq.
-
a variety of new utility functions, many being community contributions
-
a variety of performance enhancements (e.g., constant folding)
-
def($a): ...;
is now allowed as an equivalent ofdef(a): a as $a | ...;
Lastly, don't forget the wiki! It has a lot of new content since 1.4, much of it contributed by the community.