Android/Kotlin Series: [#04] — How to use TypeToken + generics with Gson in Kotlin?

Leo N
2 min readJun 28, 2019
https://d3nmt5vlzunoa1.cloudfront.net/kotlin/files/2019/05/Blog-Post-Grey.png

Nowadays a lot of people use Gson to convert JSON strings to Java or Kotlin objects and in this tutorial, I will show you how to write convenience methods that will make that task easier.

For Java

You have to specify the type of T at the time of deserialization. How would your List of…

--

--

Leo N

🎓 “A person who never made a mistake never tried anything new.” — Albert Einstein