# serialization

Jon Bailey

11/23/2023, 3:11 PM
Hi, Is there a way to set coerceInputValues but only for a specific field or enum class? it seems quite extreme to set that on the JSON builder, and also it isn't really JSON specific as having a default value for an enum when an unknown value is encountered could happen in any data format. I've tried writing a custom serializer but it seems like I have to do that for each enum that I want this behaviour for as it's not possible to make it generic and also it's not possible to access the @SerialName of the enum values.

Charles Flynn

11/23/2023, 8:48 PM
Handling enums has always felt one of the most painful things with serialisation and kotlin serialisation doesn't seem to help out much as you say. I often end up just using strings half the time to make life easier.