Deserializing json with PolymorphicJsonAdapterFactory and Retrofit #1632
Replies: 2 comments
-
BTW this works when creating an adapter, but not when setting it as a part of Retrofit with addConverterFactory()
|
Beta Was this translation helpful? Give feedback.
-
Any solution on this issue. I am also facing the same and haven't been able to find any solution. The debugger shows that CustomAdapter is attached to the Moshi but it never gets called to serialize the sealed class. |
Beta Was this translation helpful? Give feedback.
-
I have read about every blog and documentation there is about Moshi's PolymorphicJsonAdapterFactory but i cannot make it work for some reason.
Retrofit API & DTO's:
Moshi & Retrofit setup:
My dependencies:
I have tried making the super class open, sealed class and interface.
Sealed:
Interface:
Open:
Dosent crash, but i'm just getting a Payment object without a parent.
I have tried to add
@JsonClass(generateAdapter = true)
on the data classes (and the parent) but it makes no difference.I have also tried older versions of Moshi, but dosent seem to work for me there either.
What am i missing here?
Beta Was this translation helpful? Give feedback.
All reactions