arnab
11/10/2016, 11:33 PMinline fun <reified T> typeToken(): TypeToken<T> = (object: TypeToken<T>() {})
… at the top level inside the class, and then inside functions, I can do:
val type = typeToken<LinkedTreeMap<String, Map<String, Map<*, *>>>>().type
val foo = Gson().fromJson(response.jsonString, type)
… and that almost works, except, Kotlin asks me to explicitly specify `foo`‘s type as it can’t infer that. So this ends up being:
val type = typeToken<LinkedTreeMap<String, Map<String, Map<*, *>>>>().type
val foo: LinkedTreeMap<String, Map<String, Map<*, *>>> = Gson().fromJson(response.jsonString, type)