Kotlin / kotlinx.serialization

Kotlin multiplatform / multi-format serialization
Apache License 2.0
5.38k stars 620 forks source link

Kotlinx serialization ignores unknown enum #2554

Closed huthe98 closed 2 months ago

huthe98 commented 8 months ago

Kotlinx serialization ignores unknown enums, val services: kotlin.collections.List<@Contextual ServiceGeneratedDto>?

Failure(io.ktor.serialization.JsonConvertException: .ServiceGeneratedDto does not contain element with name 'Cars' at path $[1].services[0])
sandwwraith commented 8 months ago

Take a look here: https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/json.md#coercing-input-values

valeriyo commented 2 months ago

"unknown values for enums" -- what does it mean? literally enum field called "unknown" or something else?

sandwwraith commented 2 months ago

@valeriyo Values that are not declared in the enum class in Kotlin. See example in the mentioned section.