Cannot Deserialize JSON with @JsonProperty Annotated Record Fields in Jackson-jr #176
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
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:
![image](https://private-user-images.githubusercontent.com/4354859/389263023-378c4f7e-9d8c-4b2d-9d61-34f572bc6887.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNzUwNjcsIm5iZiI6MTczOTE3NDc2NywicGF0aCI6Ii80MzU0ODU5LzM4OTI2MzAyMy0zNzhjNGY3ZS05ZDhjLTRiMmQtOWQ2MS0zNGY1NzJiYzY4ODcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMDgwNjA3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTZkODljZWNiMzEzYWU4NTUzMmIyZTI1MjNkMmFhNjc5NWI2ZDllMTI5MDFlODIxNjA2MTk3MmMzNmE3OTI5MyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.FqdZpWMeedVIw7QKqEkdaNefE2AqttfVDvf_FCqJNu8)
Deserialization fails with an exception
Environment:
Jackson-jr version: 2.18.1
Java version: 21
Reproducer Link:
https://github.com/juulhobert/jackson-jr-annoations-reproducer
The text was updated successfully, but these errors were encountered: