我有一个配置了 Cloud Endpoints Framework v2 和 Java 8 的 GAE 应用程序。它对于已经在那里定义的服务运行良好。
我有一种定义新服务的方法。看起来像这样:
@ApiMethod(httpMethod = "get", path = "/operations/mine")
public UserOperationsResponse getOperationsForUser(User user) {
return operationsService.
getOperationsByUserId(user.getUserId());
}
这是UserOperationsResponse
类的设计:
public class UserOperationsResponse {
private List<Long> items;
public UserOperationsResponse() {
}
public UserOperationsResponse(List<Long> items) {
this.items = items;
}
public List<Long> getItems() {
return items;
}
}
该方法按预期工作并检索数据。但是,当我去邮递员并测试服务时,我得到了以下响应:
{
"items": [
"4676209648599040" // <-- string
]
}
如何在响应中获取数字数组而不是字符串数组?