Browse Source

Changed behavior of FieldFilter to throw InvalidPathException instead of returning null when a field is queried for on a json array

pull/27/head
Jack Singleton 12 years ago
parent
commit
dfe248c002
  1. 2
      json-path/src/main/java/com/jayway/jsonpath/internal/filter/FieldFilter.java

2
json-path/src/main/java/com/jayway/jsonpath/internal/filter/FieldFilter.java

@ -35,7 +35,7 @@ public class FieldFilter extends PathTokenFilter {
public Object filter(Object obj, JsonProvider jsonProvider, LinkedList<Filter> filters, boolean inArrayContext) {
if (jsonProvider.isList(obj)) {
if (!inArrayContext) {
return null;
throw new InvalidPathException("Trying to access field on array");
} else {
List<Object> result = jsonProvider.createList();
for (Object current : jsonProvider.toList(obj)) {

Loading…
Cancel
Save