Anyone know the API for allowing a "default if typ...
# serialization
s
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
{ "a": 1, "b":2, "c":2, "type": "com.example.WibbleV2" }
... 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.
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.
e