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

Sometimes serialization ignores @JsonProperty (Kotlin) #2205

Closed
comm1x opened this issue Dec 11, 2018 · 1 comment
Closed

Sometimes serialization ignores @JsonProperty (Kotlin) #2205

comm1x opened this issue Dec 11, 2018 · 1 comment

Comments

@comm1x
Copy link

comm1x commented Dec 11, 2018

We have 2 classes Cat and Dog. For Cat with property name someflag serialization will works fine. But for Dog - no.

data class Dog(@JsonProperty("is_active") val isActive: Boolean)
data class Cat(@JsonProperty("is_active") val someflag: Boolean)

val mapper = ObjectMapper()
mapper.registerModule(KotlinModule())

val dogJson = mapper.writeValueAsString(Dog(true))
val catJson = mapper.writeValueAsString(Cat(true))

// dogJson is {"active": true}        -- NOT OK, should be "is_active"
// catJson is {"is_active": true}     -- OK

We expect that dogJson and catJson will be {"is_active": true}, but dogJson is {"active": true} for unknown reason.

Jackson version:

implementation 'com.fasterxml.jackson.core:jackson-core:2.9.7'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.6'
@comm1x
Copy link
Author

comm1x commented Dec 11, 2018

Duplicate FasterXML/jackson-module-kotlin#80

@comm1x comm1x closed this as completed Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant