FasterXML / FasterXML/jackson-databind

SnakeCaseStrategy is not applied correctly when deserializing record components

Closed
#6,217 2 comments 0 reactions 0 assignees View on GitHub
works-as-intended
Dominant language
Java
Stars
3.7k
Forks
1.5k
Avg merge
3d 6h
Merged PRs (30d)
28

Description

### Search before asking

- [x] I searched in the [issues](https://github.com/FasterXML/jackson-databind/issues) and found nothing similar.

### Describe the bug

When deserializing a Java record with @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class), the configured naming strategy is not consistently applied to record components.

This results in JSON properties using snake_case names not being matched to their corresponding record components during deserialization.

### Version Information

3.2.1

### Reproduction

```java
public class Jackson3Test {

@Test
public void test() {
String content = "{\"is_true\" : false}";

TestRecord testRecord = JsonMapper.builder().build().readValue(content, TestRecord.class);

Assertions.assertFalse(testRecord.isTrue()); // fails with NPE
}

@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
record TestRecord(Boolean isTrue) {}
}
```

### Actual behavior
The record component is not matched to the JSON property using the configured SnakeCaseStrategy.
The test fails with `java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because the return value of "prompt.runner.Jackson3Test$TestRecord.isTrue()" is null`

Adding an explicit JsonProperty("is_true") to the record component makes deserialization work.

### Expected behavior

SnakeCaseStrategy should be applied consistently to record components during deserialization, so that the JSON property name is resolved to the corresponding Java record component.

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the provided Jackson3Test with JsonMapper, @JsonNaming, SnakeCaseStrategy, and the TestRecord(Boolean isTrue) record. Trace record-component deserialization and naming resolution, then verify that the is_true JSON property populates isTrue without an explicit @JsonProperty and that the regression test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.