Browse Source

Better approach

pull/331/head
jochenberger 8 years ago committed by GitHub
parent
commit
7fc262724b
  1. 5
      json-path/src/main/java/com/jayway/jsonpath/spi/json/JsonOrgJsonProvider.java

5
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) { public Object getMapValue(Object obj, String key) {
try { try {
JSONObject jsonObject = toJsonObject(obj); JSONObject jsonObject = toJsonObject(obj);
if (!jsonObject.has(key)) { Object o = jsonObject.opt(key);
if (o == null) {
return UNDEFINED; return UNDEFINED;
} else { } else {
return unwrap(jsonObject.get(key)); return unwrap(o);
} }
} catch (JSONException e) { } catch (JSONException e) {
throw new JsonPathException(e); throw new JsonPathException(e);

Loading…
Cancel
Save