I've used Jackson for years, and I am not sure I ever faced this issue.
Using Jackson 2.12.5 in a Spring Boot 2.5.5 project, I have an object that I need to serialize. I have no issue with other fields, but these 2 fields are causing me problems :
@Jacksonized
@Builder
@Getter
public class ComputationResult {
private final String pId;
private final String cId;
... other fields ignored
}
As you can see, I am also using Lombok annotations. When "delombokized", the getters are :
public String getPId() {
return this.pId;
}
public String getCId() {
return this.cId;
}
when serializing the POJO, I expect the field names to be "pId" and "cId", but they are not : I get "pid" and "cid", all lower-case. I don't have the problem with other fields, for which the case is respected.
It caused me an issue because I need to serialize then deserialize the POJO, and the deserialization failed because it could not map "cid" json field to "cId" java field.
There are various workarounds (I am using @JsonAlias("cid")
on the field to allow the deserialization), but I am puzzled : is this an expected behavior by Jackson ? does it process String fields differently depending on their length ? or is it a java beans convention that I am not aware of ?
Is there a property to set in the objectMapper to "fix" the behavior, without implementing my own com.fasterxml.jackson.databind.PropertyNamingStrategy
?