Skip to content
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

Field name conversion issues caused by automatic generation of getter functions in Kotlin #703

Closed
NEONKID opened this issue Aug 18, 2023 · 1 comment
Labels

Comments

@NEONKID
Copy link

NEONKID commented Aug 18, 2023

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

@NEONKID NEONKID added the bug label Aug 18, 2023
@k163377
Copy link
Contributor

k163377 commented Aug 18, 2023

A workaround option for these issues will be released in 2.16.
Please see the issue below for details.
#630

This issue is closed as a duplicate.

@k163377 k163377 closed this as completed Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants