【发布时间】:2011-06-16 04:53:07
【问题描述】:
您好,我有以下课程,需要使用 Gson 转换传入的 Json
public class JsonConverter<T>{
private boolean success = Boolean.TRUE;
private List<T> data;
private int total;
private String message;
public JsonConverter(){
}
public JsonConverter(List<T> data, int count){
this.data = data;
this.total = count;
} //getters and setters
我有一个传入的 Json,其数据属性包含一些具有以下定义的类的值:
class A {private long calendarId;
private String title;
private String description;
private int colorId;
private boolean isHidden;
private long userId; //getter and setter
}
示例: json字符串:
{"data":{"calendarId":"ext-gen223","title":"work","description":"work","isHidden":false,"colorId":"2"}}
我想从 Json String 中获取值并将其设置在 List data 中(应该是 A 类对象列表 ) 的类 JsonConverter 使用 Gson。
谢谢
【问题讨论】: