From 7fc262724bf469d1ff9f1036dbe47b9fe1dc2652 Mon Sep 17 00:00:00 2001 From: jochenberger Date: Thu, 23 Mar 2017 16:06:10 +0100 Subject: [PATCH] Better approach --- .../com/jayway/jsonpath/spi/json/JsonOrgJsonProvider.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/json-path/src/main/java/com/jayway/jsonpath/spi/json/JsonOrgJsonProvider.java b/json-path/src/main/java/com/jayway/jsonpath/spi/json/JsonOrgJsonProvider.java index 516ce424..0c5f169e 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/spi/json/JsonOrgJsonProvider.java +++ b/json-path/src/main/java/com/jayway/jsonpath/spi/json/JsonOrgJsonProvider.java @@ -96,10 +96,11 @@ public class JsonOrgJsonProvider extends AbstractJsonProvider { public Object getMapValue(Object obj, String key) { try { JSONObject jsonObject = toJsonObject(obj); - if (!jsonObject.has(key)) { + Object o = jsonObject.opt(key); + if (o == null) { return UNDEFINED; } else { - return unwrap(jsonObject.get(key)); + return unwrap(o); } } catch (JSONException e) { throw new JsonPathException(e);