You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Serialization of fields starting with a single lowercase character followed by an uppercase character are serialized as all lowercase. This causes deserialization to fail as jackson tries to deserialize according to the "original"/camelCased field name. E.g. pId is serialized as pid but expects pId during deserialization.
To Reproduce
data classFooBar(
valid:String,
valnId:String, // expected name: nId, actual: nid
)
funmain() {
val fooBar =FooBar("bar", "foo")
val json = jacksonObjectMapper().writeValueAsString(fooBar)
assert(fooBar == jacksonObjectMapper().readValue<FooBar>(json))
}
Expected behavior
Serialized fields names should match the original field name.
junkdog
changed the title
Failed deerialization of fields where only the first character is lowercase
Failed deserialization of fields where only the first character is lowercase
Sep 24, 2021
+1
Hint where to find the bug:
com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector#collectAll
com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector#_addMethods
com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector#_addGetterMethod
com.fasterxml.jackson.databind.ser.BeanSerializerFactory#removeIgnorableTypes
This is because pId has a getPId and setPId format accessor. Jackson extracts the PId from here and makes the letters lowercase until it encounters a lowercase letter (PId -> pid).
Quckfix for it - add @JsonProperty("pId") on accessor for Java. Or @get:JsonProperty("pId") / @param:JsonProperty("pId") for kotlin
Describe the bug
Serialization of fields starting with a single lowercase character followed by an uppercase character are serialized as all lowercase. This causes deserialization to fail as jackson tries to deserialize according to the "original"/camelCased field name. E.g.
pId
is serialized aspid
but expectspId
during deserialization.To Reproduce
Expected behavior
Serialized fields names should match the original field name.
Versions
Kotlin: 1.5.30
Jackson-module-kotlin: 2.12.5
Jackson-databind: 2.12.5
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: