For a given json response like this ```{ ... ...
# serialization
p
For a given json response like this
Copy code
{
    ...
    "error": "error_001"
}
is there an out-of-the-box solution to deserialize
error
as a sealed interface like this?
Copy code
@Serializable
sealed interface Errors {
    @Serializable
    @SerialName("error_001")
    object Error001 : Errors
    
    // Catch all for unknown values
    @Serializable
    value class Unknown(val errorCode: String) : Errors
}
i
@SerialName is for key, but not for value.
s
Should be possible with a custom de-serializer. 1. Inspect the value for "error" 2. If "error_1" -> map to Error001 else Unknown