diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 33f5082c..00000000 --- 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/LICENSE.txt b/LICENSE.txt index a9c80ed1..ba3d5d28 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 ccef4161..d543992c 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,30 @@ # 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.5.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.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. +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 @@ -59,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 @@ -177,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). diff --git a/jmespath-core/pom.xml b/jmespath-core/pom.xml index 06de939f..ab003a94 100644 --- a/jmespath-core/pom.xml +++ b/jmespath-core/pom.xml @@ -10,9 +10,13 @@ io.burt jmespath - 0.5.1 + 0.6.0 + + 4.9.3 + + org.antlr 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 8d6dc5f4..3188179c 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 1a628dfe..d1d083f4 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/ComplianceRunner.java b/jmespath-core/src/test/java/io/burt/jmespath/ComplianceRunner.java index 31277f9a..cdbf80e6 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 5f6495d8..2050dc54 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)); @@ -136,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); } } 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 c3a754a9..bb684300 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 8bf537c8..66a3be45 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-core/src/test/java/io/burt/jmespath/jcf/JcfTest.java b/jmespath-core/src/test/java/io/burt/jmespath/jcf/JcfTest.java index 33aeaf77..0ffe03ba 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")))); } } 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 0597b06b..1ff49b5f 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("{}"); diff --git a/jmespath-gson/pom.xml b/jmespath-gson/pom.xml index 1541bf94..17145433 100644 --- a/jmespath-gson/pom.xml +++ b/jmespath-gson/pom.xml @@ -10,9 +10,13 @@ io.burt jmespath - 0.5.1 + 0.6.0 + + 2.10.1 + + ${project.groupId} 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 59cd8688..a3713f0b 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-gson/src/test/java/io/burt/jmespath/gson/GsonComplianceTest.java b/jmespath-gson/src/test/java/io/burt/jmespath/gson/GsonComplianceTest.java index 2bdf722e..e3ec8ac2 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-jr/pom.xml b/jmespath-jackson-jr/pom.xml new file mode 100644 index 00000000..ae10d856 --- /dev/null +++ b/jmespath-jackson-jr/pom.xml @@ -0,0 +1,44 @@ + + + 4.0.0 + + jmespath-jackson-jr + JMESPath Jackson jr + A JMESPath implementation for Java + + + io.burt + jmespath + 0.6.0 + + + + 2.14.2 + + + + + ${project.groupId} + jmespath-core + ${project.parent.version} + + + ${project.groupId} + jmespath-core + ${project.parent.version} + test-jar + test + + + com.fasterxml.jackson.jr + jackson-jr-objects + ${jackson-jr.version} + + + com.fasterxml.jackson.jr + jackson-jr-stree + ${jackson-jr.version} + + + + \ 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 00000000..749fe2a8 --- /dev/null +++ b/jmespath-jackson-jr/src/main/java/io/burt/jmespath/jacksonjr/JacksonJrRuntime.java @@ -0,0 +1,230 @@ +package io.burt.jmespath.jacksonjr; + +import com.fasterxml.jackson.core.JsonToken; +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.io.UncheckedIOException; +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 JrsValue 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 JrsValue get(int index) { + return array.get(index); + } + + @Override + public int size() { + return array.size(); + } + } + + @Override + public List toList(JrsValue value) { + if (value == null) { + return Collections.emptyList(); + } else 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 = iterator.next(); + list.add(entry.getValue()); + } + return list; + } else { + return Collections.emptyList(); + } + } + + @Override + public String toString(JrsValue value) { + if (JsonToken.VALUE_STRING.equals(value.asToken())) { + return value.asText(); + } else { + try { + return json.asString(value); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + } + + @Override + public Number toNumber(JrsValue value) { + if (value.isValueNode() && value.isNumber()) { + JrsNumber number = (JrsNumber) value; + return number.getValue(); + } else { + return null; + } + } + + @Override + public boolean isTruthy(JrsValue value) { + if (value.isContainerNode()) { + return value.size() > 0; + } else if (value.isValueNode()) { + 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(JrsValue value) { + switch (value.asToken()) { + case START_ARRAY: + return JmesPathType.ARRAY; + case VALUE_EMBEDDED_OBJECT: + case START_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 JrsValue getProperty(JrsValue value, JrsValue name) { + if (JsonToken.VALUE_NULL.equals(value.asToken())) { + return JrsNull.instance(); + } else { + JrsValue node = value.get(name.asText()); + return node != null ? node : createNull(); + } + } + + @Override + 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())); + } + return names; + } else { + return Collections.emptyList(); + } + } + + @Override + public JrsValue createNull() { + return JrsNull.instance(); + } + + @Override + public JrsValue createArray(Collection elements) { + List values = new ArrayList<>(); + for (JrsValue node: elements) { + if (node == null) { + values.add(JrsNull.instance()); + } else { + values.add(node); + } + } + return new JrsArray(values); + + } + + @Override + public JrsValue createString(String str) { + return new JrsString(str); + } + + @Override + public JrsValue createBoolean(boolean b) { + return b ? JrsBoolean.TRUE : JrsBoolean.FALSE; + } + + @Override + public JrsValue createObject(Map obj) { + Map values = new HashMap<>(); + for (Map.Entry entry : obj.entrySet()) { + values.put(entry.getKey().asText(), entry.getValue()); + } + return new JrsObject(values); + } + + @Override + public JrsValue createNumber(double n) { + return new JrsNumber(n); + } + + @Override + 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 new file mode 100644 index 00000000..040f1290 --- /dev/null +++ b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrComplianceTest.java @@ -0,0 +1,12 @@ +package io.burt.jmespath.jacksonjr; + +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(); + + @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 00000000..2c1004f0 --- /dev/null +++ b/jmespath-jackson-jr/src/test/java/io/burt/jmespath/jacksonjr/JacksonJrTest.java @@ -0,0 +1,14 @@ +package io.burt.jmespath.jacksonjr; + + +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 { + @Override + protected Adapter createRuntime(RuntimeConfiguration configuration) { + return new JacksonJrRuntime(configuration); + } +} diff --git a/jmespath-jackson/pom.xml b/jmespath-jackson/pom.xml index 933cafda..82370432 100644 --- a/jmespath-jackson/pom.xml +++ b/jmespath-jackson/pom.xml @@ -10,9 +10,13 @@ io.burt jmespath - 0.5.1 + 0.6.0 + + 2.15.3 + + ${project.groupId} 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 3b05037e..1bb9bc65 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-jackson/src/test/java/io/burt/jmespath/jackson/JacksonComplianceTest.java b/jmespath-jackson/src/test/java/io/burt/jmespath/jackson/JacksonComplianceTest.java index 03500ab2..5d8913bf 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/pom.xml b/jmespath-jakarta-jsonp/pom.xml index 3f886497..3bf991f1 100644 --- a/jmespath-jakarta-jsonp/pom.xml +++ b/jmespath-jakarta-jsonp/pom.xml @@ -10,9 +10,13 @@ io.burt jmespath - 0.5.1 + 0.6.0 + + 1.1.6 + + ${project.groupId} 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 2daf6018..975002c1 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())); } 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 88dd53d1..1f257771 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/pom.xml b/jmespath-vertx/pom.xml index 8589e7cb..c5cf5dcf 100644 --- a/jmespath-vertx/pom.xml +++ b/jmespath-vertx/pom.xml @@ -10,9 +10,13 @@ io.burt jmespath - 0.5.1 + 0.6.0 + + 4.4.6 + + ${project.groupId} 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 5175a759..b0f51136 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; } diff --git a/pom.xml b/pom.xml index 25e720c5..2683d440 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.burt jmespath - 0.5.1 + 0.6.0 pom JMESPath @@ -13,13 +13,8 @@ https://github.com/burtcorp/jmespath-java - 4.12 + 4.13.2 1.3 - 2.9.9 - 1.1.6 - 2.8.5 - 4.7.2 - 3.7.1 UTF-8 @@ -32,7 +27,7 @@ - Theo Hultberg + Theo Hultberg Tolv theo@burtcorp.com Burt http://burtcorp.com/ @@ -51,12 +46,13 @@ 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-0.6.0 jmespath-core jmespath-jackson + jmespath-jackson-jr jmespath-jakarta-jsonp jmespath-gson jmespath-vertx @@ -108,8 +104,8 @@ -Xlint:deprecation -Xlint:unchecked - 7 - 7 + 8 + 8