@@ -16,8 +16,10 @@ record RecordWithIgnore(int id, @JsonIgnore String name) {
16
16
record RecordWithIgnoreJsonProperty (int id , @ JsonIgnore @ JsonProperty ("name" ) String name ) {
17
17
}
18
18
19
+ record RecordWithIgnoreJsonPropertyDifferentName (int id , @ JsonIgnore @ JsonProperty ("name2" ) String name ) {
20
+ }
21
+
19
22
record RecordWithIgnoreAccessor (int id , String name ) {
20
-
21
23
@ JsonIgnore
22
24
@ Override
23
25
public String name () {
@@ -61,6 +63,20 @@ public void testSerializeJsonIgnoreAndJsonPropertyRecord() throws Exception {
61
63
assertEquals ("{\" id\" :123}" , json );
62
64
}
63
65
66
+ @ Test
67
+ public void testDeserializeJsonIgnoreAndJsonPropertyRecord () throws Exception {
68
+ RecordWithIgnoreJsonProperty value = MAPPER .readValue ("{\" id\" :123,\" name\" :\" Bob\" }" ,
69
+ RecordWithIgnoreJsonProperty .class );
70
+ assertEquals (new RecordWithIgnoreJsonProperty (123 , null ), value );
71
+ }
72
+
73
+ @ Test
74
+ public void testDeserializeJsonIgnoreRecordWithDifferentName () throws Exception {
75
+ RecordWithIgnoreJsonPropertyDifferentName value = MAPPER .readValue ("{\" id\" :123,\" name\" :\" Bob\" }" ,
76
+ RecordWithIgnoreJsonPropertyDifferentName .class );
77
+ assertEquals (new RecordWithIgnoreJsonPropertyDifferentName (123 , null ), value );
78
+ }
79
+
64
80
/*
65
81
/**********************************************************************
66
82
/* Test methods, JsonIgnore accessor
@@ -69,10 +85,11 @@ public void testSerializeJsonIgnoreAndJsonPropertyRecord() throws Exception {
69
85
70
86
@ Test
71
87
public void testSerializeJsonIgnoreAccessorRecord () throws Exception {
72
- String json = MAPPER . writeValueAsString ( new RecordWithIgnoreAccessor ( 123 , "Bob" ));
73
- assertEquals ( "{ \" id \" : 123}" , json );
88
+ assertEquals ( "{ \" id \" :123}" ,
89
+ MAPPER . writeValueAsString ( new RecordWithIgnoreAccessor ( 123 , "Bob" )) );
74
90
}
75
91
92
+ // [databind#4628]
76
93
@ Test
77
94
public void testDeserializeJsonIgnoreAccessorRecord () throws Exception {
78
95
RecordWithIgnoreAccessor expected = new RecordWithIgnoreAccessor (123 , null );
0 commit comments