Kotlin / kotlinx.serialization

Kotlin multiplatform / multi-format serialization
Apache License 2.0
5.33k stars 618 forks source link

Polymorphic deserialization `type` field #786

Open saied89 opened 4 years ago

saied89 commented 4 years ago

Currently the expected value of type field is the canonical name of sub classes. Is it possible to customize this value?

ps: Subclass name or ParentClass.SubClass might be better choices for this value. The way it is moving your model class to another package breaks the api with clients.

qwwdfsad commented 4 years ago

Not yet, but we are considering adding this. As a workaround, you can change the canonical name of the class by annotation it with @SerialName annotation