0

Why when I'm returning Float my fromJson isn't called

class RateAdapter {
    @FromJson
    fun fromJson(json: Any): Float {
        return 0.5f
    }
}

But when I'm wrapping it in data class, it's called correctly?

class RateAdapter {
    @FromJson
    fun fromJson(json: Any): MyData {
        return MyData(0.5f)
    }
}

I'm using Moshi with Retrofit

return Retrofit.Builder()
        .baseUrl(CURRENCY_CONVERTER_URL)
        .addConverterFactory(MoshiConverterFactory.create(
                Moshi.Builder().add(RateAdapter()).build()
        ))
        .addCallAdapterFactory(LiveDataCallAdapterFactory())
        .build()
        .create(CurrencyConverterService::class.java)
jakub
  • 3,576
  • 3
  • 29
  • 55

0 Answers0