【问题标题】:Gson, parse object of arrays using retrofitGson,使用改造解析数组对象
【发布时间】:2015-11-09 12:35:30
【问题描述】:

我有这个服务器响应:

{ "result" : true , "content" : {
    "files" : [],
    "filesNames" : [],
    "folders" : []
    }
}

如何创建一个 gson 对象以使改造适应该响应?因为这似乎不起作用(我只需要文件和文件夹):

public class GetUserFilesAnswer {

    public boolean result;
    public List<Integer> files;
    public List<String> folders;


}

client.getUserFiles(email, token, path, new Callback<GetUserFilesAnswer>() {
        @Override
        public void success(GetUserFilesAnswer getUserFilesAnswer, Response response) {
        }

        @Override
        public void failure(RetrofitError error) {

        }
    });

【问题讨论】:

标签: android json gson retrofit


【解决方案1】:

试试这个模型:

public class GetUserFilesAnswer {

    public static class Content {
       public List<Integer> files;
       public List<String> folders;
    }

    public boolean result;
    public Content content;

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-23
    • 1970-01-01
    相关资源
    最近更新 更多