I've got an endpoint that I know is liable to chan...
# serialization
a
I've got an endpoint that I know is liable to change on the server side in a way that isn't backwards compatible for mobile clients. I have limited ability to influence the API. I'd like to have
@Serializable data class MyDataClass(val inner: MyUnreliableDataClass?)
Where kotlinx.serialization will just insert
null
as the value for
inner
if the deserialization fails because the server-side json schema changed. Is there an easy way to define this kind of a serializer?
s
I solved a similar problem once using a wrapper class. I have a complete gist here: https://gist.github.com/vshivam/5fd90e87be8958f5c9e1d1ff0c55f798