You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we try to read user object, then field ESIAPassport will not be deserialised by jackson, because jackson analyses setter name and expects json to contain field esiapassport.
ObjectMapper objectMapper = new ObjectMapper()
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
String response = """
{
"firstName": "A",
"ESIAPassport": "1234"
}
""";
User user = objectMapper.readValue(response, User.class);
assertEquals("A", user.getFirstName()); // ok
assertEquals("1234", user.getESIAPassport()); // fails
I suppose fix would be to add @JsonProperty annotation on getter or both getter and setter - looks like it doesn't matter for jackson.
The text was updated successfully, but these errors were encountered:
Nazukin-Dmitry
changed the title
fields with capital letters in the beginning are not deserialised by jackson. java
Fields with capital letters in the beginning are not deserialised by jackson. java
Apr 20, 2024
Hello. We have third party schema, where some fields begin with a capital letter.
As example:
Generated java class for User looks like:
We receive response like:
If we try to read
user
object, then fieldESIAPassport
will not be deserialised by jackson, because jackson analyses setter name and expects json to contain fieldesiapassport
.I suppose fix would be to add @JsonProperty annotation on getter or both getter and setter - looks like it doesn't matter for jackson.
The text was updated successfully, but these errors were encountered: