{ "firstName": "John", "lastName" : "doe", "age" : 26, "address" : { "streetAddress": "naist street", "city" : "Nara", "postalCode" : "630-0192" }, "phoneNumbers": [ { "type" : "iPhone", "number": "0123-4567-8888" }, { "type" : "home", "number": "0123-4567-8910" } ]}
public boolean passesJsonPath(Map<String, Object> jsonObject, String jsonPath) {
try {
Configuration conf = Configuration.builder().options(Option.AS_PATH_LIST).build();
List<String> list = JsonPath.using(conf).parse(jsonObject).read(jsonPath);
return true;
} catch (PathNotFoundException pathNotFoundException) {
return false;
}
}
$.[?(@.age > 10)]
{ "firstName": "John", "lastName" : "doe", "age" : "26", "address" : { "streetAddress": "naist street", "city" : "Nara", "postalCode" : "630-0192" }, "phoneNumbers": [ { "type" : "iPhone", "number": "0123-4567-8888" }, { "type" : "home", "number": "0123-4567-8910" } ]}