提问人:sublimelaconic 提问时间:11/10/2023 更新时间:11/10/2023 访问量:23
javax.ws.rs.core.Response.readEntity 返回 MismatchedInputException
javax.ws.rs.core.Response.readEntity returning MismatchedInputException
问:
我正在尝试从 API 读取响应。但是我收到此错误:
原因:com.fasterxml.jackson.databind.exc.MismatchedInputException:无法反序列化 [package] 类型的值。ResponseDTO ' from Array value (token )_ at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 1]JsonToken.START_ARRAY
响应如下所示:
[
{
"success": true,
"errors": []
}
]
以下是我调用 API 的方式:
ResponseDTO response = service.executeAPI(ResponseDTO.class, request, builder);
这是我的执行方法的精简版本:
private <T> T executeAPI(final Class<T> resType, final Supplier<Response> executor) {
T response = null;
// call API
response = clientResponse.readEntity(resType);
}
这是我的DTO:
@XmlRootElement
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResponseDTO {
private boolean success;
private List<String> errors;
//getters and setters
}
答: 暂无答案
评论