decodeEnumsCaseInsensitive

Enables decoding enum values in a case-insensitive manner. Encoding is not affected.

This affects both enum serial names and alternative names (specified with the JsonNames annotation). In the following example, string [VALUE_A, VALUE_B] will be printed:

enum class E { VALUE_A, @JsonNames("ALTERNATIVE") VALUE_B }

@Serializable
data class Outer(val enums: List<E>)

val j = Json { decodeEnumsCaseInsensitive = true }
println(j.decodeFromString<Outer>("""{"enums":["value_A", "alternative"]}""").enums)

If this feature is enabled, it is no longer possible to decode enum values that have the same name in a lowercase form. The following code will throw a serialization exception:

enum class BadEnum { Bad, BAD }
val j = Json { decodeEnumsCaseInsensitive = true }
j.decodeFromString<Box<BadEnum>>("""{"boxed":"bad"}""")