From 1eacd85f01ec9fa7104ea05805e18b6b51234fef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Oct 2020 08:55:35 +0000 Subject: [PATCH 01/22] Bump junit from 4.12 to 4.13.1 Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.1. - [Release notes](https://github.com/junit-team/junit4/releases) - [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md) - [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13.1) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2d48e75..f9184f9 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ https://github.com/burtcorp/jmespath-java - 4.12 + 4.13.1 1.3 2.9.9 1.1.6 From fb0156903dae860c91731dd60d163b2127f6771b Mon Sep 17 00:00:00 2001 From: Theo Date: Sat, 4 Dec 2021 12:51:57 +0100 Subject: [PATCH 02/22] [maven-release-plugin] prepare for next development iteration --- jmespath-core/pom.xml | 2 +- jmespath-gson/pom.xml | 2 +- jmespath-jackson/pom.xml | 2 +- jmespath-jakarta-jsonp/pom.xml | 2 +- jmespath-vertx/pom.xml | 2 +- pom.xml | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/jmespath-core/pom.xml b/jmespath-core/pom.xml index 06de939..13b981c 100644 --- a/jmespath-core/pom.xml +++ b/jmespath-core/pom.xml @@ -10,7 +10,7 @@ io.burt jmespath - 0.5.1 + 0.5.2-SNAPSHOT diff --git a/jmespath-gson/pom.xml b/jmespath-gson/pom.xml index 1541bf9..dc40e68 100644 --- a/jmespath-gson/pom.xml +++ b/jmespath-gson/pom.xml @@ -10,7 +10,7 @@ io.burt jmespath - 0.5.1 + 0.5.2-SNAPSHOT diff --git a/jmespath-jackson/pom.xml b/jmespath-jackson/pom.xml index 933cafd..19725e7 100644 --- a/jmespath-jackson/pom.xml +++ b/jmespath-jackson/pom.xml @@ -10,7 +10,7 @@ io.burt jmespath - 0.5.1 + 0.5.2-SNAPSHOT diff --git a/jmespath-jakarta-jsonp/pom.xml b/jmespath-jakarta-jsonp/pom.xml index 3f88649..5e2ca26 100644 --- a/jmespath-jakarta-jsonp/pom.xml +++ b/jmespath-jakarta-jsonp/pom.xml @@ -10,7 +10,7 @@ io.burt jmespath - 0.5.1 + 0.5.2-SNAPSHOT diff --git a/jmespath-vertx/pom.xml b/jmespath-vertx/pom.xml index 8589e7c..4867611 100644 --- a/jmespath-vertx/pom.xml +++ b/jmespath-vertx/pom.xml @@ -10,7 +10,7 @@ io.burt jmespath - 0.5.1 + 0.5.2-SNAPSHOT diff --git a/pom.xml b/pom.xml index 25e720c..b5f0010 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.burt jmespath - 0.5.1 + 0.5.2-SNAPSHOT pom JMESPath @@ -51,7 +51,7 @@ scm:git:ssh://git@github.com/burtcorp/jmespath-java.git scm:git:ssh://git@github.com/burtcorp/jmespath-java.git https://github.com/burtcorp/jmespath-java.git - jmespath-0.5.1 + jmespath-${project.version} From 16303e96568024b7881e4df950731ca84cba007a Mon Sep 17 00:00:00 2001 From: Mantas Norvaisa Date: Fri, 29 Apr 2022 16:26:13 +0300 Subject: [PATCH 03/22] Fix precedence of negation vs comparison --- .../main/antlr4/io/burt/jmespath/parser/JmesPath.g4 | 2 +- .../main/java/io/burt/jmespath/node/NegateNode.java | 5 +++++ .../test/java/io/burt/jmespath/parser/ParserTest.java | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/jmespath-core/src/main/antlr4/io/burt/jmespath/parser/JmesPath.g4 b/jmespath-core/src/main/antlr4/io/burt/jmespath/parser/JmesPath.g4 index 8d6dc5f..3188179 100644 --- a/jmespath-core/src/main/antlr4/io/burt/jmespath/parser/JmesPath.g4 +++ b/jmespath-core/src/main/antlr4/io/burt/jmespath/parser/JmesPath.g4 @@ -6,8 +6,8 @@ expression : expression '.' chainedExpression # chainExpression | expression bracketSpecifier # bracketedExpression | bracketSpecifier # bracketExpression - | expression COMPARATOR expression # comparisonExpression | '!' expression # notExpression + | expression COMPARATOR expression # comparisonExpression | expression '&&' expression # andExpression | expression '||' expression # orExpression | identifier # identifierExpression diff --git a/jmespath-core/src/main/java/io/burt/jmespath/node/NegateNode.java b/jmespath-core/src/main/java/io/burt/jmespath/node/NegateNode.java index 1a628df..d1d083f 100644 --- a/jmespath-core/src/main/java/io/burt/jmespath/node/NegateNode.java +++ b/jmespath-core/src/main/java/io/burt/jmespath/node/NegateNode.java @@ -22,6 +22,11 @@ protected boolean internalEquals(Object o) { return negated.equals(other.negated); } + @Override + protected String internalToString() { + return negated.toString(); + } + @Override protected int internalHashCode() { return 17 + 31 * negated.hashCode(); diff --git a/jmespath-core/src/test/java/io/burt/jmespath/parser/ParserTest.java b/jmespath-core/src/test/java/io/burt/jmespath/parser/ParserTest.java index 0597b06..1ff49b5 100644 --- a/jmespath-core/src/test/java/io/burt/jmespath/parser/ParserTest.java +++ b/jmespath-core/src/test/java/io/burt/jmespath/parser/ParserTest.java @@ -843,6 +843,17 @@ public void negatedSelectionExpression() { assertThat(actual, is(expected)); } + @Test + public void negatedComparison() { + Expression expected = Comparison( + "==", + Negate(Property("foo")), + JsonLiteral("false") + ); + Expression actual = compile("!foo == `false`"); + assertThat(actual, is(expected)); + } + @Test public void bareJsonLiteralExpression() { Expression expected = JsonLiteral("{}"); From d683914e3f8a235c15fd2ed761957e0a53f218b2 Mon Sep 17 00:00:00 2001 From: Abhishek Shukla Date: Mon, 2 Jan 2023 18:13:24 +0100 Subject: [PATCH 04/22] Add kotlinx serialization support --- jmespath-kotlinx/pom.xml | 72 +++++++++++ .../burt/jmespath/kotlinx/KotlinxRuntime.kt | 112 ++++++++++++++++++ .../jmespath/kotlinx/KotlinxComplianceTest.kt | 10 ++ .../io/burt/jmespath/kotlinx/KotlinxTest.kt | 10 ++ pom.xml | 1 + 5 files changed, 205 insertions(+) create mode 100644 jmespath-kotlinx/pom.xml create mode 100644 jmespath-kotlinx/src/main/java/io/burt/jmespath/kotlinx/KotlinxRuntime.kt create mode 100644 jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxComplianceTest.kt create mode 100644 jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxTest.kt diff --git a/jmespath-kotlinx/pom.xml b/jmespath-kotlinx/pom.xml new file mode 100644 index 0000000..a39cd78 --- /dev/null +++ b/jmespath-kotlinx/pom.xml @@ -0,0 +1,72 @@ + + + + 4.0.0 + jmespath-kotlinx + JMESPath Kotlinx + A JMESPath implementation with kotlinx + + + io.burt + jmespath + 0.5.2-SNAPSHOT + + + + + ${project.groupId} + jmespath-core + ${project.parent.version} + + + ${project.groupId} + jmespath-core + ${project.parent.version} + test-jar + test + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + org.jetbrains.kotlinx + kotlinx-serialization-json + 1.4.1 + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + + + kotlinx-serialization + + + + + org.jetbrains.kotlin + kotlin-maven-serialization + ${kotlin.version} + + + + + + + 1.6.0 + + diff --git a/jmespath-kotlinx/src/main/java/io/burt/jmespath/kotlinx/KotlinxRuntime.kt b/jmespath-kotlinx/src/main/java/io/burt/jmespath/kotlinx/KotlinxRuntime.kt new file mode 100644 index 0000000..7c563f4 --- /dev/null +++ b/jmespath-kotlinx/src/main/java/io/burt/jmespath/kotlinx/KotlinxRuntime.kt @@ -0,0 +1,112 @@ +package io.burt.jmespath.kotlinx + +import io.burt.jmespath.BaseRuntime +import io.burt.jmespath.JmesPathType +import io.burt.jmespath.RuntimeConfiguration +import kotlinx.serialization.ExperimentalSerializationApi +import kotlinx.serialization.json.Json +import kotlinx.serialization.json.JsonArray +import kotlinx.serialization.json.JsonElement +import kotlinx.serialization.json.JsonNull +import kotlinx.serialization.json.JsonObject +import kotlinx.serialization.json.JsonPrimitive +import kotlinx.serialization.json.boolean +import kotlinx.serialization.json.booleanOrNull +import kotlinx.serialization.json.doubleOrNull +import kotlinx.serialization.json.encodeToJsonElement +import kotlinx.serialization.json.jsonArray +import kotlinx.serialization.json.jsonObject +import kotlinx.serialization.json.jsonPrimitive + + +@OptIn(ExperimentalSerializationApi::class) +class KotlinRuntime(configuration: RuntimeConfiguration, private val json: Json) : + BaseRuntime(configuration) { + + + constructor() : this(RuntimeConfiguration.defaultConfiguration(), Json { + encodeDefaults = true + explicitNulls = true + }) + + constructor(configuration: RuntimeConfiguration) : this(configuration, Json { + encodeDefaults = true + explicitNulls = true + }) + + override fun toString(value: JsonElement) = value.jsonPrimitive.content + + override fun parseString(str: String): JsonElement { + return json.parseToJsonElement(str) + } + + override fun createNull(): JsonElement { + return JsonNull + } + + override fun createString(str: String): JsonElement { + return json.parseToJsonElement(str) + } + + override fun createBoolean(b: Boolean): JsonElement { + return JsonPrimitive(b) + } + + override fun createNumber(n: Double): JsonElement { + return JsonPrimitive(n) + } + + override fun createNumber(n: Long): JsonElement { + return JsonPrimitive(n) + } + + override fun createObject(obj: MutableMap?): JsonElement { + return json.encodeToJsonElement(obj) + } + + override fun createArray(elements: MutableCollection): JsonElement { + return JsonArray(elements.toList()) + } + + override fun getPropertyNames(value: JsonElement): Collection { + return if (value is JsonObject) { + value.jsonObject.keys.map { JsonPrimitive(it) } + } else + emptyList() + } + + override fun getProperty(value: JsonElement, name: JsonElement): JsonElement { + return value.jsonObject[name.jsonPrimitive.content] ?: JsonNull + } + + override fun typeOf(value: JsonElement): JmesPathType { + return if (value == JsonNull) + JmesPathType.NULL + else if (value is JsonArray) + JmesPathType.ARRAY + else if (value is JsonObject) + JmesPathType.OBJECT + else if (value.jsonPrimitive.booleanOrNull != null) + JmesPathType.BOOLEAN + else if (value.jsonPrimitive.doubleOrNull != null) + JmesPathType.NUMBER + else + JmesPathType.STRING + } + + override fun isTruthy(value: JsonElement): Boolean { + return value.jsonPrimitive.jsonPrimitive.boolean + } + + override fun toNumber(value: JsonElement): Number { + return value.jsonPrimitive.content.toDouble() + } + + override fun toList(value: JsonElement?): List { + return when (value) { + is JsonArray -> value.jsonArray + is JsonObject -> value.values.toList() + else -> emptyList() + } + } +} diff --git a/jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxComplianceTest.kt b/jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxComplianceTest.kt new file mode 100644 index 0000000..1af1aaf --- /dev/null +++ b/jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxComplianceTest.kt @@ -0,0 +1,10 @@ +package io.burt.jmespath.kotlinx + +import io.burt.jmespath.JmesPathComplianceTest +import io.burt.jmespath.Adapter +import io.burt.jmespath.RuntimeConfiguration +import kotlinx.serialization.json.JsonElement + +class KotlinxComplianceTest : JmesPathComplianceTest() { + override fun runtime(): Adapter = KotlinRuntime(RuntimeConfiguration.defaultConfiguration()) +} diff --git a/jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxTest.kt b/jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxTest.kt new file mode 100644 index 0000000..6a7025a --- /dev/null +++ b/jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxTest.kt @@ -0,0 +1,10 @@ +package io.burt.jmespath.kotlinx + + +import io.burt.jmespath.JmesPathRuntimeTest +import io.burt.jmespath.RuntimeConfiguration +import kotlinx.serialization.json.JsonElement + +class KotlinxTest : JmesPathRuntimeTest() { + override fun createRuntime(configuration: RuntimeConfiguration) = KotlinRuntime(configuration) +} diff --git a/pom.xml b/pom.xml index b5f0010..c976a98 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,7 @@ jmespath-jakarta-jsonp jmespath-gson jmespath-vertx + jmespath-kotlinx From 1bd93b1b8042d58f1e38bd7412968265ad91720a Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Fri, 20 Oct 2023 16:11:03 +0200 Subject: [PATCH 05/22] add jackson-jr implementation --- jmespath-jackson-jr/pom.xml | 56 ++++ .../jmespath/jacksonjr/JacksonJrRuntime.java | 239 ++++++++++++++++++ .../jacksonjr/JacksonJrComplianceTest.java | 26 ++ .../jmespath/jacksonjr/JacksonJrTest.java | 28 ++ 4 files changed, 349 insertions(+) create mode 100644 jmespath-jackson-jr/pom.xml create mode 100644 jmespath-jackson-jr/src/main/java/io/burt/jmespath/jacksonjr/JacksonJrRuntime.java create mode 100644 jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrComplianceTest.java create mode 100644 jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrTest.java diff --git a/jmespath-jackson-jr/pom.xml b/jmespath-jackson-jr/pom.xml new file mode 100644 index 0000000..ed56586 --- /dev/null +++ b/jmespath-jackson-jr/pom.xml @@ -0,0 +1,56 @@ + + + + + 4.0.0 + + jmespath-jackson-jr + JMESPath JacksonJr + A JMESPath implementation for Java + + + io.burt + jmespath + 0.5.2-SNAPSHOT + + + + + ${project.groupId} + jmespath-core + ${project.parent.version} + + + ${project.groupId} + jmespath-core + ${project.parent.version} + test-jar + test + + + com.fasterxml.jackson.jr + jackson-jr-objects + 2.14.2 + + + com.fasterxml.jackson.jr + jackson-jr-stree + 2.14.2 + + + + \ No newline at end of file diff --git a/jmespath-jackson-jr/src/main/java/io/burt/jmespath/jacksonjr/JacksonJrRuntime.java b/jmespath-jackson-jr/src/main/java/io/burt/jmespath/jacksonjr/JacksonJrRuntime.java new file mode 100644 index 0000000..bdb51de --- /dev/null +++ b/jmespath-jackson-jr/src/main/java/io/burt/jmespath/jacksonjr/JacksonJrRuntime.java @@ -0,0 +1,239 @@ +/* + * Copyright 2023 Amazon.com, Inc. or its affiliates. + * Licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.burt.jmespath.jacksonjr; + +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.TreeNode; +import com.fasterxml.jackson.jr.ob.JSON; +import com.fasterxml.jackson.jr.stree.JacksonJrsTreeCodec; +import com.fasterxml.jackson.jr.stree.JrsArray; +import com.fasterxml.jackson.jr.stree.JrsBoolean; +import com.fasterxml.jackson.jr.stree.JrsNull; +import com.fasterxml.jackson.jr.stree.JrsNumber; +import com.fasterxml.jackson.jr.stree.JrsObject; +import com.fasterxml.jackson.jr.stree.JrsString; +import com.fasterxml.jackson.jr.stree.JrsValue; +import io.burt.jmespath.BaseRuntime; +import io.burt.jmespath.JmesPathType; +import io.burt.jmespath.RuntimeConfiguration; +import java.io.IOException; +import java.util.AbstractList; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +public class JacksonJrRuntime extends BaseRuntime { + private final JSON json; + public JacksonJrRuntime() { + this(RuntimeConfiguration.defaultConfiguration()); + } + + public JacksonJrRuntime(RuntimeConfiguration configuration) { + this(configuration, JSON.builder() + .treeCodec(new JacksonJrsTreeCodec()) + .build()); + } + public JacksonJrRuntime(RuntimeConfiguration configuration, JSON json) { + super(configuration); + this.json = json; + } + + @Override + public TreeNode parseString(String str) { + try { + return json.treeFrom(str); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + private static class JrsArrayListWrapper extends AbstractList { + private final JrsArray array; + + JrsArrayListWrapper(JrsArray array) { + this.array = array; + } + + @Override + public TreeNode get(int index) { + return array.get(index); + } + + @Override + public int size() { + return array.size(); + } + } + + @Override + public List toList(TreeNode value) { + if (value == null) { + return Collections.emptyList(); + } + if (value.isArray()) { + return new JrsArrayListWrapper((JrsArray) value); + } else if (value.isObject()) { + JrsObject object = (JrsObject) value; + List list = new ArrayList<>(object.size()); + Iterator> iterator = object.fields(); + + while (iterator.hasNext()) { + Map.Entry entry = (Map.Entry) iterator.next(); + list.add(entry.getValue()); + } + return list; + } else { + return Collections.emptyList(); + } + } + + @Override + public String toString(TreeNode value) { + if (value.asToken().equals(JsonToken.VALUE_STRING)) { + return ((JrsString) value).asText(); + } else { + try { + return json.asString(value); + } catch (IOException e) { + return ""; + } + } + } + + @Override + public Number toNumber(TreeNode value) { + if (value.isValueNode() && ((JrsValue) value).isNumber()) { + JrsNumber number = (JrsNumber) value; + return number.getValue(); + } else return null; + } + + @Override + public boolean isTruthy(TreeNode value) { + // false, null, empty lists, empty objects, empty strings. + if (value.isContainerNode()) { + return value.size() > 0; + } else if (value.isValueNode()) { + if (value.asToken().equals(JsonToken.VALUE_STRING)) { + return !((JrsString) value).asText().isEmpty(); + } else return !value.asToken().equals(JsonToken.VALUE_FALSE) && + !value.asToken().equals(JsonToken.VALUE_NULL); + } else { + return !value.isMissingNode(); + } + } + + @Override + public JmesPathType typeOf(TreeNode value) { + switch (value.asToken()) { + case START_ARRAY: + case END_ARRAY: + return JmesPathType.ARRAY; + case VALUE_EMBEDDED_OBJECT: + case START_OBJECT: + case END_OBJECT: + return JmesPathType.OBJECT; + case VALUE_STRING: + return JmesPathType.STRING; + case VALUE_NUMBER_INT: + case VALUE_NUMBER_FLOAT: + return JmesPathType.NUMBER; + case VALUE_TRUE: + case VALUE_FALSE: + return JmesPathType.BOOLEAN; + case VALUE_NULL: + return JmesPathType.NULL; + case NOT_AVAILABLE: + default: + throw new IllegalStateException(String.format("Unknown node type encountered: %s", value.asToken())); + } + } + + @Override + public TreeNode getProperty(TreeNode value, TreeNode name) { + if (value == null || value.asToken().equals(JsonToken.VALUE_NULL)) { + return JrsNull.instance(); + } else { + TreeNode node = value.get(((JrsString) name).asText()); + return node != null ? node : createNull(); + } + } + + @Override + public Collection getPropertyNames(TreeNode value) { + if (value != null && value.isObject()) { + List names = new ArrayList<>(value.size()); + Iterator fieldNames = value.fieldNames(); + while (fieldNames.hasNext()) { + names.add(createString(fieldNames.next())); + } + return names; + } else { + return Collections.emptyList(); + } + } + + @Override + public TreeNode createNull() { + return JrsNull.instance(); + } + + @Override + public TreeNode createArray(Collection elements) { + List values = new ArrayList<>(); + for (TreeNode node: elements) { + if (node == null) { + values.add(JrsNull.instance()); + } else { + values.add((JrsValue) node); + } + } + return new JrsArray(values); + + } + + @Override + public TreeNode createString(String str) { + return new JrsString(str); + } + + @Override + public TreeNode createBoolean(boolean b) { + return b ? JrsBoolean.TRUE : JrsBoolean.FALSE; + } + + @Override + public TreeNode createObject(Map obj) { + Map values = new HashMap<>(); + for (Map.Entry entry : obj.entrySet()) { + values.put(((JrsString)entry.getKey()).asText(), (JrsValue) entry.getValue()); + } + return new JrsObject(values); + } + + @Override + public TreeNode createNumber(double n) { + return new JrsNumber(n); + } + + @Override + public TreeNode createNumber(long n) { + return new JrsNumber(n); + } +} diff --git a/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrComplianceTest.java b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrComplianceTest.java new file mode 100644 index 0000000..2efad0b --- /dev/null +++ b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrComplianceTest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2023 Amazon.com, Inc. or its affiliates. + * Licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.burt.jmespath.jacksonjr; + +import com.fasterxml.jackson.core.TreeNode; +import io.burt.jmespath.Adapter; +import io.burt.jmespath.JmesPathComplianceTest; + +public class JacksonJrComplianceTest extends JmesPathComplianceTest { + private Adapter runtime = new JacksonJrRuntime(); + + @Override + protected Adapter runtime() { return runtime; } +} diff --git a/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrTest.java b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrTest.java new file mode 100644 index 0000000..0357878 --- /dev/null +++ b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrTest.java @@ -0,0 +1,28 @@ +/* + * Copyright 2023 Amazon.com, Inc. or its affiliates. + * Licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package io.burt.jmespath.jacksonjr; + + +import com.fasterxml.jackson.core.TreeNode; +import io.burt.jmespath.Adapter; +import io.burt.jmespath.JmesPathRuntimeTest; +import io.burt.jmespath.RuntimeConfiguration; + +public class JacksonJrTest extends JmesPathRuntimeTest { + @Override + protected Adapter createRuntime(RuntimeConfiguration configuration) { + return new JacksonJrRuntime(configuration); + } +} From 50115453cc2c8bb7968301563c0a9f5b24c04984 Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Fri, 20 Oct 2023 16:16:46 +0200 Subject: [PATCH 06/22] remove license headers --- jmespath-jackson-jr/pom.xml | 14 -------------- .../burt/jmespath/jacksonjr/JacksonJrRuntime.java | 14 -------------- .../jacksonjr/JacksonJrComplianceTest.java | 14 -------------- .../io/burt/jmespath/jacksonjr/JacksonJrTest.java | 14 -------------- 4 files changed, 56 deletions(-) diff --git a/jmespath-jackson-jr/pom.xml b/jmespath-jackson-jr/pom.xml index ed56586..eead53e 100644 --- a/jmespath-jackson-jr/pom.xml +++ b/jmespath-jackson-jr/pom.xml @@ -1,18 +1,4 @@ - - diff --git a/jmespath-jackson-jr/src/main/java/io/burt/jmespath/jacksonjr/JacksonJrRuntime.java b/jmespath-jackson-jr/src/main/java/io/burt/jmespath/jacksonjr/JacksonJrRuntime.java index bdb51de..c836220 100644 --- a/jmespath-jackson-jr/src/main/java/io/burt/jmespath/jacksonjr/JacksonJrRuntime.java +++ b/jmespath-jackson-jr/src/main/java/io/burt/jmespath/jacksonjr/JacksonJrRuntime.java @@ -1,17 +1,3 @@ -/* - * Copyright 2023 Amazon.com, Inc. or its affiliates. - * Licensed under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - package io.burt.jmespath.jacksonjr; import com.fasterxml.jackson.core.JsonToken; diff --git a/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrComplianceTest.java b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrComplianceTest.java index 2efad0b..3e7eea5 100644 --- a/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrComplianceTest.java +++ b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrComplianceTest.java @@ -1,17 +1,3 @@ -/* - * Copyright 2023 Amazon.com, Inc. or its affiliates. - * Licensed under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - package io.burt.jmespath.jacksonjr; import com.fasterxml.jackson.core.TreeNode; diff --git a/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrTest.java b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrTest.java index 0357878..8dbaa37 100644 --- a/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrTest.java +++ b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrTest.java @@ -1,17 +1,3 @@ -/* - * Copyright 2023 Amazon.com, Inc. or its affiliates. - * Licensed under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - package io.burt.jmespath.jacksonjr; From 451db7ee515c32272a754cf23407f94acdffe3c6 Mon Sep 17 00:00:00 2001 From: Jerome Van Der Linden Date: Mon, 23 Oct 2023 23:27:11 +0200 Subject: [PATCH 07/22] code review fixes --- jmespath-jackson-jr/pom.xml | 2 +- .../jmespath/jacksonjr/JacksonJrRuntime.java | 91 ++++++++++--------- .../jacksonjr/JacksonJrComplianceTest.java | 8 +- .../jmespath/jacksonjr/JacksonJrTest.java | 6 +- 4 files changed, 56 insertions(+), 51 deletions(-) diff --git a/jmespath-jackson-jr/pom.xml b/jmespath-jackson-jr/pom.xml index eead53e..7362efb 100644 --- a/jmespath-jackson-jr/pom.xml +++ b/jmespath-jackson-jr/pom.xml @@ -5,7 +5,7 @@ 4.0.0 jmespath-jackson-jr - JMESPath JacksonJr + JMESPath Jackson jr A JMESPath implementation for Java diff --git a/jmespath-jackson-jr/src/main/java/io/burt/jmespath/jacksonjr/JacksonJrRuntime.java b/jmespath-jackson-jr/src/main/java/io/burt/jmespath/jacksonjr/JacksonJrRuntime.java index c836220..749fe2a 100644 --- a/jmespath-jackson-jr/src/main/java/io/burt/jmespath/jacksonjr/JacksonJrRuntime.java +++ b/jmespath-jackson-jr/src/main/java/io/burt/jmespath/jacksonjr/JacksonJrRuntime.java @@ -1,7 +1,6 @@ package io.burt.jmespath.jacksonjr; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.jr.ob.JSON; import com.fasterxml.jackson.jr.stree.JacksonJrsTreeCodec; import com.fasterxml.jackson.jr.stree.JrsArray; @@ -15,6 +14,7 @@ import io.burt.jmespath.JmesPathType; import io.burt.jmespath.RuntimeConfiguration; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.AbstractList; import java.util.ArrayList; import java.util.Collection; @@ -24,8 +24,9 @@ import java.util.List; import java.util.Map; -public class JacksonJrRuntime extends BaseRuntime { +public class JacksonJrRuntime extends BaseRuntime { private final JSON json; + public JacksonJrRuntime() { this(RuntimeConfiguration.defaultConfiguration()); } @@ -35,13 +36,14 @@ public JacksonJrRuntime(RuntimeConfiguration configuration) { .treeCodec(new JacksonJrsTreeCodec()) .build()); } + public JacksonJrRuntime(RuntimeConfiguration configuration, JSON json) { super(configuration); this.json = json; } @Override - public TreeNode parseString(String str) { + public JrsValue parseString(String str) { try { return json.treeFrom(str); } catch (IOException e) { @@ -49,7 +51,7 @@ public TreeNode parseString(String str) { } } - private static class JrsArrayListWrapper extends AbstractList { + private static class JrsArrayListWrapper extends AbstractList { private final JrsArray array; JrsArrayListWrapper(JrsArray array) { @@ -57,7 +59,7 @@ private static class JrsArrayListWrapper extends AbstractList { } @Override - public TreeNode get(int index) { + public JrsValue get(int index) { return array.get(index); } @@ -68,19 +70,18 @@ public int size() { } @Override - public List toList(TreeNode value) { + public List toList(JrsValue value) { if (value == null) { return Collections.emptyList(); - } - if (value.isArray()) { + } else if (value.isArray()) { return new JrsArrayListWrapper((JrsArray) value); } else if (value.isObject()) { JrsObject object = (JrsObject) value; - List list = new ArrayList<>(object.size()); + List list = new ArrayList<>(object.size()); Iterator> iterator = object.fields(); while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); + Map.Entry entry = iterator.next(); list.add(entry.getValue()); } return list; @@ -90,50 +91,54 @@ public List toList(TreeNode value) { } @Override - public String toString(TreeNode value) { - if (value.asToken().equals(JsonToken.VALUE_STRING)) { - return ((JrsString) value).asText(); + public String toString(JrsValue value) { + if (JsonToken.VALUE_STRING.equals(value.asToken())) { + return value.asText(); } else { try { return json.asString(value); } catch (IOException e) { - return ""; + throw new UncheckedIOException(e); } } } @Override - public Number toNumber(TreeNode value) { - if (value.isValueNode() && ((JrsValue) value).isNumber()) { + public Number toNumber(JrsValue value) { + if (value.isValueNode() && value.isNumber()) { JrsNumber number = (JrsNumber) value; return number.getValue(); - } else return null; + } else { + return null; + } } @Override - public boolean isTruthy(TreeNode value) { - // false, null, empty lists, empty objects, empty strings. + public boolean isTruthy(JrsValue value) { if (value.isContainerNode()) { return value.size() > 0; } else if (value.isValueNode()) { - if (value.asToken().equals(JsonToken.VALUE_STRING)) { - return !((JrsString) value).asText().isEmpty(); - } else return !value.asToken().equals(JsonToken.VALUE_FALSE) && - !value.asToken().equals(JsonToken.VALUE_NULL); + switch (value.asToken()) { + case VALUE_STRING: + return !value.asText().isEmpty(); + case VALUE_FALSE: + case VALUE_NULL: + return false; + default: + return true; + } } else { return !value.isMissingNode(); } } @Override - public JmesPathType typeOf(TreeNode value) { + public JmesPathType typeOf(JrsValue value) { switch (value.asToken()) { case START_ARRAY: - case END_ARRAY: return JmesPathType.ARRAY; case VALUE_EMBEDDED_OBJECT: case START_OBJECT: - case END_OBJECT: return JmesPathType.OBJECT; case VALUE_STRING: return JmesPathType.STRING; @@ -152,19 +157,19 @@ public JmesPathType typeOf(TreeNode value) { } @Override - public TreeNode getProperty(TreeNode value, TreeNode name) { - if (value == null || value.asToken().equals(JsonToken.VALUE_NULL)) { + public JrsValue getProperty(JrsValue value, JrsValue name) { + if (JsonToken.VALUE_NULL.equals(value.asToken())) { return JrsNull.instance(); } else { - TreeNode node = value.get(((JrsString) name).asText()); + JrsValue node = value.get(name.asText()); return node != null ? node : createNull(); } } @Override - public Collection getPropertyNames(TreeNode value) { - if (value != null && value.isObject()) { - List names = new ArrayList<>(value.size()); + public Collection getPropertyNames(JrsValue value) { + if (value.isObject()) { + List names = new ArrayList<>(value.size()); Iterator fieldNames = value.fieldNames(); while (fieldNames.hasNext()) { names.add(createString(fieldNames.next())); @@ -176,18 +181,18 @@ public Collection getPropertyNames(TreeNode value) { } @Override - public TreeNode createNull() { + public JrsValue createNull() { return JrsNull.instance(); } @Override - public TreeNode createArray(Collection elements) { + public JrsValue createArray(Collection elements) { List values = new ArrayList<>(); - for (TreeNode node: elements) { + for (JrsValue node: elements) { if (node == null) { values.add(JrsNull.instance()); } else { - values.add((JrsValue) node); + values.add(node); } } return new JrsArray(values); @@ -195,31 +200,31 @@ public TreeNode createArray(Collection elements) { } @Override - public TreeNode createString(String str) { + public JrsValue createString(String str) { return new JrsString(str); } @Override - public TreeNode createBoolean(boolean b) { + public JrsValue createBoolean(boolean b) { return b ? JrsBoolean.TRUE : JrsBoolean.FALSE; } @Override - public TreeNode createObject(Map obj) { + public JrsValue createObject(Map obj) { Map values = new HashMap<>(); - for (Map.Entry entry : obj.entrySet()) { - values.put(((JrsString)entry.getKey()).asText(), (JrsValue) entry.getValue()); + for (Map.Entry entry : obj.entrySet()) { + values.put(entry.getKey().asText(), entry.getValue()); } return new JrsObject(values); } @Override - public TreeNode createNumber(double n) { + public JrsValue createNumber(double n) { return new JrsNumber(n); } @Override - public TreeNode createNumber(long n) { + public JrsValue createNumber(long n) { return new JrsNumber(n); } } diff --git a/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrComplianceTest.java b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrComplianceTest.java index 3e7eea5..040f129 100644 --- a/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrComplianceTest.java +++ b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrComplianceTest.java @@ -1,12 +1,12 @@ package io.burt.jmespath.jacksonjr; -import com.fasterxml.jackson.core.TreeNode; +import com.fasterxml.jackson.jr.stree.JrsValue; import io.burt.jmespath.Adapter; import io.burt.jmespath.JmesPathComplianceTest; -public class JacksonJrComplianceTest extends JmesPathComplianceTest { - private Adapter runtime = new JacksonJrRuntime(); +public class JacksonJrComplianceTest extends JmesPathComplianceTest { + private Adapter runtime = new JacksonJrRuntime(); @Override - protected Adapter runtime() { return runtime; } + protected Adapter runtime() { return runtime; } } diff --git a/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrTest.java b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrTest.java index 8dbaa37..2c1004f 100644 --- a/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrTest.java +++ b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrTest.java @@ -1,14 +1,14 @@ package io.burt.jmespath.jacksonjr; -import com.fasterxml.jackson.core.TreeNode; +import com.fasterxml.jackson.jr.stree.JrsValue; import io.burt.jmespath.Adapter; import io.burt.jmespath.JmesPathRuntimeTest; import io.burt.jmespath.RuntimeConfiguration; -public class JacksonJrTest extends JmesPathRuntimeTest { +public class JacksonJrTest extends JmesPathRuntimeTest { @Override - protected Adapter createRuntime(RuntimeConfiguration configuration) { + protected Adapter createRuntime(RuntimeConfiguration configuration) { return new JacksonJrRuntime(configuration); } } From 7e3129769dfd48ca717b23d24918c489b1c6b27c Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 24 Oct 2023 13:45:57 +0200 Subject: [PATCH 08/22] Remove the Travis CI config We're not using Travis anymore --- .travis.yml | 9 --------- README.md | 2 -- 2 files changed, 11 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 33f5082..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -dist: trusty -language: java -jdk: - - oraclejdk8 -cache: - directories: - - $HOME/.m2 -before_install: - - git submodule update --init --recursive diff --git a/README.md b/README.md index ccef416..fd72e74 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # jmespath-java -[![Build Status](https://travis-ci.org/burtcorp/jmespath-java.png?branch=master)](https://travis-ci.org/burtcorp/jmespath-java) - _If you're reading this on GitHub, please note that this is the readme for the development version and that some features described here might not yet have been released. You can find the readme for a specific version via the release tags ([here is an example](https://github.com/burtcorp/jmespath-java/releases/tag/jmespath-0.1.0))._ This is an implementation of [JMESPath](http://jmespath.org/) for Java and it supports searching JSON documents (via [Jackson](https://github.com/FasterXML/jackson) or [Gson](https://github.com/google/gson)) and structures containing basic Java objects (`Map`, `List`, `String`, etc.) – but can also be extended to work with any JSON-like structure. From 6c0d7385a91b2f4796c82ca489f17f7e8b411bf4 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 24 Oct 2023 14:04:20 +0200 Subject: [PATCH 09/22] Update the project to use Java 8 It's been EOL for a while, but we don't need any higher version and it's still a common target. --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 451718a..c38560c 100644 --- a/pom.xml +++ b/pom.xml @@ -109,8 +109,8 @@ -Xlint:deprecation -Xlint:unchecked - 7 - 7 + 8 + 8 From 01b473cf20f5ed9107739567b2118af127083039 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 24 Oct 2023 14:18:59 +0200 Subject: [PATCH 10/22] Update dependencies to the latest compatible versions ANTLR >4.10 requires a newer version of Java than 8. --- jmespath-core/pom.xml | 4 ++++ jmespath-gson/pom.xml | 4 ++++ jmespath-jackson/pom.xml | 4 ++++ jmespath-jakarta-jsonp/pom.xml | 4 ++++ jmespath-vertx/pom.xml | 4 ++++ pom.xml | 7 +------ 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/jmespath-core/pom.xml b/jmespath-core/pom.xml index 13b981c..eaa2f89 100644 --- a/jmespath-core/pom.xml +++ b/jmespath-core/pom.xml @@ -13,6 +13,10 @@ 0.5.2-SNAPSHOT + + 4.9.3 + + org.antlr diff --git a/jmespath-gson/pom.xml b/jmespath-gson/pom.xml index dc40e68..74736b2 100644 --- a/jmespath-gson/pom.xml +++ b/jmespath-gson/pom.xml @@ -13,6 +13,10 @@ 0.5.2-SNAPSHOT + + 2.10.1 + + ${project.groupId} diff --git a/jmespath-jackson/pom.xml b/jmespath-jackson/pom.xml index 19725e7..da3900c 100644 --- a/jmespath-jackson/pom.xml +++ b/jmespath-jackson/pom.xml @@ -13,6 +13,10 @@ 0.5.2-SNAPSHOT + + 2.15.3 + + ${project.groupId} diff --git a/jmespath-jakarta-jsonp/pom.xml b/jmespath-jakarta-jsonp/pom.xml index 5e2ca26..f46d789 100644 --- a/jmespath-jakarta-jsonp/pom.xml +++ b/jmespath-jakarta-jsonp/pom.xml @@ -13,6 +13,10 @@ 0.5.2-SNAPSHOT + + 1.1.6 + + ${project.groupId} diff --git a/jmespath-vertx/pom.xml b/jmespath-vertx/pom.xml index 4867611..e8a3180 100644 --- a/jmespath-vertx/pom.xml +++ b/jmespath-vertx/pom.xml @@ -13,6 +13,10 @@ 0.5.2-SNAPSHOT + + 4.4.6 + + ${project.groupId} diff --git a/pom.xml b/pom.xml index c38560c..180274b 100644 --- a/pom.xml +++ b/pom.xml @@ -13,13 +13,8 @@ https://github.com/burtcorp/jmespath-java - 4.13.1 + 4.13.2 1.3 - 2.9.9 - 1.1.6 - 2.8.5 - 4.7.2 - 3.7.1 UTF-8 From ae96185d09e6a4abe87296d4ca75402e87920e88 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 24 Oct 2023 15:17:33 +0200 Subject: [PATCH 11/22] Update the readme to not focus only on Jackson and Gson There are many more adapters now --- README.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index fd72e74..e3059ac 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,30 @@ # jmespath-java -_If you're reading this on GitHub, please note that this is the readme for the development version and that some features described here might not yet have been released. You can find the readme for a specific version via the release tags ([here is an example](https://github.com/burtcorp/jmespath-java/releases/tag/jmespath-0.1.0))._ +_If you're reading this on GitHub, please note that this is the readme for the development version and that some features described here might not yet have been released. You can find the readme for a specific version via the release tags ([here is an example](https://github.com/burtcorp/jmespath-java/releases/tag/jmespath-0.5.0))._ -This is an implementation of [JMESPath](http://jmespath.org/) for Java and it supports searching JSON documents (via [Jackson](https://github.com/FasterXML/jackson) or [Gson](https://github.com/google/gson)) and structures containing basic Java objects (`Map`, `List`, `String`, etc.) – but can also be extended to work with any JSON-like structure. +This is an implementation of [JMESPath](http://jmespath.org/) for Java. It supports multiple JSON libraries, for example [Jackson](https://github.com/FasterXML/jackson), [Jackson jr](https://github.com/FasterXML/jackson-jr), [Gson](https://github.com/google/gson), and structures containing basic Java objects (`Map`, `List`, `String`, etc.). It can be extended to support any JSON-like structure through a simple adapter. ## Installation -Using Maven you can add this to your dependencies: +You can install the library using Maven: ```xml io.burt - jmespath + ${jmespath.adapter} ${jmespath.version} ``` -Check the [releases page](https://github.com/burtcorp/jmespath-java/releases) for the value of `${jmespath.version}`. +Replace `${jmespath.adapter}` with the adapter you need for your project, for example `jmespath-jackson` or `jmespath-gson`. You can also use `jmespath-core` if you are going to implement your own adapter in your project. -If you don't want both the Jackson and Gson implementations you can change it to `jmespath-jackson` or `jmespath-gson`. Some time before 1.0 the dependencies will probably be reversed so that `jmespath` will not depend on the specific runtimes, so you unless you have the need for multiple runtimes you should depend on the specific runtime you need. +Replace `${jmespath.version}` with the latest version from the [releases page](https://github.com/burtcorp/jmespath-java/releases). ### Dependencies `jmespath-core` has an ANTLR based parser, but the ANTLR runtime artifact has been shaded into the `io.burt.jmespath` package to avoid conflicts with other artifacts that may depend on ANTLR. This means that `jmespath-core` has no external dependencies. -`jmespath-jackson` obviously depends on Jackson, specifically Jackson DataBind (`com.fasterxml.jackson.core:jackson-databind`), but other than that it only depends on `jmespath-core`. - -`jmespath-gson` depends on Gson, specifically `com.google.code.gson:gson`, but other than that only `jmespath-core`. +The adapters each depend on their supporting libraries, for example Jackson Databind for `jmespath-jackson`. ## Basic usage @@ -57,7 +55,7 @@ JsonNode result = expression.search(input); ## Description -`jmespath-java` comes in three parts: `jmespath-core`, `jmespath-jackson`, and `jmespath-gson`. The former contains the expression parser, core runtime, default functions and a simple runtime adapter that can search structures made up from numbers, strings, booleans, `List` and `Map` available as `io.burt.jmespath.jcf.JcfRuntime` (for "Java Collections Framework"). The latter contains the Jackson and Gson runtime adapters, respectively, and is what you should be using most of the time. The JCF runtime is just for internal development and testing. It primarily exists to test that there's nothing runtime-specific in the implementation. +`jmespath-java` comes in multiple parts: `jmespath-core`, and the adapters for different JSON libraries, like `jmespath-jackson`, and `jmespath-gson`. `jmespath-core` contains the expression parser, core runtime, default functions and a simple runtime adapter that can search structures made up from numbers, strings, booleans, `List` and `Map` available as `io.burt.jmespath.jcf.JcfRuntime` (for "Java Collections Framework"). The latter contains runtime adapters for each specific JSON library, and is what you should be using most of the time. The JCF runtime is just for internal development and testing. It primarily exists to test that there's nothing runtime-specific in the implementation. ## Configuration From c78e8adcd4cb99d7d6766f2a7887cf44708f93ba Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 24 Oct 2023 15:18:02 +0200 Subject: [PATCH 12/22] Update the copyright statement Burt is now Burt Intelligence, and the copyright belongs to each contributor --- LICENSE.txt | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index a9c80ed..ba3d5d2 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2016, Burt AB +Copyright (c) 2016, Burt Intelligence AB and contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index e3059ac..d543992 100644 --- a/README.md +++ b/README.md @@ -173,4 +173,4 @@ And all dependencies should be installed, the code compiled and the tests run. # Copyright -© 2016-2018 Burt AB, see LICENSE.txt (BSD 3-Clause). +© 2016 Burt Intelligence AB and contributors, see LICENSE.txt (BSD 3-Clause). From e673d0819ccec34d48de4ea2a2ada584bc9396ad Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 24 Oct 2023 15:22:40 +0200 Subject: [PATCH 13/22] Move dependency versions to property declarations This makes it easier to get an overview of what versions we use --- jmespath-jackson-jr/pom.xml | 8 ++++++-- jmespath-kotlinx/pom.xml | 11 +++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/jmespath-jackson-jr/pom.xml b/jmespath-jackson-jr/pom.xml index 7362efb..9d916da 100644 --- a/jmespath-jackson-jr/pom.xml +++ b/jmespath-jackson-jr/pom.xml @@ -14,6 +14,10 @@ 0.5.2-SNAPSHOT + + 2.14.2 + + ${project.groupId} @@ -30,12 +34,12 @@ com.fasterxml.jackson.jr jackson-jr-objects - 2.14.2 + ${jackson-jr.version} com.fasterxml.jackson.jr jackson-jr-stree - 2.14.2 + ${jackson-jr.version} diff --git a/jmespath-kotlinx/pom.xml b/jmespath-kotlinx/pom.xml index a39cd78..3cffa7c 100644 --- a/jmespath-kotlinx/pom.xml +++ b/jmespath-kotlinx/pom.xml @@ -12,6 +12,11 @@ 0.5.2-SNAPSHOT + + 1.6.0 + 1.4.1 + + ${project.groupId} @@ -33,9 +38,10 @@ org.jetbrains.kotlinx kotlinx-serialization-json - 1.4.1 + ${kotlinx.version} + @@ -66,7 +72,4 @@ - - 1.6.0 - From b673441a55ebb94f9676512c1e9d0b3c8d17f5b9 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 24 Oct 2023 15:38:20 +0200 Subject: [PATCH 14/22] Use Hamcrest syntax for the compliance tests Not sure why this wasn't the case already, my IDE complained about the syntax --- .../test/java/io/burt/jmespath/JmesPathComplianceTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jmespath-core/src/test/java/io/burt/jmespath/JmesPathComplianceTest.java b/jmespath-core/src/test/java/io/burt/jmespath/JmesPathComplianceTest.java index 5f6495d..8207529 100644 --- a/jmespath-core/src/test/java/io/burt/jmespath/JmesPathComplianceTest.java +++ b/jmespath-core/src/test/java/io/burt/jmespath/JmesPathComplianceTest.java @@ -18,7 +18,7 @@ import org.junit.runner.RunWith; import org.hamcrest.Matcher; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.hamcrest.Matchers.containsString; @@ -72,9 +72,10 @@ public void run() { Expression compiledExpression = runtime.compile(expression); U result = compiledExpression.search(input); if (expectedError == null) { - assertTrue( + assertThat( String.format("Expected <%s> to be <%s>, expression <%s> compiled expression <%s>", result, expectedResult, expression, compiledExpression), - runtime.compare(expectedResult, result) == 0 + runtime.compare(expectedResult, result), + is(0) ); } else { fail(String.format("Expected \"%s\" error", expectedError)); From fd1ab5323a88e78ae8caf039140b669b7b3df5d8 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 24 Oct 2023 15:55:53 +0200 Subject: [PATCH 15/22] Make the adapter variable final in the compliance tests This is not strictly necessary, but the IDE was complaining --- .../src/test/java/io/burt/jmespath/JmesPathRuntimeTest.java | 2 +- .../src/test/java/io/burt/jmespath/jcf/JcfComplianceTest.java | 2 +- .../src/test/java/io/burt/jmespath/gson/GsonComplianceTest.java | 2 +- .../java/io/burt/jmespath/jackson/JacksonComplianceTest.java | 2 +- .../io/burt/jmespath/jakarta/jsonp/JsonpComplianceTest.java | 2 +- .../test/java/io/burt/jmespath/vertx/VertxComplianceTest.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jmespath-core/src/test/java/io/burt/jmespath/JmesPathRuntimeTest.java b/jmespath-core/src/test/java/io/burt/jmespath/JmesPathRuntimeTest.java index c3a754a..bb68430 100644 --- a/jmespath-core/src/test/java/io/burt/jmespath/JmesPathRuntimeTest.java +++ b/jmespath-core/src/test/java/io/burt/jmespath/JmesPathRuntimeTest.java @@ -31,7 +31,7 @@ import static org.hamcrest.Matchers.containsString; public abstract class JmesPathRuntimeTest { - private Adapter runtime = createRuntime(RuntimeConfiguration.defaultConfiguration()); + private final Adapter runtime = createRuntime(RuntimeConfiguration.defaultConfiguration()); protected T contact; protected T cloudtrail; diff --git a/jmespath-core/src/test/java/io/burt/jmespath/jcf/JcfComplianceTest.java b/jmespath-core/src/test/java/io/burt/jmespath/jcf/JcfComplianceTest.java index 8bf537c..66a3be4 100644 --- a/jmespath-core/src/test/java/io/burt/jmespath/jcf/JcfComplianceTest.java +++ b/jmespath-core/src/test/java/io/burt/jmespath/jcf/JcfComplianceTest.java @@ -4,7 +4,7 @@ import io.burt.jmespath.Adapter; public class JcfComplianceTest extends JmesPathComplianceTest { - private Adapter runtime = new JcfRuntime(); + private final Adapter runtime = new JcfRuntime(); @Override protected Adapter runtime() { return runtime; } diff --git a/jmespath-gson/src/test/java/io/burt/jmespath/gson/GsonComplianceTest.java b/jmespath-gson/src/test/java/io/burt/jmespath/gson/GsonComplianceTest.java index 2bdf722..e3ec8ac 100644 --- a/jmespath-gson/src/test/java/io/burt/jmespath/gson/GsonComplianceTest.java +++ b/jmespath-gson/src/test/java/io/burt/jmespath/gson/GsonComplianceTest.java @@ -5,7 +5,7 @@ import io.burt.jmespath.JmesPathComplianceTest; public class GsonComplianceTest extends JmesPathComplianceTest { - private Adapter runtime = new GsonRuntime(); + private final Adapter runtime = new GsonRuntime(); @Override protected Adapter runtime() { diff --git a/jmespath-jackson/src/test/java/io/burt/jmespath/jackson/JacksonComplianceTest.java b/jmespath-jackson/src/test/java/io/burt/jmespath/jackson/JacksonComplianceTest.java index 03500ab..5d8913b 100644 --- a/jmespath-jackson/src/test/java/io/burt/jmespath/jackson/JacksonComplianceTest.java +++ b/jmespath-jackson/src/test/java/io/burt/jmespath/jackson/JacksonComplianceTest.java @@ -6,7 +6,7 @@ import io.burt.jmespath.Adapter; public class JacksonComplianceTest extends JmesPathComplianceTest { - private Adapter runtime = new JacksonRuntime(); + private final Adapter runtime = new JacksonRuntime(); @Override protected Adapter runtime() { return runtime; } diff --git a/jmespath-jakarta-jsonp/src/test/java/io/burt/jmespath/jakarta/jsonp/JsonpComplianceTest.java b/jmespath-jakarta-jsonp/src/test/java/io/burt/jmespath/jakarta/jsonp/JsonpComplianceTest.java index 88dd53d..1f25777 100644 --- a/jmespath-jakarta-jsonp/src/test/java/io/burt/jmespath/jakarta/jsonp/JsonpComplianceTest.java +++ b/jmespath-jakarta-jsonp/src/test/java/io/burt/jmespath/jakarta/jsonp/JsonpComplianceTest.java @@ -6,7 +6,7 @@ import javax.json.JsonValue; public class JsonpComplianceTest extends JmesPathComplianceTest { - private Adapter runtime = new JsonpRuntime(); + private final Adapter runtime = new JsonpRuntime(); @Override protected Adapter runtime() { return runtime; } diff --git a/jmespath-vertx/src/test/java/io/burt/jmespath/vertx/VertxComplianceTest.java b/jmespath-vertx/src/test/java/io/burt/jmespath/vertx/VertxComplianceTest.java index 5175a75..b0f5113 100644 --- a/jmespath-vertx/src/test/java/io/burt/jmespath/vertx/VertxComplianceTest.java +++ b/jmespath-vertx/src/test/java/io/burt/jmespath/vertx/VertxComplianceTest.java @@ -4,7 +4,7 @@ import io.burt.jmespath.Adapter; public class VertxComplianceTest extends JmesPathComplianceTest { - private Adapter runtime = new VertxRuntime(); + private final Adapter runtime = new VertxRuntime(); @Override protected Adapter runtime() { return runtime; } From b37d735036ee0d5937523ab53f0fb976501e1d40 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 24 Oct 2023 15:56:16 +0200 Subject: [PATCH 16/22] Prefer #isEmpty over #size/#length > 0 --- .../src/main/java/io/burt/jmespath/gson/GsonRuntime.java | 6 +++--- .../main/java/io/burt/jmespath/jackson/JacksonRuntime.java | 4 ++-- .../java/io/burt/jmespath/jakarta/jsonp/JsonpRuntime.java | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/jmespath-gson/src/main/java/io/burt/jmespath/gson/GsonRuntime.java b/jmespath-gson/src/main/java/io/burt/jmespath/gson/GsonRuntime.java index 59cd868..a3713f0 100644 --- a/jmespath-gson/src/main/java/io/burt/jmespath/gson/GsonRuntime.java +++ b/jmespath-gson/src/main/java/io/burt/jmespath/gson/GsonRuntime.java @@ -91,13 +91,13 @@ public boolean isTruthy(JsonElement value) { case BOOLEAN: return value.getAsBoolean(); case STRING: - return value.getAsString().length() > 0; + return !value.getAsString().isEmpty(); case NUMBER: return true; case ARRAY: - return value.getAsJsonArray().size() > 0; + return !value.getAsJsonArray().isEmpty(); case OBJECT: - return value.getAsJsonObject().size() > 0; + return !value.getAsJsonObject().isEmpty(); } throw new IllegalStateException(String.format("Unknown node type encountered: %s", value.getClass())); } diff --git a/jmespath-jackson/src/main/java/io/burt/jmespath/jackson/JacksonRuntime.java b/jmespath-jackson/src/main/java/io/burt/jmespath/jackson/JacksonRuntime.java index 3b05037..1bb9bc6 100644 --- a/jmespath-jackson/src/main/java/io/burt/jmespath/jackson/JacksonRuntime.java +++ b/jmespath-jackson/src/main/java/io/burt/jmespath/jackson/JacksonRuntime.java @@ -97,9 +97,9 @@ public boolean isTruthy(JsonNode value) { case ARRAY: case BINARY: case OBJECT: - return value.size() > 0; + return !value.isEmpty(); case STRING: - return value.textValue().length() > 0; + return !value.textValue().isEmpty(); case BOOLEAN: return value.booleanValue(); case MISSING: diff --git a/jmespath-jakarta-jsonp/src/main/java/io/burt/jmespath/jakarta/jsonp/JsonpRuntime.java b/jmespath-jakarta-jsonp/src/main/java/io/burt/jmespath/jakarta/jsonp/JsonpRuntime.java index 2daf601..975002c 100644 --- a/jmespath-jakarta-jsonp/src/main/java/io/burt/jmespath/jakarta/jsonp/JsonpRuntime.java +++ b/jmespath-jakarta-jsonp/src/main/java/io/burt/jmespath/jakarta/jsonp/JsonpRuntime.java @@ -110,11 +110,11 @@ public boolean isTruthy(JsonValue value) { case TRUE: return true; case ARRAY: - return ((JsonArray) value).size() > 0; + return !((JsonArray) value).isEmpty(); case OBJECT: - return ((JsonObject) value).size() > 0; + return !((JsonObject) value).isEmpty(); case STRING: - return ((JsonString) value).getString().length() > 0; + return !((JsonString) value).getString().isEmpty(); default: throw new IllegalStateException(String.format("Unknown node type encountered: %s", value.getValueType())); } From 88bd640bd26c64a4c7cc3d67233ac40abb295450 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 24 Oct 2023 15:56:40 +0200 Subject: [PATCH 17/22] Change from Arrays.asList to Collections.singletonList Because this is something IDEs care about --- jmespath-core/src/test/java/io/burt/jmespath/jcf/JcfTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jmespath-core/src/test/java/io/burt/jmespath/jcf/JcfTest.java b/jmespath-core/src/test/java/io/burt/jmespath/jcf/JcfTest.java index 33aeaf7..0ffe03b 100644 --- a/jmespath-core/src/test/java/io/burt/jmespath/jcf/JcfTest.java +++ b/jmespath-core/src/test/java/io/burt/jmespath/jcf/JcfTest.java @@ -20,6 +20,6 @@ public class JcfTest extends JmesPathRuntimeTest { @Test public void toListReturnsAListWhenGivenAnotherTypeOfCollection() { List list = runtime().toList(Collections.singleton(parse("1"))); - assertThat(list, is(Arrays.asList(parse("1")))); + assertThat(list, is(Collections.singletonList(parse("1")))); } } From 4f8bad7a616411d567483ffe5e8ffcd400ce4703 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 24 Oct 2023 15:56:56 +0200 Subject: [PATCH 18/22] Change to Java 8 catch syntax with multiple exception types --- .../test/java/io/burt/jmespath/ComplianceRunner.java | 10 +++------- .../java/io/burt/jmespath/JmesPathComplianceTest.java | 6 ++---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/jmespath-core/src/test/java/io/burt/jmespath/ComplianceRunner.java b/jmespath-core/src/test/java/io/burt/jmespath/ComplianceRunner.java index 31277f9..cdbf80e 100644 --- a/jmespath-core/src/test/java/io/burt/jmespath/ComplianceRunner.java +++ b/jmespath-core/src/test/java/io/burt/jmespath/ComplianceRunner.java @@ -29,10 +29,8 @@ private Description createDescription(JmesPathComplianceTest.ComplianceTest c private Collection> getAllTests() { try { return testClass.newInstance().getAllTests(); - } catch (InstantiationException ie) { - throw new RuntimeException("Could not instantiate runtime", ie); - } catch (IllegalAccessException iae) { - throw new RuntimeException("Could not instantiate runtime", iae); + } catch (InstantiationException | IllegalAccessException e) { + throw new RuntimeException("Could not instantiate runtime", e); } } @@ -42,9 +40,7 @@ public void run(RunNotifier notifier) { notifier.fireTestStarted(testDescription); try { complianceTest.run(); - } catch (AssertionError ae) { - notifier.fireTestFailure(new Failure(testDescription, ae)); - } catch (Exception e) { + } catch (AssertionError | Exception e) { notifier.fireTestFailure(new Failure(testDescription, e)); } finally { notifier.fireTestFinished(testDescription); diff --git a/jmespath-core/src/test/java/io/burt/jmespath/JmesPathComplianceTest.java b/jmespath-core/src/test/java/io/burt/jmespath/JmesPathComplianceTest.java index 8207529..2050dc5 100644 --- a/jmespath-core/src/test/java/io/burt/jmespath/JmesPathComplianceTest.java +++ b/jmespath-core/src/test/java/io/burt/jmespath/JmesPathComplianceTest.java @@ -137,10 +137,8 @@ public Iterable getFeatureNames() { } } return featureNames; - } catch (IOException ioe) { - throw new RuntimeException("Could not load compliance feature names", ioe); - } catch (URISyntaxException use) { - throw new RuntimeException("Could not load compliance feature names", use); + } catch (IOException | URISyntaxException e) { + throw new RuntimeException("Could not load compliance feature names", e); } } From b7f1606d42e147857d0d9c6e2543d5858a6cb6b8 Mon Sep 17 00:00:00 2001 From: Theo Date: Thu, 26 Oct 2023 11:19:30 +0200 Subject: [PATCH 19/22] Revert "Merge pull request #75 from shuklaabhi/kotlinx-support" This reverts commit 2e4af851601af5467da275c024d2411929f64877, reversing changes made to bfb49f7d9628ed31af2751569299279b01adbfed. This adapter couldn't be released to Maven central because it did not generate Javadocs. I don't have the time to figure out how to work around it for this release and instead I'm going to remove it. --- jmespath-kotlinx/pom.xml | 75 ------------ .../burt/jmespath/kotlinx/KotlinxRuntime.kt | 112 ------------------ .../jmespath/kotlinx/KotlinxComplianceTest.kt | 10 -- .../io/burt/jmespath/kotlinx/KotlinxTest.kt | 10 -- pom.xml | 1 - 5 files changed, 208 deletions(-) delete mode 100644 jmespath-kotlinx/pom.xml delete mode 100644 jmespath-kotlinx/src/main/java/io/burt/jmespath/kotlinx/KotlinxRuntime.kt delete mode 100644 jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxComplianceTest.kt delete mode 100644 jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxTest.kt diff --git a/jmespath-kotlinx/pom.xml b/jmespath-kotlinx/pom.xml deleted file mode 100644 index 3cffa7c..0000000 --- a/jmespath-kotlinx/pom.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - 4.0.0 - jmespath-kotlinx - JMESPath Kotlinx - A JMESPath implementation with kotlinx - - - io.burt - jmespath - 0.5.2-SNAPSHOT - - - - 1.6.0 - 1.4.1 - - - - - ${project.groupId} - jmespath-core - ${project.parent.version} - - - ${project.groupId} - jmespath-core - ${project.parent.version} - test-jar - test - - - org.jetbrains.kotlin - kotlin-stdlib - ${kotlin.version} - - - org.jetbrains.kotlinx - kotlinx-serialization-json - ${kotlinx.version} - - - - - - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin.version} - - - compile - compile - - compile - - - - - - kotlinx-serialization - - - - - org.jetbrains.kotlin - kotlin-maven-serialization - ${kotlin.version} - - - - - - diff --git a/jmespath-kotlinx/src/main/java/io/burt/jmespath/kotlinx/KotlinxRuntime.kt b/jmespath-kotlinx/src/main/java/io/burt/jmespath/kotlinx/KotlinxRuntime.kt deleted file mode 100644 index 7c563f4..0000000 --- a/jmespath-kotlinx/src/main/java/io/burt/jmespath/kotlinx/KotlinxRuntime.kt +++ /dev/null @@ -1,112 +0,0 @@ -package io.burt.jmespath.kotlinx - -import io.burt.jmespath.BaseRuntime -import io.burt.jmespath.JmesPathType -import io.burt.jmespath.RuntimeConfiguration -import kotlinx.serialization.ExperimentalSerializationApi -import kotlinx.serialization.json.Json -import kotlinx.serialization.json.JsonArray -import kotlinx.serialization.json.JsonElement -import kotlinx.serialization.json.JsonNull -import kotlinx.serialization.json.JsonObject -import kotlinx.serialization.json.JsonPrimitive -import kotlinx.serialization.json.boolean -import kotlinx.serialization.json.booleanOrNull -import kotlinx.serialization.json.doubleOrNull -import kotlinx.serialization.json.encodeToJsonElement -import kotlinx.serialization.json.jsonArray -import kotlinx.serialization.json.jsonObject -import kotlinx.serialization.json.jsonPrimitive - - -@OptIn(ExperimentalSerializationApi::class) -class KotlinRuntime(configuration: RuntimeConfiguration, private val json: Json) : - BaseRuntime(configuration) { - - - constructor() : this(RuntimeConfiguration.defaultConfiguration(), Json { - encodeDefaults = true - explicitNulls = true - }) - - constructor(configuration: RuntimeConfiguration) : this(configuration, Json { - encodeDefaults = true - explicitNulls = true - }) - - override fun toString(value: JsonElement) = value.jsonPrimitive.content - - override fun parseString(str: String): JsonElement { - return json.parseToJsonElement(str) - } - - override fun createNull(): JsonElement { - return JsonNull - } - - override fun createString(str: String): JsonElement { - return json.parseToJsonElement(str) - } - - override fun createBoolean(b: Boolean): JsonElement { - return JsonPrimitive(b) - } - - override fun createNumber(n: Double): JsonElement { - return JsonPrimitive(n) - } - - override fun createNumber(n: Long): JsonElement { - return JsonPrimitive(n) - } - - override fun createObject(obj: MutableMap?): JsonElement { - return json.encodeToJsonElement(obj) - } - - override fun createArray(elements: MutableCollection): JsonElement { - return JsonArray(elements.toList()) - } - - override fun getPropertyNames(value: JsonElement): Collection { - return if (value is JsonObject) { - value.jsonObject.keys.map { JsonPrimitive(it) } - } else - emptyList() - } - - override fun getProperty(value: JsonElement, name: JsonElement): JsonElement { - return value.jsonObject[name.jsonPrimitive.content] ?: JsonNull - } - - override fun typeOf(value: JsonElement): JmesPathType { - return if (value == JsonNull) - JmesPathType.NULL - else if (value is JsonArray) - JmesPathType.ARRAY - else if (value is JsonObject) - JmesPathType.OBJECT - else if (value.jsonPrimitive.booleanOrNull != null) - JmesPathType.BOOLEAN - else if (value.jsonPrimitive.doubleOrNull != null) - JmesPathType.NUMBER - else - JmesPathType.STRING - } - - override fun isTruthy(value: JsonElement): Boolean { - return value.jsonPrimitive.jsonPrimitive.boolean - } - - override fun toNumber(value: JsonElement): Number { - return value.jsonPrimitive.content.toDouble() - } - - override fun toList(value: JsonElement?): List { - return when (value) { - is JsonArray -> value.jsonArray - is JsonObject -> value.values.toList() - else -> emptyList() - } - } -} diff --git a/jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxComplianceTest.kt b/jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxComplianceTest.kt deleted file mode 100644 index 1af1aaf..0000000 --- a/jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxComplianceTest.kt +++ /dev/null @@ -1,10 +0,0 @@ -package io.burt.jmespath.kotlinx - -import io.burt.jmespath.JmesPathComplianceTest -import io.burt.jmespath.Adapter -import io.burt.jmespath.RuntimeConfiguration -import kotlinx.serialization.json.JsonElement - -class KotlinxComplianceTest : JmesPathComplianceTest() { - override fun runtime(): Adapter = KotlinRuntime(RuntimeConfiguration.defaultConfiguration()) -} diff --git a/jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxTest.kt b/jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxTest.kt deleted file mode 100644 index 6a7025a..0000000 --- a/jmespath-kotlinx/src/test/java/io/burt/jmespath/kotlinx/KotlinxTest.kt +++ /dev/null @@ -1,10 +0,0 @@ -package io.burt.jmespath.kotlinx - - -import io.burt.jmespath.JmesPathRuntimeTest -import io.burt.jmespath.RuntimeConfiguration -import kotlinx.serialization.json.JsonElement - -class KotlinxTest : JmesPathRuntimeTest() { - override fun createRuntime(configuration: RuntimeConfiguration) = KotlinRuntime(configuration) -} diff --git a/pom.xml b/pom.xml index 180274b..ffc487e 100644 --- a/pom.xml +++ b/pom.xml @@ -55,7 +55,6 @@ jmespath-jakarta-jsonp jmespath-gson jmespath-vertx - jmespath-kotlinx From 15dd0141572c4c7f258823e183f47f367ed3fbf3 Mon Sep 17 00:00:00 2001 From: Theo Date: Thu, 26 Oct 2023 11:27:37 +0200 Subject: [PATCH 20/22] Update my name in the contributors list --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ffc487e..eb9058b 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ - Theo Hultberg + Theo Hultberg Tolv theo@burtcorp.com Burt http://burtcorp.com/ From 8bb8249ef273d44575f18299bb879cf481742385 Mon Sep 17 00:00:00 2001 From: Theo Date: Thu, 26 Oct 2023 11:27:54 +0200 Subject: [PATCH 21/22] Add the Jackson jr module to pom.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index eb9058b..f1363fd 100644 --- a/pom.xml +++ b/pom.xml @@ -52,6 +52,7 @@ jmespath-core jmespath-jackson + jmespath-jackson-jr jmespath-jakarta-jsonp jmespath-gson jmespath-vertx From 62ccff6190100aa335b6fa9314ec54da33e783e8 Mon Sep 17 00:00:00 2001 From: Theo Date: Thu, 26 Oct 2023 11:28:35 +0200 Subject: [PATCH 22/22] [maven-release-plugin] prepare release jmespath-0.6.0 --- jmespath-core/pom.xml | 2 +- jmespath-gson/pom.xml | 2 +- jmespath-jackson-jr/pom.xml | 6 ++---- jmespath-jackson/pom.xml | 2 +- jmespath-jakarta-jsonp/pom.xml | 2 +- jmespath-vertx/pom.xml | 2 +- pom.xml | 4 ++-- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/jmespath-core/pom.xml b/jmespath-core/pom.xml index eaa2f89..ab003a9 100644 --- a/jmespath-core/pom.xml +++ b/jmespath-core/pom.xml @@ -10,7 +10,7 @@ io.burt jmespath - 0.5.2-SNAPSHOT + 0.6.0 diff --git a/jmespath-gson/pom.xml b/jmespath-gson/pom.xml index 74736b2..1714543 100644 --- a/jmespath-gson/pom.xml +++ b/jmespath-gson/pom.xml @@ -10,7 +10,7 @@ io.burt jmespath - 0.5.2-SNAPSHOT + 0.6.0 diff --git a/jmespath-jackson-jr/pom.xml b/jmespath-jackson-jr/pom.xml index 9d916da..ae10d85 100644 --- a/jmespath-jackson-jr/pom.xml +++ b/jmespath-jackson-jr/pom.xml @@ -1,7 +1,5 @@ - + 4.0.0 jmespath-jackson-jr @@ -11,7 +9,7 @@ io.burt jmespath - 0.5.2-SNAPSHOT + 0.6.0 diff --git a/jmespath-jackson/pom.xml b/jmespath-jackson/pom.xml index da3900c..8237043 100644 --- a/jmespath-jackson/pom.xml +++ b/jmespath-jackson/pom.xml @@ -10,7 +10,7 @@ io.burt jmespath - 0.5.2-SNAPSHOT + 0.6.0 diff --git a/jmespath-jakarta-jsonp/pom.xml b/jmespath-jakarta-jsonp/pom.xml index f46d789..3bf991f 100644 --- a/jmespath-jakarta-jsonp/pom.xml +++ b/jmespath-jakarta-jsonp/pom.xml @@ -10,7 +10,7 @@ io.burt jmespath - 0.5.2-SNAPSHOT + 0.6.0 diff --git a/jmespath-vertx/pom.xml b/jmespath-vertx/pom.xml index e8a3180..c5cf5dc 100644 --- a/jmespath-vertx/pom.xml +++ b/jmespath-vertx/pom.xml @@ -10,7 +10,7 @@ io.burt jmespath - 0.5.2-SNAPSHOT + 0.6.0 diff --git a/pom.xml b/pom.xml index f1363fd..2683d44 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.burt jmespath - 0.5.2-SNAPSHOT + 0.6.0 pom JMESPath @@ -46,7 +46,7 @@ scm:git:ssh://git@github.com/burtcorp/jmespath-java.git scm:git:ssh://git@github.com/burtcorp/jmespath-java.git https://github.com/burtcorp/jmespath-java.git - jmespath-${project.version} + jmespath-0.6.0