Browse Source

add a method to safely read a path from a map, turning an InvalidPathException into a null return value

pull/16/head
Jochen Berger 12 years ago
parent
commit
8d7597b947
  1. 8
      json-path/src/main/java/com/jayway/jsonpath/Criteria.java

8
json-path/src/main/java/com/jayway/jsonpath/Criteria.java

@ -95,7 +95,13 @@ public class Criteria {
} }
} }
private static Object readSafely(JsonPath path, Map<String, Object> map){
try{
return path.read(map);
} catch (InvalidPathException e){
return null;
}
}
boolean singleObjectApply(Map<String, Object> map) { boolean singleObjectApply(Map<String, Object> map) {

Loading…
Cancel
Save