How to use gson deserialize to ArrayList in Kotlin
问题 I use this class to store data public class Item(var name:String, var description:String?=null){ } And use it in ArrayList public var itemList = ArrayList<Item>() Use this code to serialize the object val gs=Gson() val itemListJsonString = gs.toJson(itemList) And deserialize itemList = gs.fromJson<ArrayList<Item>>(itemListJsonString, ArrayList::class.java) But this method will give me LinkedTreeMap , not Item , I cannot cast LinkedTreeMap to Item What is correct way to deserialize to json in