无法将列表作为API方法参数传递:JsonMappingException:无法从VALUE_STRING标记中反序列化java.lang.String []的实例

时间:2015-01-15 00:47:33

标签: java android jackson google-cloud-endpoints google-cloud-platform

我将Google Cloud端点定义为:

@ApiMethod(
        name = "list",
        path = "MyUser",
        httpMethod = ApiMethod.HttpMethod.GET)
public CollectionResponse<MyUser> list(@Nullable @Named("cursor") String cursor, @Nullable @Named("limit") Integer limit, @Named("phones") ArrayList<String> phones) {
....

并从Android客户端调用它:

myUserApi.list(phones).execute();

但我得到以下例外:

 {
"code": 400,
"errors": [
{
"domain": "global",
"message": "com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String[] out of VALUE_STRING token\n at [Source: N/A; line: -1, column: -1]",
"reason": "badRequest"
}
],
"message": "com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String[] out of VALUE_STRING token\n at [Source: N/A; line: -1, column: -1]"
}

我不知道是什么问题。根据Cloud Endpoints官方文档,List参数有效。

编辑:这是来自云控制台的调试消息:

Request URL: https://myapp.appspot.com/_ah/api/myUserApi/v1/myUserphones?phones=11111111&phones=222222222&phones=3333333&phones....
Method: myUserApi.list
Error Code: 400
Reason: badRequest
Message: com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String[] out of VALUE_STRING token

显然,它将列表中的每个元素转换为参数,而不是将所有内容都作为数组传递。我该如何解决这个问题?

0 个答案:

没有答案