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

EnumFeature.WRITE_ENUMS_TO_LOWERCASE overrides @JsonProperty values #4788

Closed
1 task done
martel opened this issue Nov 7, 2024 · 7 comments
Closed
1 task done

EnumFeature.WRITE_ENUMS_TO_LOWERCASE overrides @JsonProperty values #4788

martel opened this issue Nov 7, 2024 · 7 comments
Labels
2.18 has-failing-test Indicates that there exists a test case (under `failing/`) to reproduce the issue
Milestone

Comments

@martel
Copy link

martel commented Nov 7, 2024

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

@martel martel added the to-evaluate Issue that has been received but not yet evaluated label Nov 7, 2024
@cowtowncoder cowtowncoder added 2.18 has-failing-test Indicates that there exists a test case (under `failing/`) to reproduce the issue and removed to-evaluate Issue that has been received but not yet evaluated labels Nov 7, 2024
@cowtowncoder
Copy link
Member

Thank you for reporting this @martel -- definitely sounds like a bug. Big thanks for reproduction.

@cowtowncoder
Copy link
Member

@JooHyukKim I think you implemented this feature; may want to see if this might be something simple to fix? Or if not, at least add "tofix" reproduction to help.

@JooHyukKim
Copy link
Member

JooHyukKim commented Nov 7, 2024

Okay, lemme look into this right away 👌🏼👌🏼
Thank you for clean reproduction @martel !

@JooHyukKim
Copy link
Member

Filed #4789 , thanks!

cowtowncoder added a commit that referenced this issue Nov 8, 2024
@cowtowncoder cowtowncoder added this to the 2.18.2 milestone Nov 8, 2024
@cowtowncoder
Copy link
Member

Excellent work, @JooHyukKim !

@martel
Copy link
Author

martel commented Nov 11, 2024

Thank you, folks! I was expecting this issue to be open for months, and lo and behold! Such a nice surprise. Big thank you!! Cheers.

@cowtowncoder
Copy link
Member

Thank you for your the report @martel; happy we could get it fixed quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.18 has-failing-test Indicates that there exists a test case (under `failing/`) to reproduce the issue
Projects
None yet
Development

No branches or pull requests

3 participants