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 names containing hyphens are truncated when serialized #434

Closed
ocisly opened this issue Apr 4, 2021 · 2 comments
Closed

Field names containing hyphens are truncated when serialized #434

ocisly opened this issue Apr 4, 2021 · 2 comments
Labels

Comments

@ocisly
Copy link

ocisly commented Apr 4, 2021

Describe the bug

Hyphens are legal in Kotlin field names. #383 broke serialisation of such fields by incorrectly inferring that any such field name indicates an inline class and proceeding to truncate it before the hyphen.

To Reproduce

import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper

data class ReproduceBug383(val `a-b`: Int)
val mapper = jacksonObjectMapper()
mapper.writeValueAsString(ReproduceBug383(5)) // => {"a":5}

Expected behavior

{"a-b":5}

Versions
Kotlin: 1.4.31
Jackson-module-kotlin: 2.12.2
Jackson-databind: 2.12.2

Additional context

Commit that broke it: 6787e10#diff-5bffae78b70b8281d1cc2775149f7abe12db5a678c9163c105675ec2136183a2R165

PR introducing the breaking change: https://github.com/FasterXML/jackson-module-kotlin/pull/383/files#diff-5bffae78b70b8281d1cc2775149f7abe12db5a678c9163c105675ec2136183a2R162

Line of code that removes the correct field: https://github.com/FasterXML/jackson-databind/blob/e0fd026b38e9f58e78d191ba3b5f03c5a743b1b4/src/main/java/com/fasterxml/jackson/databind/ser/BeanSerializerFactory.java#L727

@ocisly ocisly added the bug label Apr 4, 2021
@dinomite dinomite added the 2.12 label Apr 5, 2021
@dinomite
Copy link
Member

dinomite commented Apr 5, 2021

Thanks for the very detailed report!

@k163377
Copy link
Contributor

k163377 commented Mar 3, 2023

The issue of property names in the serialization result differing from the definition in Kotlin will be addressed in #630.
This issue be closed as a duplicate.

@k163377 k163377 closed this as completed Mar 3, 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

3 participants