Is there a way to require the type-discriminator's...
# serialization
p
Is there a way to require the type-discriminator's presence during serialization, even if the serialization case doesn't actually need discriminating? That is, I'm putting a specific member of a sealed class inside a sealed class, and, for the API's sake, I want to include the
type
key, but if I type the field in the data class to the specific sealed class member, it just serializes the different properties and does not include the type discriminator (by design, surely - but I'm hoping to avoid it anyways)
encodeDefaults
won't work, because I have lots of other nullable things that I don't want to send over the wire. I'm guessing the solution will be a custom serializer for as many of these sometimes-discriminated-sometimes-not members as I have
For posterity, this is the best I've come up with.
PlainTextObject
is the sealed class member,
TextObject
is the base class.