-
-
Notifications
You must be signed in to change notification settings - Fork 177
@JsonProperty ignored when serialising Kotlin @JvmRecord in 2.16.X #773
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
Comments
This seems to occur without registering a In the case of the code you submitted, the annotation is given as a constructor parameter. I have submitted an issue to |
Just tracking this round the houses - it seems to have ended up as a Kotlin bug https://youtrack.jetbrains.com/issue/KT-67977 |
Some other context: Jackson 2.18 will finally get Property Introspection rewrite -- FasterXML/jackson-databind#4515 -- completion of which should make it possible to address some problems that formerly could not, wrt Kotlin introspection. |
I checked again and it seems that at least in |
I changed the target package com.fasterxml.jackson.module.kotlin
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.core.JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION
import com.fasterxml.jackson.databind.json.JsonMapper
@JvmRecord
data class JacksonTest(
@JsonProperty("propertyOne")
val one: String,
@JsonProperty("propertyTwo")
val two: String
)
fun main() {
val mapper = JsonMapper.builder().findAndAddModules()
.build()
.enable(INCLUDE_SOURCE_IN_LOCATION)
val test = JacksonTest("one", "two")
val ser = mapper.writeValueAsString(test)
println(ser)
val de = mapper.readValue<JacksonTest>(ser)
println(de)
}
|
Search before asking
Describe the bug
When serialising the following Kotlin
data class
with2.16.1
I get the wrong properties generate. This works with2.15.4
.The following simple test code
Produces the following error
As you can see, the property is called
one
etc, notpropertyOne
.Removing
@JvmRecord
causes the test to pass. This works correctly with@JvmRecord
in2.15.4
.Versions
Java: GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30)
Kotlin: 1.9.22 (
jvmTarget
21)Jackson BOM:
2.16.1
To Reproduce
The above runs correctly if
@JvmRecord
2.15.4
Expected behavior
No response
Versions
Java: GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30)
Kotlin: 1.9.22
Jackson-module-kotlin: 2.16.1
Jackson-databind: 2.16.1
Jackson-bom: 2.16.1
Additional context
Discovered when investigating Spring Boot 3.3.X
The text was updated successfully, but these errors were encountered: