kotlinx-serialization / kotlinx.serialization.builtins / AbstractEncoder / encodeEnum

encodeEnum

(common, js, jvm, native) open fun encodeEnum(enumDescriptor: SerialDescriptor, index: Int): Unit

Encodes a enum value that is stored at the index in enumDescriptor elements collection. Corresponding kind is UnionKind.ENUM_KIND.

E.g. for the enum enum class Letters { A, B, C, D } and serializable value "C", encodeEnum method should be called with 2 as am index.

This method does not imply any restrictions on the output format, the format is free to store the enum by its name, index, ordinal or any other