How to use TypeToken with generics in Gson in Kotlin (solving com.google.gson.internal.LinkedTreeMap error)
Hi everyone! I've been struggling for several days with the problem of JSON deserialization in Kotlin when using generics. I have a function that takes a class type and returns a parsed object. In Java, I would write something like `new TypeToken
- >(){}.getType()`, but in Kotlin this doesn't work due to erased generics.
Here's a simplified example:
```kotlin
data class User(val name: String, val age: Int)
fun
No answers yet.
Log in to leave an answer