Releases: eiiches/jackson-jq
1.0.0-preview.20191208
WARNING: This is a pre-release. Java API will likely to change in final 1.0.0 release.
Changes since 1.0.0-preview.20190925
Bug fixes
- Allow escaped forward slashes (
\/
) in strings (#51)
0.0.12
1.0.0-preview.20190925
WARNING: This is a pre-release. Java API will change in final 1.0.0 release.
jackson-jq 0.0.9
This release contains some incompatible changes. Please take a look at the Incompatible changes section before upgrading.
Improvements
join/1
is re-implemented in Java to achieve O(n) time complexity. Previously, it was implemented in jq usingreduce
and+
operator, which incurred O(n^2) copy operations and quickly became prohibitive for large inputs.
Incompatible changes
- It is now considered an error to include spaces between
.
and an identifier in field accessors (e.g.. foo
). While the new behavior is in line with jq, this is a backward incompatible change for jackson-jq users. (#21, #20)
API deprecations
JsonQuery.apply(...)
without explicitScope
parameter is now deprecated. Please useJsonQuery.apply(scope, in)
instead.Scope(parent)
constructor is now deprecated. Please useScope.newChildScope(parent)
instead.Scope()
constructor is deprecated (since 0.0.8). Please useScope.newEmptyScope()
instead.
With these deprecations considered, minimal usage becomes a bit lengthy:
// rootScope should be reused as possible because loadFunctions() is a heavy operation.
// After this initial setup, rootScope should not be modified (via setValue(), etc.) so that
// it can be shared across threads.
final Scope rootScope = Scope.newEmptyScope();
rootScope.loadFunctions(Scope.class.getClassLoader());
// If one needs to pass variables to jq, a lightweight child scope should be created per
// apply() invocation or at least per thread.
final Scope childScope = Scope.newChildScope(rootScope);
childScope.setValue("param", IntNode.valueOf(42));
// compile() a query is a relatively heavy operation and the results should be reused as possible.
// q is immutable and thread-safe.
final JsonQuery q = JsonQuery.compile("$param * 2");
// apply() with an explicit scope
q.apply(childScope, in) // => [84]
Bug fixes
- Default
Scope.rootScope()
is used inconsistently when callingloadFunctions()
on alternative scopes (#17)
jackson-jq 0.0.7
This release contains some incompatible changes. Please take a look at the Incompatible changes between 0.0.6 and 0.0.7 section before upgrading.
New features
More syntax supports
- [Bug] Field accessors can now follow immediately after closing parentheses (e.g.
(.a).b
) - [jq-1.5] Destructuring syntax (e.g.
. as [$a, $b] | $a
) - [jq-1.5] Generic
?
operator (e.g.(.a)?
) - [jq-1.5] Support
try
withoutcatch
clause (e.g.try .a
) - [jq-1.5] It's now possible to use reserved keywords as object keys without quotes. (e.g.
{if: 10, as: false}
)
More functions
- [jq-1.4]
recurse_down/0
- [jq-1.5]
combinations/0
andcombinations/1
- [jq-1.5]
in/1
andinside/1
- [jq-1.5]
recurse/2
- [jq-1.5]
map_values/1
- [jq-1.5]
infinite/0
andisinfinite/0
- [jq-1.5]
nan/0
andisnan/0
- [jq-1.5]
log2/0
andpow/2
- [jq-1.x]
utf8bytelength/0
Oniguruma regular expressions
The previous versions of jackson-jq had been using Java regular expressions which were often incompatible with jq-1.5's Oniguruma regular expressions. In this release, jackson-jq switched to use joni, an Oniguruma implementation for Java, in order to archive best compatibility with jq. On the other hand, this introduces a compatibility issue with the previous releases of jackson-jq. The following functions are affected:
split/2
,splits/1
andsplits/2
(Note thatsplit/1
, a non-regex match version, is not affected)sub/2
andsub/3
gsub/2
andgsub/3
scan/1
andscan/2
capture/1
andcapture/2
test/1
andtest/2
match/1
andmatch/2
Incompatible changes between 0.0.6 and 0.0.7
- Regular expression functions now uses Oniguruma (see above), this may break some applications.
split2/1
(basicallysplit/1
but with regex) is removed because it's never been included in any of the jq releases.- Fix
contains/1
to raise an error if argument and input types do not match. The previous behavior was to returnfalse
. - [jq-1.3]
length/0
of string now returns the number of Unicode code points, not the number of code units of the UTF-16 representation. - [jq-1.5]
flatten/1
with a negative depth are not allowed anymore, useflatten/0
instead. - [jq-1.5] Division (
/
) and modulo (%
) operators now raise an error if the divisors are zero. The previous behavior was to return +/- infinity. - [jq-1.x]
join/1
now also accepts an array of non-string values as the input.
Other improvements
- Built-in functions are now loaded using the ServiceLoader API, which makes it easy to work with maven-shade-plugin.
jackson-jq
command now accepts--null-input/-n
option, which specifies the command to use a singlenull
as the input.