Hi everyone, Do you know if there is a way to add...
# serialization
m
Hi everyone, Do you know if there is a way to add a default type for sealed class serialization or any discussion regarding this somewhere? Imagine that you have two Styles (default and dark):
Copy code
@Serializable
sealed class Style {

   @SerialName("default")
   object Default : Style()

   @SerialName("dark")
   class Dark(...) : Style()
}
Now in order to future-proof the above in case new styles are introduced, we want to use the Default style in case a new type (“light” f.x.) is introduced. Is there some idiomatic way to do this - besides using a custom serializer?
j
Custom serializer I think
☝️ 1
(you have an
object Unknown : Style()
and then pass that into
OneOfSerializer(Style.class, Style.Unknown)
🙏 1