Currently I am working on a native android app with webView front end.
I have something like:
public class dataObject
{
int a;
String b;
}
My version of gson list deserialization using a helper class:
public List getList(Class type, JSONArray json) throws Exception {
Gson gsonB = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
return gsonB.fromJson(json.toString(), new JsonListHelper(type));
}
public class JsonListHelper implements ParameterizedType {
private Class> wrapped;
public JsonListHelper(Class wrapped) {
this.wrapped = wrapped;
}
public Type[] getActualTypeArguments() {
return new Type[] {wrapped};
}
public Type getRawType() {
return List.class;
}
public Type getOwnerType() {
return null;
}
}
Usage
List