You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes. I am using Measure with meters unit and Measure with kilograms unit
The json content has weight: 1000.0,height : 8 like that.
I tried to write a typeadapter facory class MeasureTypeAdapterFactory : TypeAdapterFactory {
override fun create(gson: Gson, type: TypeToken): TypeAdapter? {
return when (type.rawType) {
Measure::class.java -> MeasureAdapter() as TypeAdapter
else -> null
}
}
}
But it is not working as expected.
The json should parse and become a object in kotlin data class Dimensions {
val height: Measure = Measure(0.0, Length.meters),
val weight: Measure = Measure(0.0, Mass.kilograms),
}
The one I implemented is not correct. Can you please help with it. I am not able to find good examples as well.
If we want to register type adapter for the type how to create it?
The text was updated successfully, but these errors were encountered: