为什么当我返回Float时,我的fromJson没有被呼叫
class RateAdapter {
@FromJson
fun fromJson(json: Any): Float {
return 0.5f
}
}
但是当我将其包装在数据类中时,它被正确调用了吗?
class RateAdapter {
@FromJson
fun fromJson(json: Any): MyData {
return MyData(0.5f)
}
}
我正在将Moshi与Retrofit一起使用
return Retrofit.Builder()
.baseUrl(CURRENCY_CONVERTER_URL)
.addConverterFactory(MoshiConverterFactory.create(
Moshi.Builder().add(RateAdapter()).build()
))
.addCallAdapterFactory(LiveDataCallAdapterFactory())
.build()
.create(CurrencyConverterService::class.java)