Skip to content

Add new factory method for creating custom EnumValues to pass to EnumDeserializer #2663

@whut

Description

@whut

The com.fasterxml.jackson.databind.util.EnumValues constructor is now private, which means that it is
not possible to create EnumSerializer instance with custom EnumValues. It should be at least protected, like is the case of com.fasterxml.jackson.databind.util.EnumResolver used by EnumDeserializer.

I try to implement different strategy for serialization and deserialization of enums, simply to convert java SNAKE_CASE to more common in JSON camelCase and vice-versa. It is quite easy with EnumDeserializer, but in case of EnumSerializer it is not. I would like to just create new instance of EnumSerializer with EnumValues instance build using different logic. Currently the only way (without reflection which I will use for the time being) is to cal the EnumValues#construct* methods, which have hard-coded enum-to-string mapping logic.

BTW. Consider adding casing strategy for enum serialization/deserialization as build-in jackson feature. For example in JSON.NET it is just a matter of passing approprate NamingStrategy to StringEnumConverter constructor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions