Skip to content

EnumFeature.WRITE_ENUMS_TO_LOWERCASE overrides @JsonProperty values #4788

@martel

Description

@martel

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

When using EnumFeature.WRITE_ENUMS_TO_LOWERCASE, the @JsonProperty values of enum fields are ignored.

Version Information

2.18.1

Reproduction

class ObjectMapperTest {

  public enum Sauce {
    @JsonProperty("Ketchup")
    KETCHUP,
  }

  ObjectMapper objectMapper = new ObjectMapper()
      .configure(EnumFeature.WRITE_ENUMS_TO_LOWERCASE, true);

  @Test
  void shouldUseJsonProperty() throws JsonProcessingException {
    assertEquals("\"Ketchup\"", objectMapper.writeValueAsString(Sauce.KETCHUP));
  }
}

Results in:

org.opentest4j.AssertionFailedError: 
Expected :"Ketchup"
Actual   :"ketchup"

Expected behavior

Should return @JsonProperty defined value.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.18Issues planned at 2.18 or laterhas-failing-testIndicates that there exists a test case (under `failing/`) to reproduce the issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions