ClassDiscriminatorMode

Defines which classes and objects should have their serial name included in the json as so-called class discriminator.

Class discriminator is a JSON field added by kotlinx.serialization that has JsonBuilder.classDiscriminator as a key (type by default), and class' serial name as a value (fully-qualified name by default, can be changed with SerialName annotation).

Class discriminator is important for serializing and deserializing polymorphic class hierarchies. Default ClassDiscriminatorMode.POLYMORPHIC mode adds discriminator only to polymorphic classes. This behavior can be changed to match various JSON schemas.

See also

Entries

Link copied to clipboard

Never include class discriminator in the output.

Link copied to clipboard

Include class discriminators whenever possible.

Link copied to clipboard

Include class discriminators for polymorphic classes.

Properties

Link copied to clipboard

Returns a representation of an immutable list of all enum entries, in the order they're declared.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Link copied to clipboard

Returns an array containing the constants of this enum type, in the order they're declared.