public class ListResult<T> {
private boolean ok;
private String message;
private java.util.List<T> data;
private Paging paging;
}
When i want to deserialize JSON given form RESTful call like this :
Type fooType = new TypeToken<ListResult<T>>() {}.getType();
Gson gson = new Gson();
Object model = gson.fromJson(strResult, fooType);
A get A ListResult where data field is a list of StringMap instead a List of T like defined in ListResult class
Any idea ?
Type fooType = new TypeToken<ListResult<StringMap>>() {}.getType();
Gson gson = new Gson();
ListResult<StringMap> model = gson.fromJson(strResult, fooType);
Gson can't read your mind, or determine a Generic type all on its own ;)
https://sites.google.com/site/gson/gson-user-guide#TOC-Serializing-and-Deserializing-Generic-Types
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With