android - 如何更改 Robospice/Jackson 中的根 JSON 数组元素名称?

标签 android jackson robospice

我在 Robospice 中使用了这个 Request 类和 Google HTTP Java client :

public class MyRequest {
    @Key
    private List<String> Items;
 //.....
}

我用的是:

MyRequest myRequest = new MyRequest();
myRequest.setItems(data);

this.postMyRequest = new PostMyRequest(myRequest);
getSpiceManager().execute(postMyRequest, new PostMyRequestListener());

JsonHttpContent jsonHttpContent = new JsonHttpContent(new JacksonFactory(), this.myRequest);

HttpRequest httpRequest = getHttpRequestFactory()
            .buildPostRequest(new GenericUrl(this.baseUrl), jsonHttpContent);
httpRequest.setParser(new JacksonFactory().createJsonObjectParser());

Response response = httpRequest.execute().parseAs(getResultType());

如何将根数组名称(从“Items”)更改为其他名称? 我试过 @JsonProperty("Foo") 但没有做任何事情。

最佳答案

好的,明白了。

我从 ArrayList 扩展了我的类。

public class MyRequest extends ArrayList<String> {
 //.....
}

这使得根名称为空白/空(这正是我想要的)

关于android - 如何更改 Robospice/Jackson 中的根 JSON 数组元素名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22287769/

相关文章:

java - Jackson 包装器反序列化最佳实践

java - Jackson 和泛型类型引用

java - 如何使用带有 JSON 数据的 RoboSpice Google Http Java 客户端模块上传文件

android - 在 SoundPool 播放中使用 String

java - startsWith endsWith 匹配包含正则表达式

java - Json映射非标准接口(interface)

android - 将 Cookie 与 Robospice Retrofit 请求一起使用

php - Android - 后台线程更新 PHP session

java - 未找到 Android Studio 注释抽象处理器

android - 以编程方式裁剪位图的底部