I have this code:
Type typeOfObjectsList = new TypeToken>() {}.getType();
List objectsList = new Gson().fromJso
You can actually do it. You just need to parse first your data into an JsonArray and then transform each object individually, and add it to a List :
Class dataType;
//...
JsonElement root = jsonParser.parse(json);
List data = new ArrayList<>();
JsonArray rootArray = root.getAsJsonArray();
for (JsonElement json : rootArray) {
try {
data.add(gson.fromJson(json, dataType));
} catch (Exception e) {
e.printStackTrace();
}
}
return data;