Sum types are sealed trait
s, sealed class
es and
non-singleton enum
s.
Since they have one or more subtypes, we need to disambiguate between them somehow.
The default in Tupson is to use the @type
property.
Its value is the simple type name of class or enum case.
This makes JSON independent of scala/java package and it is more readable.
Example:
You can use some other key by annotating the sum type with @discriminator
: