Thread
#serialization
    alex009

    alex009

    3 years ago
    hi all! can anyone help me with enum serialization? i have enum values 1,2,3,4 and write this enum:
    enum class Status {
        @SerialName("1")
        ACTIVE,
        @SerialName("2")
        BLOCKED,
        @SerialName("3")
        WAIT_UPDATE_PROFILE,
        @SerialName("4")
        WAIT_APPROVE;
    }
    but serialization can't parse Status:
    kotlinx.serialization.SerializationException: com.icerockdev.generated.ktor.models.RelativeProfileResponse.Status does not contain element with name '1'
    enums not support
    @SerialName
    ?
    s

    sandwwraith

    3 years ago
    Unfotunately, enums currently don't support that
    You can write custom serializer to convert Int <> Enum
    alex009

    alex009

    3 years ago
    thx 🙂