kotlinx-serialization / kotlinx.serialization.builtins / AbstractDecoder / decodeEnum

decodeEnum

(common, js, jvm, native) open fun decodeEnum(enumDescriptor: SerialDescriptor): Int

Decodes a enum value and returns its index in enumDescriptor elements collection. Corresponding kind is UnionKind.ENUM_KIND.

E.g. for the enum enum class Letters { A, B, C, D } and underlying input "C", decodeEnum method should return 2 as a result.

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