diff --git a/src/main/java/org/springframework/data/web/JsonProjectingMethodInterceptorFactory.java b/src/main/java/org/springframework/data/web/JsonProjectingMethodInterceptorFactory.java index 8ae20805c..3b1262b35 100644 --- a/src/main/java/org/springframework/data/web/JsonProjectingMethodInterceptorFactory.java +++ b/src/main/java/org/springframework/data/web/JsonProjectingMethodInterceptorFactory.java @@ -156,13 +156,14 @@ public class JsonProjectingMethodInterceptorFactory implements MethodInterceptor return isCollectionResult && !(nested instanceof Collection) ? result : nested; } - type = isCollectionResult && JsonPath.isPathDefinite(jsonPath) + boolean definitePath = JsonPath.isPathDefinite(jsonPath); + type = isCollectionResult && definitePath ? ResolvableType.forClassWithGenerics(List.class, type) : type; List result = (List) context.read(jsonPath, new ResolvableTypeRef(type)); - if (isCollectionResult && JsonPath.isPathDefinite(jsonPath)) { + if (isCollectionResult && definitePath) { result = (List) result.get(0); }