jackson-databind icon indicating copy to clipboard operation
jackson-databind copied to clipboard

Consider supporting some form of naming strategy for enums

Open cowtowncoder opened this issue 4 years ago • 0 comments

(note: follow up for #2660 )

As things are, the only way to change representation of Enum values (which defaults to using Enum.name()) is to use either "use toString()" or explicit @JsonProperty overrides. But it appears that there is usage where there is naming convention in use, similar to how @JsonNaming works mapping POJO fields to external JSON property names.

One possibility might be to try to directly support use of @JsonNaming on Enum classes. This may or may not be practical, considering underlying PropertyNamingStrategy is tied to accessors (Field, Method) that POJOs expose -- but bigger issue may be that this would be two-dimensional mapping as unlike POJO property names that use Bean naming ([lower] camel case), Enum names themselves may use one convention, and external names another one. As such it may be necessary to either come up with new abstraction(s), or maybe just alternate PropertyNamingStrategy implementations.

cowtowncoder avatar Mar 26 '20 00:03 cowtowncoder