-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
2.18Issues planned at 2.18 or laterIssues planned at 2.18 or laterRecordIssue related to JDK17 java.lang.Record supportIssue related to JDK17 java.lang.Record support
Description
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
Since 2.16.0 the order of record
's properties is not preserved when @JsonProperty
is present. This is not the case for version 2.15.X.
The impact:
- breaking tons of tests related to signatures and similar use cases
- overall worse order than the order defined in the record in terms of readability
Version Information
1.16.0+, works on 1.15.X
Reproduction
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
class RecordPropertiesOrderTest {
@Test
void assertRecordPropertiesOrder() throws JsonProcessingException {
assertEquals("{\"aa\":1,\"b\":2}", new ObjectMapper().writeValueAsString(new TestRecord(1, 2)));
}
private record TestRecord(@JsonProperty("aa") int a, int b) {
}
}
Expected behavior
The properties in the JSON should be in the same order as defined in the record
just like it behaves without the @JsonProperty
annotation.
Additional context
No response
Metadata
Metadata
Assignees
Labels
2.18Issues planned at 2.18 or laterIssues planned at 2.18 or laterRecordIssue related to JDK17 java.lang.Record supportIssue related to JDK17 java.lang.Record support