jackson-databind icon indicating copy to clipboard operation
jackson-databind copied to clipboard

Conversion to snake_case with JsonNaming work not properly

Open FriMay opened this issue 3 years ago • 1 comments

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: image Expected: e_variable z_variable If add one more letter at begin of word: image

FriMay avatar Jan 10 '22 19:01 FriMay

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.

yawkat avatar Jan 11 '22 08:01 yawkat