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):
Here is a solution that works with a dynamically defined type. The trick is creating the proper type of of array using Array.newInstance().
public static List fromJsonList(String json, Class clazz) {
Object [] array = (Object[])java.lang.reflect.Array.newInstance(clazz, 0);
array = gson.fromJson(json, array.getClass());
List list = new ArrayList();
for (int i=0 ; i