The old class name is:
@Serializable
@SerialName("OldClass")
class OldClass(
val member: String,
) : IClass {
...
}
Now I want to rename it to:
@Serializable
@SerialName("NewClass")
class NewClass(
val member: String,
) : IClass {
...
}
The problem is, users might have already serialized and saved it. So, what I want is:
- When serializing, use the NewClass
- When deserializing, no matter if it reads OldClass or NewClass, always decode with NewClass
The SerializeModule that used for serializing/deserliazing looke like:
val serializeModule = SerializersModule {
polymorphic(IClass::class) {
subclass(OldClass::class)
subclass(NewClass::class)
...
}
}
Currently, I need to implement both classes, which are exactly the same, is it possible to only implement the NewClass, and use an alias for the old one?