jackson-databind
jackson-databind copied to clipboard
Conversion to snake_case with JsonNaming work not properly
Version information com.fasterxml.jackson.core:jackson-annotations:2.13.1 OpenJDK 17 Gradle 7.2 Spring Boot 2.6.2
Describe the bug I testing auto snake_case conversion feature and found, that case when first letter is lower and next is upper conversion doesn't work properly (for example eVariable). Tested class
@EqualsAndHashCode(callSuper = true)
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class X <T, E> extends Y <E> {
T genericT;
E genericE;
E eVariable;
Z<T, Integer, E> zVariable;
}
Result:
Expected:
e_variable
z_variable
If add one more letter at begin of word:

This is documented behavior. Please see: https://fasterxml.github.io/jackson-databind/javadoc/2.8/com/fasterxml/jackson/databind/PropertyNamingStrategy.SnakeCaseStrategy.html
To fix this, you can either add an explicit @JsonProperty annotation, or name the getter something else – geteVariable.