We've defined a model in our service code as -
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class SomeData {
public boolean tnAvailable;
@NonNull
public String sTempChange;
public boolean isTnAvailable() {
return faAvailable;
}
public void setTnAvailable(boolean faAvailable) {
this.faAvailable = faAvailable;
}
@Nonnull
public String getSTempChange() {
return sTempChange;
}
public void setSTempChange(@Nonnull String sTempChange) {
this.sTempChange = sTempChange;
}
}
When the api including the above model in response is queried , we get the response as -
"someData": {
"tnAvailable": true,
"stempChange": "trial_001"
}
What surprised us was the stempChange
(notice lowercase t
) instead of sTempChange
in the attributes of the response.
Suspecting the cause to be Jackson com.fasterxml.jackson.core:jackson-core:2.5.2 while serializing and deserializing of the objects during API calls since we do not alter the attribute using any other getter-setter ot wrapper. Why would this so happen and is serialization/deserialization the correct direction to look for this?
Edit - From the comment by @Windle, trying to explain what's different here. I re-iterate "The question though there relates pretty much to the same situation. Yet I 'm looking forward to the reason's for such implementation and documentation in fasterxml as well."
Handling of multiple leading capital letters in getters/setters (like "getURL()", or "getFName()"). By default, Jackson will simply lower-case ALL leading upper-case letters, giving "url" and "fname". But if you enable MapperFeature.USE_STD_BEAN_NAMING (added in Jackson 2.5), it will follow what Java Bean naming convention would do, which is only lower-case a single upper-case leading letter; if multiple found, do nothing. That would result in properties "URL" and "FName".