我有一个使用Moshi 1.8.0序列化/反序列化数据的工作代码
Upgrading to 1.9.1 now leads to a crash when attempting to serialize:
JAVAlang.IllegalArgumentException:无法序列化Kotlin类型
Here is the serializer code:
val moshi = Moshi.Builder().build()
val dataListType = newParameterizedType(List::class.java, T::class.java)
val adapter: JsonAdapter<List<T>> = moshi.adapter(dataListType)
val json = adapter.toJson(dataList)
对应的T类是
@IgnoreExtraProperties
data class Spot(
var id: String = "",
var localizedName: String? = null,
var type: String = "",
var location: Location? = null
)
我完全不知道在这里该做些什么.
Thanks for the help!