In GSON to get a list of objects you do
Gson gson = new Gson();
Type token = new TypeToken>(){}.getType();
return gson.fromJson(json
In Kotlin you can simply use this function:
inline fun fromJson(json: String): T {
return Gson().fromJson(json, object: TypeToken(){}.type)
}
and use it like
val myTypes: List = fromJson(jsonString);
It will parse any object including gereric types as List. Keyword inline and reified ensures that type will not be erased.
For detail info I can recommend this Medium post