Merge branch '1.2.x'

This commit is contained in:
Andy Wilkinson
2018-07-19 11:19:22 +01:00
2 changed files with 39 additions and 3 deletions

View File

@@ -86,8 +86,23 @@ class JsonContentHandler implements ContentHandler {
}
ExtractedField extracted = this.fieldProcessor.extract(candidate.getPath(),
payload);
return extracted.getValue() instanceof Collection
&& ((Collection<?>) extracted.getValue()).isEmpty();
return isEmptyCollection(extracted.getValue());
}
private boolean isEmptyCollection(Object value) {
if (!(value instanceof Collection)) {
return false;
}
Collection<?> collection = (Collection<?>) value;
if (collection.isEmpty()) {
return true;
}
for (Object entry : collection) {
if (!isEmptyCollection(entry)) {
return false;
}
}
return true;
}
@Override