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

@JsonProperty is being ignored when property name (in camelCase notation) starts with a single letter #353

Closed
fragonib opened this issue Jul 18, 2020 · 3 comments
Labels

Comments

@fragonib
Copy link

fragonib commented Jul 18, 2020

Describe the bug
Jackson @JsonProperty annotation is being ignored when property name is in camelCase and first word consists in a single letter.

To Reproduce
Here is an example with two properties of same type but different name. Kotlin compiler places @JsonProperty on same place: constructor param. However, only originalName property name is replaced but aName is not.

class JsonAnnotationTest {

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

    @Test
    fun `JsonProperty annotation test`() {
        assertThat(mapper.writeValueAsString(EntityWithJacksonAnnotation()))
                .isEqualTo("""{"changedName1":"value","changedName2":"value"}""")
    }

}

data class EntityWithJacksonAnnotation(

        @JsonProperty("changedName1")
        val originalName: String? = "value",

        @JsonProperty("changedName2")
        val aName: String? = "value"

)

Expected behavior

Expected :{"changedName1":"value","changedName2":"value"}
Actual   :{"changedName1":"value","aname":"value"}

Versions
Kotlin: 1.3
Jackson-module-kotlin: 2.11.1
Jackson-databind: 2.11.1

@fragonib fragonib added the bug label Jul 18, 2020
@fragonib fragonib changed the title JsonProperty is being ignored when property name in camelCase starts with a single letter @JsonProperty is being ignored when property name (in camelCase notation) starts with a single letter Jul 19, 2020
@iivan91
Copy link

iivan91 commented Jul 24, 2020

I have found the same issue too.

MyClass(val eTag: String) the eTag value is parsed as etag removing the capital letter T
This can be a big problem if a back-end sends me a json with capital letters in the second place of the properties, because Jackson can not find the property and fails.

@Blafasel3
Copy link

Any updates on this? I just encountered the same issue.

@k163377
Copy link
Contributor

k163377 commented Mar 3, 2023

This issue will be fixed by #630 and therefore 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

4 participants