jackson-jr icon indicating copy to clipboard operation
jackson-jr copied to clipboard

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

Open juulhobert opened this issue 1 year ago • 1 comments

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

juulhobert avatar Nov 24 '24 09:11 juulhobert

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

cowtowncoder avatar Nov 24 '24 19:11 cowtowncoder

Fixed for 2.21.0 and 3.0.1.

cowtowncoder avatar Oct 22 '25 01:10 cowtowncoder