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
I searched in the issues and found nothing similar.
I have confirmed that the same problem is not reproduced if I exclude the KotlinModule.
I searched in the issues of databind and other modules used and found nothing similar.
I have confirmed that the problem does not reproduce in Java and only occurs when using Kotlin and KotlinModule.
Describe the bug
Data classes with properties starting with a single lowercase letter are handled incorrectly, changing to lowercase whole group of sequential uppercase letters following it in property name:
This results in inaccurate JSON & inability to deserialize it back with the same data class.
To Reproduce
importcom.fasterxml.jackson.module.kotlin.jacksonObjectMapperimportcom.fasterxml.jackson.module.kotlin.readValuedata classBugTest(/*@get:JvmName("getaBcd") or @get:JsonProperty("aBcd") fixes the issue*/valaBcd:Int)
funmain() {
val mapper = jacksonObjectMapper()
val json = mapper.writeValueAsString(BugTest(1))
println(json) // expected: {"aBcd":1}, actual: {"abcd":1}
mapper.readValue<BugTest>(json) // com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "abcd" (class BugTest), not marked as ignorable (one known property: "aBcd"])
}
Expected behavior
Prints {"aBcd":1}, exits successfully.
Versions
Kotlin: Any
Jackson-module-kotlin: 2.18.2
Jackson-databind: 2.18.2
Additional context
There is a similar bug for databind, but I believe Kotlin module could handle it in its own way, since the root cause of databind's bug is a method it restores field name from getter name, while Kotlin module can directly access data class properties names and not rely on Kotlin's compiler-generated getters (which is getABcd in this case by the way).
The text was updated successfully, but these errors were encountered:
Search before asking
Describe the bug
Data classes with properties starting with a single lowercase letter are handled incorrectly, changing to lowercase whole group of sequential uppercase letters following it in property name:
This results in inaccurate JSON & inability to deserialize it back with the same data class.
To Reproduce
Expected behavior
Prints
{"aBcd":1}
, exits successfully.Versions
Kotlin: Any
Jackson-module-kotlin: 2.18.2
Jackson-databind: 2.18.2
Additional context
There is a similar bug for databind, but I believe Kotlin module could handle it in its own way, since the root cause of databind's bug is a method it restores field name from getter name, while Kotlin module can directly access data class properties names and not rely on Kotlin's compiler-generated getters (which is
getABcd
in this case by the way).The text was updated successfully, but these errors were encountered: