diff --git a/json-path/src/main/java/com/jayway/jsonpath/Filter.java b/json-path/src/main/java/com/jayway/jsonpath/Filter.java index 9de183bf..2b81e8b6 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/Filter.java +++ b/json-path/src/main/java/com/jayway/jsonpath/Filter.java @@ -16,6 +16,8 @@ package com.jayway.jsonpath; import java.util.*; +import com.jayway.jsonpath.spi.JsonProvider; + /** * A filter is used to filter the content of a JSON array in a JSONPath. * @@ -45,10 +47,11 @@ public abstract class Filter { /** * Filters the provided list based on this filter configuration * @param filterItems items to filter + * @param jsonProvider the json provider that is used to create the result list * @return the filtered list */ - public List doFilter(List filterItems) { - List result = new ArrayList(); + public List doFilter(List filterItems, JsonProvider jsonProvider) { + List result = jsonProvider.createList();; for (T filterItem : filterItems) { if (accept(filterItem)) { result.add(filterItem); diff --git a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ArrayQueryFilter.java b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ArrayQueryFilter.java index 80892f78..8ded0836 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ArrayQueryFilter.java +++ b/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ArrayQueryFilter.java @@ -34,7 +34,7 @@ public class ArrayQueryFilter extends PathTokenFilter { Filter filter = filters.poll(); - return filter.doFilter((List)obj); + return filter.doFilter((List)obj, jsonProvider); }