Is it possible to create a method, that parses a generic collection from jsson? My aproach above doesn't work, because at runtime gson returns an ArrayList of LinkedHasmaps here, however there is no errors at compile time.
private <T> ArrayList<T> readArray(String json)
{
Gson gson = new Gson();
Type collType = new TypeToken<ArrayList<T>>() {
}.getType();
return gson.fromJson(json, collType);
}
I have already looked at some similar questions here like: Using a generic type with Gson, but I found no solution, that really works.