Skip to content

PascalCaseStrategy ignores @JsonProperty on method #428

@piotrturski

Description

@piotrturski

naming strategy changes name provided in JSONPropertyAnnotation

copied from: http://stackoverflow.com/questions/22667964/jackson-pascal-case-and-jsonproperty-on-getter

the following test should pass but it fails

import static org.assertj.core.api.Assertions.assertThat;
import org.testng.annotations.Test;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;

public class JsonFailureTest {

    @Test
    public void should_serialize_first_letter_lowercase() throws Exception {

        String json = new ObjectMapper()
                            .setPropertyNamingStrategy(PropertyNamingStrategy.PASCAL_CASE_TO_CAMEL_CASE)
                            .writeValueAsString(

        new Object(){

            @JsonProperty("fooBar")
            public String whatever() {return "";}

        });

        assertThat(json).contains("fooBar");
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions