【发布时间】:2019-07-24 06:32:07
【问题描述】:
我有一堂课:
@JsonClass(generateAdapter = true)
data class DayAveragePriceModel(
val asset: Asset,
val value: BigDecimal
)
Asset 是我拥有的自定义类。我正在尝试使用Moshi,但出现以下错误:
Caused by: java.lang.IllegalArgumentException: Platform class java.math.BigDecimal (with no annotations) requires explicit JsonAdapter to be registered
我该如何解决这个问题?我试过了
return Moshi.Builder()
.add(KotlinJsonAdapterFactory())
.add(Object::class.java)
.build()
}
但它正在崩溃。
提前非常感谢!
【问题讨论】: