diff --git a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/JsonAsserterImpl.java b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/JsonAsserterImpl.java index 2faa8aee..10859683 100644 --- a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/JsonAsserterImpl.java +++ b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/JsonAsserterImpl.java @@ -4,7 +4,6 @@ package com.jayway.jsonassert.impl; import com.jayway.jsonassert.JsonAsserter; import com.jayway.jsonpath.Configuration; import com.jayway.jsonpath.JsonPath; -import com.jayway.jsonpath.Option; import com.jayway.jsonpath.PathNotFoundException; import org.hamcrest.Matcher; diff --git a/json-path-assert/src/test/java/com/jayway/jsonassert/JsonAssertTest.java b/json-path-assert/src/test/java/com/jayway/jsonassert/JsonAssertTest.java index d6cd02a3..4d0d7d05 100644 --- a/json-path-assert/src/test/java/com/jayway/jsonassert/JsonAssertTest.java +++ b/json-path-assert/src/test/java/com/jayway/jsonassert/JsonAssertTest.java @@ -1,6 +1,5 @@ package com.jayway.jsonassert; -import org.junit.Ignore; import org.junit.Test; import java.io.InputStream; diff --git a/json-path-web-test/src/main/java/com/jayway/jsonpath/web/bench/Bench.java b/json-path-web-test/src/main/java/com/jayway/jsonpath/web/bench/Bench.java index ce69eb4d..5a80a48a 100644 --- a/json-path-web-test/src/main/java/com/jayway/jsonpath/web/bench/Bench.java +++ b/json-path-web-test/src/main/java/com/jayway/jsonpath/web/bench/Bench.java @@ -25,14 +25,16 @@ public class Bench { private final boolean flagWrap; private final boolean flagMerge; private final boolean flagSuppress; + private final boolean flagNullLeaf; - public Bench(String json, String path, boolean optionAsValues, boolean flagWrap, boolean flagMerge, boolean flagSuppress) { + public Bench(String json, String path, boolean optionAsValues, boolean flagWrap, boolean flagMerge, boolean flagSuppress, boolean flagNullLeaf) { this.json = json; this.path = path; this.optionAsValues = optionAsValues; this.flagWrap = flagWrap; this.flagMerge = flagMerge; this.flagSuppress = flagSuppress; + this.flagNullLeaf = flagNullLeaf; } public Result runJayway() { @@ -55,6 +57,9 @@ public class Bench { if (!optionAsValues) { configuration = configuration.addOptions(Option.AS_PATH_LIST); } + if(flagNullLeaf){ + configuration = configuration.addOptions(Option.DEFAULT_PATH_LEAF_TO_NULL); + } long now = System.currentTimeMillis(); try { diff --git a/json-path-web-test/src/main/java/com/jayway/jsonpath/web/resource/ApiResource.java b/json-path-web-test/src/main/java/com/jayway/jsonpath/web/resource/ApiResource.java index b0d9465d..5fb10b2c 100644 --- a/json-path-web-test/src/main/java/com/jayway/jsonpath/web/resource/ApiResource.java +++ b/json-path-web-test/src/main/java/com/jayway/jsonpath/web/resource/ApiResource.java @@ -49,11 +49,12 @@ public class ApiResource { @FormParam("type") String type, @FormParam("flagWrap") boolean flagWrap, @FormParam("flagMerge") boolean flagMerge, + @FormParam("flagNullLeaf") boolean flagNullLeaf, @FormParam("flagSuppress") boolean flagSuppress ){ boolean value = "VALUE".equalsIgnoreCase(type); - Map resultMap = new Bench(json, path, value, flagWrap, flagMerge, flagSuppress).runAll(); + Map resultMap = new Bench(json, path, value, flagWrap, flagMerge, flagSuppress, flagNullLeaf).runAll(); return Response.ok(resultMap).build(); } diff --git a/json-path-web-test/src/main/resources/html/index.html b/json-path-web-test/src/main/resources/html/index.html index 5937ec13..2da13077 100644 --- a/json-path-web-test/src/main/resources/html/index.html +++ b/json-path-web-test/src/main/resources/html/index.html @@ -82,6 +82,12 @@ Merge multi props to new object +
+ +
@@ -222,6 +228,7 @@ type: $('input[name=rbType]:checked').val(), flagWrap: $('#cbFlagWrap').prop('checked'), flagMerge: $('#cbFlagMerge').prop('checked'), + flagNullLeaf: $('#cbFlagNullLeaf').prop('checked'), flagSuppress: $('#cbFlagSuppress').prop('checked') } console.log(data); diff --git a/json-path/src/main/java/com/jayway/jsonpath/Configuration.java b/json-path/src/main/java/com/jayway/jsonpath/Configuration.java index 379e9ced..d5aca573 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/Configuration.java +++ b/json-path/src/main/java/com/jayway/jsonpath/Configuration.java @@ -26,6 +26,22 @@ import static java.util.Arrays.asList; public class Configuration { + private static Defaults DEFAULTS = new Defaults() { + @Override + public JsonProvider provider() { + return JsonProviderFactory.createProvider(); + } + + @Override + public Set