From fc6cde1433c8bb247f118b19d4319b7254af89d6 Mon Sep 17 00:00:00 2001 From: Eiichi Sato Date: Sun, 8 Dec 2019 14:16:19 +0900 Subject: [PATCH 1/4] [maven-release-plugin] prepare for next development iteration --- jackson-jq-cli/pom.xml | 4 ++-- jackson-jq-extra/pom.xml | 4 ++-- jackson-jq/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/jackson-jq-cli/pom.xml b/jackson-jq-cli/pom.xml index 68f3c144..d27ba242 100644 --- a/jackson-jq-cli/pom.xml +++ b/jackson-jq-cli/pom.xml @@ -8,14 +8,14 @@ net.thisptr jackson-jq-parent - 1.0.0-preview.20191208 + 1.0.0-SNAPSHOT net.thisptr jackson-jq-extra - 1.0.0-preview.20191208 + 1.0.0-SNAPSHOT commons-cli diff --git a/jackson-jq-extra/pom.xml b/jackson-jq-extra/pom.xml index b97f03e5..8296a01f 100644 --- a/jackson-jq-extra/pom.xml +++ b/jackson-jq-extra/pom.xml @@ -8,14 +8,14 @@ net.thisptr jackson-jq-parent - 1.0.0-preview.20191208 + 1.0.0-SNAPSHOT net.thisptr jackson-jq - 1.0.0-preview.20191208 + 1.0.0-SNAPSHOT diff --git a/jackson-jq/pom.xml b/jackson-jq/pom.xml index 85f34729..1d500b93 100644 --- a/jackson-jq/pom.xml +++ b/jackson-jq/pom.xml @@ -8,7 +8,7 @@ net.thisptr jackson-jq-parent - 1.0.0-preview.20191208 + 1.0.0-SNAPSHOT diff --git a/pom.xml b/pom.xml index 7757df1b..806d0976 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ net.thisptr jackson-jq-parent pom - 1.0.0-preview.20191208 + 1.0.0-SNAPSHOT ${project.groupId}:${project.artifactId} jq for Jackson JSON Processor https://github.com/eiiches/jackson-jq @@ -28,7 +28,7 @@ scm:git:git@github.com:eiiches/jackson-jq.git scm:git:git@github.com:eiiches/jackson-jq.git git@github.com:juven/git-demo.git - 1.0.0-preview.20191208 + HEAD From 9faf22e96b69680bebc749bc05723327f36929a8 Mon Sep 17 00:00:00 2001 From: itchyny Date: Mon, 23 Nov 2020 14:06:09 +0900 Subject: [PATCH 2/4] indices/1: fix infinite loop on empty needle text (fix #59) --- .../jackson/jq/internal/functions/IndicesFunction.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jackson-jq/src/main/java/net/thisptr/jackson/jq/internal/functions/IndicesFunction.java b/jackson-jq/src/main/java/net/thisptr/jackson/jq/internal/functions/IndicesFunction.java index cc311460..f1bbf758 100644 --- a/jackson-jq/src/main/java/net/thisptr/jackson/jq/internal/functions/IndicesFunction.java +++ b/jackson-jq/src/main/java/net/thisptr/jackson/jq/internal/functions/IndicesFunction.java @@ -47,8 +47,10 @@ public static List indices(final JsonNode needle, final JsonNode haysta if (needle.isTextual() && haystack.isTextual()) { final String haystackText = haystack.asText(); final String needleText = needle.asText(); - for (int index = haystackText.indexOf(needleText); index >= 0; index = haystackText.indexOf(needleText, index + 1)) - result.add(index); + if (!needleText.isEmpty()) { + for (int index = haystackText.indexOf(needleText); index >= 0; index = haystackText.indexOf(needleText, index + 1)) + result.add(index); + } } else if (needle.isArray() && haystack.isArray()) { if (needle.size() != 0) { for (int i = 0; i < haystack.size(); ++i) { From 2a4ab7b53208fad90782d50ce5302fe8686646d0 Mon Sep 17 00:00:00 2001 From: Eiichi Sato Date: Mon, 23 Nov 2020 20:13:37 +0900 Subject: [PATCH 3/4] test: add test for #67 --- README.md | 4 +++- .../src/test/java/net/thisptr/jackson/jq/JsonQueryTest.java | 5 ++++- jackson-jq/src/test/resources/tests/functions/indices.yaml | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bee71fb5..bd36803f 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ This table illustrates which features (picked from jq-1.5 manual) are supported |     • [`unique`, `unique_by(path_exp)`](https://stedolan.github.io/jq/manual/v1.5/#unique,unique_by(path_exp)) | ○ | |     • [`reverse`](https://stedolan.github.io/jq/manual/v1.5/#reverse) | ○ | |     • [`contains(element)`](https://stedolan.github.io/jq/manual/v1.5/#contains(element)) | ○ | -|     • [`indices(s)`](https://stedolan.github.io/jq/manual/v1.5/#indices(s)) | ○ | +|     • [`indices(s)`](https://stedolan.github.io/jq/manual/v1.5/#indices(s)) | ○*9 | |     • [`index(s)`, `rindex(s)`](https://stedolan.github.io/jq/manual/v1.5/#index(s),rindex(s)) | ○ | |     • [`inside`](https://stedolan.github.io/jq/manual/v1.5/#inside) | ○ | |     • [`startswith(str)`](https://stedolan.github.io/jq/manual/v1.5/#startswith(str)) | ○ | @@ -224,6 +224,8 @@ This table illustrates which features (picked from jq-1.5 manual) are supported *8) `.foo |= empty` always throws an error in jackson-jq instead of producing an unexpected result. jq-1.5 and jq-1.6 respectively produces a different and incorrect result for `[1,2,3] | ((.[] | select(. > 1)) |= empty)`. [jq#897](https://github.com/stedolan/jq/issues/897) says "empty in the RHS is undefined". You can still use `_modify/2` directly if you really want to emulate the exact jq-1.5 or jq-1.6 behavior. +*9) `"x" | indices("")` always returns an empty array in jackson-jq. The behavior is in line with jq after [2660b04](https://github.com/stedolan/jq/commit/2660b04a731568c54eb4b91fe811d81cbbf3470b) commit, but differs from how jq-1.5 and jq-1.6 behave. + Using jackson-jq-extra module ----------------------------- diff --git a/jackson-jq/src/test/java/net/thisptr/jackson/jq/JsonQueryTest.java b/jackson-jq/src/test/java/net/thisptr/jackson/jq/JsonQueryTest.java index 4475d9df..52dc9d48 100644 --- a/jackson-jq/src/test/java/net/thisptr/jackson/jq/JsonQueryTest.java +++ b/jackson-jq/src/test/java/net/thisptr/jackson/jq/JsonQueryTest.java @@ -63,6 +63,9 @@ public static class TestCase { @JsonProperty("should_compile") public boolean shouldCompile = true; + @JsonProperty("ignore_true_jq_behavior") + public boolean ignoreTrueJqBehavior = false; + @JsonInclude(Include.NON_NULL) @JsonProperty("v") @JsonDeserialize(using = VersionRangeDeserializer.class) @@ -156,7 +159,7 @@ private void test(final TestCase tc, final Version version) throws Throwable { return; } - if (hasJqCache.computeIfAbsent(version, v -> TrueJqEvaluator.hasJq(v))) { + if (!tc.ignoreTrueJqBehavior && hasJqCache.computeIfAbsent(version, v -> TrueJqEvaluator.hasJq(v))) { final Result result = cachedJqEvaluator.evaluate(tc.q, tc.in, version, 2000L); assumeThat(result.error).as("%s", command).isNull(); assumeThat(wrap(tc.out)).as("%s", command).isEqualTo(wrap(result.values)); diff --git a/jackson-jq/src/test/resources/tests/functions/indices.yaml b/jackson-jq/src/test/resources/tests/functions/indices.yaml index 85104c22..92543333 100644 --- a/jackson-jq/src/test/resources/tests/functions/indices.yaml +++ b/jackson-jq/src/test/resources/tests/functions/indices.yaml @@ -1 +1,2 @@ - {"v":"[1.5,1.5]","q":"indices(-1.0)","in":null,"out":[null]} +- {"v":"[1.5,1.6]","q":"indices(\"\")","in":"x","out":[[]],"ignore_true_jq_behavior":true} From 0e0d2770f93d618d92d58248f70bf6fe188991f1 Mon Sep 17 00:00:00 2001 From: Eiichi Sato Date: Mon, 23 Nov 2020 20:20:38 +0900 Subject: [PATCH 4/4] [maven-release-plugin] prepare release 1.0.0-preview.20201123 --- README.md | 16 ++++++++-------- jackson-jq-cli/pom.xml | 4 ++-- jackson-jq-extra/pom.xml | 4 ++-- jackson-jq/pom.xml | 2 +- pom.xml | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index bd36803f..bfa7baae 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ Usage First, you need Java 8 or later. -If you use Maven, add the following snippet to the `` section of your POM. For instructions for other build tools (Gradle, etc.), visit [jackson-jq](https://search.maven.org/artifact/net.thisptr/jackson-jq/1.0.0-preview.20191208/jar) on search.maven.org. +If you use Maven, add the following snippet to the `` section of your POM. For instructions for other build tools (Gradle, etc.), visit [jackson-jq](https://search.maven.org/artifact/net.thisptr/jackson-jq/1.0.0-preview.20201123/jar) on search.maven.org. ```xml net.thisptr jackson-jq - 1.0.0-preview.20191208 + 1.0.0-preview.20201123 ``` @@ -30,9 +30,9 @@ Using a jackson-jq command line tool To test a query quickly, we provide jackson-jq CLI. ```sh -$ curl -LO https://repo1.maven.org/maven2/net/thisptr/jackson-jq-cli/1.0.0-preview.20191208/jackson-jq-cli-1.0.0-preview.20191208.jar +$ curl -LO https://repo1.maven.org/maven2/net/thisptr/jackson-jq-cli/1.0.0-preview.20201123/jackson-jq-cli-1.0.0-preview.20201123.jar -$ java -jar jackson-jq-cli-1.0.0-preview.20191208.jar --help +$ java -jar jackson-jq-cli-1.0.0-preview.20201123.jar --help usage: jackson-jq [OPTIONS...] QUERY -c,--compact compact instead of pretty-printed output -h,--help print this message @@ -40,7 +40,7 @@ usage: jackson-jq [OPTIONS...] QUERY -n,--null-input use `null` as the single input value -r,--raw output raw strings, not JSON texts -$ java -jar jackson-jq-cli-1.0.0-preview.20191208.jar '.foo' +$ java -jar jackson-jq-cli-1.0.0-preview.20201123.jar '.foo' {"foo": 42} 42 ``` @@ -48,11 +48,11 @@ $ java -jar jackson-jq-cli-1.0.0-preview.20191208.jar '.foo' To test a query with a specific jq version, ```sh -$ java -jar jackson-jq-cli-1.0.0-preview.20191208.jar --jq 1.5 'join("-")' +$ java -jar jackson-jq-cli-1.0.0-preview.20201123.jar --jq 1.5 'join("-")' ["1", 2] jq: error: string ("-") and number (2) cannot be added -$ java -jar jackson-jq-cli-1.0.0-preview.20191208.jar --jq 1.6 'join("-")' # jq-1.6 can join any values, not only strings +$ java -jar jackson-jq-cli-1.0.0-preview.20201123.jar --jq 1.6 'join("-")' # jq-1.6 can join any values, not only strings ["1", 2] "1-2" ``` @@ -235,7 +235,7 @@ Using jackson-jq-extra module net.thisptr jackson-jq-extra - 1.0.0-preview.20191208 + 1.0.0-preview.20201123 ``` diff --git a/jackson-jq-cli/pom.xml b/jackson-jq-cli/pom.xml index d27ba242..4b7306dd 100644 --- a/jackson-jq-cli/pom.xml +++ b/jackson-jq-cli/pom.xml @@ -8,14 +8,14 @@ net.thisptr jackson-jq-parent - 1.0.0-SNAPSHOT + 1.0.0-preview.20201123 net.thisptr jackson-jq-extra - 1.0.0-SNAPSHOT + 1.0.0-preview.20201123 commons-cli diff --git a/jackson-jq-extra/pom.xml b/jackson-jq-extra/pom.xml index 8296a01f..76a6a6f0 100644 --- a/jackson-jq-extra/pom.xml +++ b/jackson-jq-extra/pom.xml @@ -8,14 +8,14 @@ net.thisptr jackson-jq-parent - 1.0.0-SNAPSHOT + 1.0.0-preview.20201123 net.thisptr jackson-jq - 1.0.0-SNAPSHOT + 1.0.0-preview.20201123 diff --git a/jackson-jq/pom.xml b/jackson-jq/pom.xml index 1d500b93..090b0e60 100644 --- a/jackson-jq/pom.xml +++ b/jackson-jq/pom.xml @@ -8,7 +8,7 @@ net.thisptr jackson-jq-parent - 1.0.0-SNAPSHOT + 1.0.0-preview.20201123 diff --git a/pom.xml b/pom.xml index 806d0976..f2f1dbed 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ net.thisptr jackson-jq-parent pom - 1.0.0-SNAPSHOT + 1.0.0-preview.20201123 ${project.groupId}:${project.artifactId} jq for Jackson JSON Processor https://github.com/eiiches/jackson-jq @@ -28,7 +28,7 @@ scm:git:git@github.com:eiiches/jackson-jq.git scm:git:git@github.com:eiiches/jackson-jq.git git@github.com:juven/git-demo.git - HEAD + 1.0.0-preview.20201123