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

Cannot Deserialize JSON with @JsonProperty Annotated Record Fields in Jackson-jr #176

Open
juulhobert opened this issue Nov 24, 2024 · 1 comment
Labels
jackson-annotations Issue relate to (limited) support of main Jackson annotations java-record Issue related to Java 14+ java.lang.Record support pr-welcome Issue for which progress most likely if someone submits a Pull Request

Comments

@juulhobert
Copy link

I'm encountering an issue when using Jackson-jr with annotation support to handle record classes that map to JSON with snake_case field names. While serialization works as expected, deserialization of the same JSON back into the record fails.

To illustrate the problem, I created a minimal reproducer: jackson-jr-annotations-reproducer.

Steps to Reproduce:
Use a record class where fields are annotated with @JsonProperty to specify the snake_case equivalent of the field name. Serialize an instance of the record class to JSON using Jackson-jr (with annotation support). Attempt to deserialize the resulting JSON back into the record class.

Expected Behavior:
The JSON should deserialize correctly into the record class, matching fields based on the @JsonProperty annotations.

Actual Behavior:
Deserialization fails with an exception
image

Environment:
Jackson-jr version: 2.18.1
Java version: 21

Reproducer Link:
https://github.com/juulhobert/jackson-jr-annoations-reproducer

@cowtowncoder cowtowncoder added java-record Issue related to Java 14+ java.lang.Record support jackson-annotations Issue relate to (limited) support of main Jackson annotations labels Nov 24, 2024
@cowtowncoder
Copy link
Member

Right, Record-support is pretty limited and probably won't yet work with annotation support. Thank you for reporting this.

@cowtowncoder cowtowncoder added the pr-welcome Issue for which progress most likely if someone submits a Pull Request label Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jackson-annotations Issue relate to (limited) support of main Jackson annotations java-record Issue related to Java 14+ java.lang.Record support pr-welcome Issue for which progress most likely if someone submits a Pull Request
Projects
None yet
Development

No branches or pull requests

2 participants