Anyone know the API for allowing a "default if type is missing for polymorphic deserialization"? Long story short, I inherited a system that has a bunch of JSON objects like
{ "a": 1, "b":2 }
and want to start storing a new set of polydata, where it would end up serializing
... the problem is the existing records would NOT have the type field for it to know it was V1.... trying to avoid the work of custom deserializers.
Scott Fedorov
07/03/2025, 11:03 PM
Example (pseudo):
Copy code
@Serializable
sealed class WibbeTypes {
@Serializable
data class WibbleV1(val a: Int, val b: Int): WibbleTypes
@Serializable
data class WibbleV2(val a: Int, val b: Int, val c: Int): WibbleTypes
}
New WibbleV1 records would serialize with the type, but getting old records out and deserializing would fail because the type field is missing.