@Nullable @Override public Object invoke(@SuppressWarnings("null") MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); TypeInformation<Object> returnType = ClassTypeInformation.fromReturnTypeOf(method); ResolvableType type = ResolvableType.forMethodReturnType(method); boolean isCollectionResult = Collection.class.isAssignableFrom(type.getRawClass()); type = isCollectionResult ? type : ResolvableType.forClassWithGenerics(List.class, type); Iterable<String> jsonPaths = getJsonPaths(method); for (String jsonPath : jsonPaths) { try { if (returnType.getRequiredActualType().getType().isInterface()) { List<?> result = context.read(jsonPath); return result.isEmpty() ? null : result.get(0); } type = isCollectionResult && JsonPath.isPathDefinite(jsonPath) ? ResolvableType.forClassWithGenerics(List.class, type) : type; List<?> result = (List<?>) context.read(jsonPath, new ResolvableTypeRef(type)); if (isCollectionResult && JsonPath.isPathDefinite(jsonPath)) { result = (List<?>) result.get(0); } return isCollectionResult ? result : result.isEmpty() ? null : result.get(0); } catch (PathNotFoundException o_O) { // continue with next path } } return null; }