-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow serializing enums to lowercase (EnumFeature.WRITE_ENUMS_TO_LOWERCASE
)
#3053
Comments
See proposed PR. |
I don't think I'll accept this as a Or, alternatively, have something like I'll keep this issue open but the solution will need to be something other than another |
I see you removed the to evaluate label on this issue. Is this going to be implemented soon, when is Jackson 2.13 going to be released, as the information in the wiki don't seem to be right anymore. |
@kdankert I probably will not have time to work on this any time soon unfortunately. 2.13 will be released whenever it might be ready: versions are not scheduled based on time. But before release there will be one or more Release Candidates and announcements will typically be sent on dev mailing list (as well as via |
No problem, thanks for the update. |
Note that I solved it temporarily with custom serializer: package net.goout.jackson
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.databind.ser.std.StdSerializer
val lowerCaseEnumJacksonSerializerModule = SimpleModule().also {
val lowerCaseEnumKeySerializer = object : StdSerializer<Enum<*>>(Enum::class.java) {
override fun serialize(value: Enum<*>?, json: JsonGenerator, provider: SerializerProvider) {
json.writeFieldName(value?.name?.toLowerCase())
}
}
val lowerCaseEnumValueSerializer = object : StdSerializer<Enum<*>>(Enum::class.java) {
override fun serialize(value: Enum<*>?, json: JsonGenerator, provider: SerializerProvider) {
json.writeString(value?.name?.toLowerCase())
}
}
it.addKeySerializer(Enum::class.java, lowerCaseEnumKeySerializer)
it.addSerializer(Enum::class.java, lowerCaseEnumValueSerializer)
} |
So Jackson 2.14 is out and I'm unable to use this feature, the new |
@ZeroOne3010 Unfortunately this feature did not make it in due to timing constraints, all the other work. I changed the label -- it is intended to show release targeted, but is not binding (i.e. aspirational, not constraining) |
@cowtowncoder OK, no worries, thanks for the clarification! I can wait. :) |
EnumFeature.WRITE_ENUMS_TO_LOWERCASE
)
Implemented via #3776. |
Is your feature request related to a problem? Please describe.
Java enums are usually defined as
UPPER_CASE_WITH_UNDERSCORE
. This is not a standard in endpoints, as these rather uselower_case_with_underscore
. There is already feature forACCEPT_CASE_INSENSITIVE_ENUMS
, which helps with deserialization, the feature for serialization is however currently missing. Only option is using@JsonProperty
ortoString()
serialization.Describe the solution you'd like
I would like to have
SerializationFeature.WRITE_ENUM_LOWERCASED
.Usage example
Any API endpoint.
The text was updated successfully, but these errors were encountered: