Hi, we were using `kotlinx.serialization.internal....
# serialization
p
Hi, we were using
kotlinx.serialization.internal.CommonEnumSerializer
to serialize an enum:
Copy code
object DayTypeSerializer : CommonEnumSerializer<DayType>(
    "DayType",
    DayType.values(),
    DayType.values().map { it.type.toString() }.toTypedArray()
)

@Serializable(with = DayTypeSerializer::class)
enum class Day(val type: Int) {
    MONDAY(1),
    TUESDAY(2),
    WEDNESDAY(3),
    THURSDAY(4),
    FRIDAY(5),
    SATURDAY(6),
    SUNDAY(7),
    HOLIDAY(8),
}
After 0.20.0 update
CommonEnumSerializer
is removed. Is there another way to achieve this?
s
сс @Vsevolod Tolstopyatov [JB]
v
Another way is to write your own enum serializer. We removed
CES
because it was too implemnetation-specific and we didn’t know about any compelling use-cases
it would be really nice if you created a github issue with your use-case explained, so others could also vote/comment
a
We also rely on this — @Paulius Ruminas can you link to your issue once you create it so I can also add our use cases?
p
We added @SerialName annotations to out Kotlin enum class
Copy code
```
@Serializable
enum class DayType {
    @SerialName("1") MONDAY,
    @SerialName("2") TUESDAY,
    @SerialName("3") WEDNESDAY,
    @SerialName("4") THURSDAY,
    @SerialName("5") FRIDAY,
    @SerialName("6") SATURDAY,
    @SerialName("7") SUNDAY,
    @SerialName("8") HOLIDAY,
}
```
And changed our TypeScript enum to use strings instead of numbers.
p
What I can weird is that you can't get the serializer now without reflection