1

Closed

StringEnumConverter could replace hyphens with underscores

description

When interacting with APIs we don't have control over, we sometimes run into a discrete set of values that includes hyphens (aka dashes). It would be nice if the StringEnumConverter automatically converted them to underscores before deserializing.

For serialization it would be quite a bit more challenging because it's not obvious if an underscore is supposed to be a hyphen. I'm not requesting that the serialization case be handled but a possible solution would be to add an enum class attribute called "Hyphenate" or something similar which would instruct the serializer to replace underscores with hyphens.
Closed Oct 3, 2013 at 10:38 AM by JamesNK
I suggest you use your own custom converter

comments