Field name conversion issues caused by automatic generation of getter functions in Kotlin
Closed this issue · 1 comments
NEONKID commented
A bug in which the name of the getter function is not generated as intended when compiling Kotlin due to the use of the field name as a getter function during serialization in Jackson, so that the field name conversion such as snake case is not converted to the desired format
Kotlin code example:
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class)
data class ABC (
val aBcDef: String,
)
internal class ObjectMapperTest {
val mapper = ObjectMapper()
@Test
fun `test abc`() {
val abc = ABC("John")
println(mapper.writeValueAsString(abc))
}
}
When the above code is executed, the aBcDef field should be converted to the a_bc_def
field, but it is actually converted to abc_def
Result:
{"abc_def":"John"}
Kotlin Version : 1.9.0
Jackson Databind Version: 2.15.2
Jackson Module Kotlin Version: 2.15.2