I want to transfer a list object via Google Gson, but I don\'t know how to deserialize generic types.
What I tried after looking at this (BalusC\'s answer):
I liked the answer from kays1 but I couldn't implement it. So I built my own version using his concept.
public class JsonListHelper{
public static final List getList(String json) throws Exception {
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
Type typeOfList = new TypeToken>(){}.getType();
return gson.fromJson(json, typeOfList);
}
}
Usage:
List MyList= JsonListHelper.getList(jsonArrayString);