Ok, so I have ``` inline fun <reified T&g...
# getting-started
a
Ok, so I have
Copy code
inline fun <reified T> typeToken(): TypeToken<T> = (object: TypeToken<T>() {})
… at the top level inside the class, and then inside functions, I can do:
Copy code
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:
Copy code
val type = typeToken<LinkedTreeMap<String, Map<String, Map<*, *>>>>().type
        val foo: LinkedTreeMap<String, Map<String, Map<*, *>>> = Gson().fromJson(response.jsonString, type)