Hi I have the following class and need to convert the incoming Json using Gson
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
I have an incoming Json with a data property that contains the values of some a class which has the following definition:
class A {private long calendarId;
private String title;
private String description;
private int colorId;
private boolean isHidden;
private long userId; //getter and setter
}
Example: Json string:
{"data":{"calendarId":"ext-gen223","title":"work","description":"work","isHidden":false,"colorId":"2"}}
I want to get the value from Json String and set it inside the List data (which should be a list of Class A objects) of Class JsonConverter using Gson.
Thanks
Used Type type = new TypeToken<JsonConverter<A>>(){}.getType();
and got it running!
精彩评论