@@ -63,6 +63,25 @@ static class MapWrapper {
63
63
}
64
64
}
65
65
66
+ // for [databind#1060]
67
+ static class IgnoreForListValuesXY {
68
+ @ JsonIgnoreProperties ({ "x" })
69
+ public List <XY > coordinates ;
70
+
71
+ public IgnoreForListValuesXY () {
72
+ coordinates = Arrays .asList (new XY ());
73
+ }
74
+ }
75
+
76
+ static class IgnoreForListValuesXYZ {
77
+ @ JsonIgnoreProperties ({ "y" })
78
+ public List <XYZ > coordinates ;
79
+
80
+ public IgnoreForListValuesXYZ () {
81
+ coordinates = Arrays .asList (new XYZ ());
82
+ }
83
+ }
84
+
66
85
/*
67
86
/****************************************************************
68
87
/* Unit tests
@@ -129,4 +148,17 @@ public void testIgnoreViaConfigOverride() throws Exception
129
148
.setIgnorals (JsonIgnoreProperties .Value .forIgnoredProperties ("x" ));
130
149
assertEquals ("{\" y\" :3}" , mapper .writeValueAsString (new Point (2 , 3 )));
131
150
}
151
+
152
+ // for [databind#1060]
153
+ // Ensure that `@JsonIgnoreProperties` applies to POJOs within lists, too
154
+ public void testIgnoreForListValues () throws Exception
155
+ {
156
+ // should apply to elements
157
+ assertEquals (aposToQuotes ("{'coordinates':[{'y':2}]}" ),
158
+ MAPPER .writeValueAsString (new IgnoreForListValuesXY ()));
159
+
160
+ // and combine values too
161
+ assertEquals (aposToQuotes ("{'coordinates':[{'z':3}]}" ),
162
+ MAPPER .writeValueAsString (new IgnoreForListValuesXYZ ()));
163
+ }
132
164
}
0 commit comments