File tree 1 file changed +43
-0
lines changed
src/test/java/com/fasterxml/jackson/databind/filter
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .databind .filter ;
2
+
3
+ import com .fasterxml .jackson .annotation .JsonIgnoreProperties ;
4
+ import com .fasterxml .jackson .annotation .JsonPropertyOrder ;
5
+ import com .fasterxml .jackson .databind .*;
6
+
7
+ public class JsonIgnoreProperties1595Test extends BaseMapTest
8
+ {
9
+ @ JsonIgnoreProperties (value = {"name" }, allowSetters = true )
10
+ @ JsonPropertyOrder (alphabetic =true )
11
+ static class Simple {
12
+ private int id ;
13
+ private String name ;
14
+
15
+ public int getId () {
16
+ return id ;
17
+ }
18
+
19
+ public void setId (int id ) {
20
+ this .id = id ;
21
+ }
22
+
23
+ public String getName () {
24
+ return name ;
25
+ }
26
+
27
+ public void setName (String name ) {
28
+ this .name = name ;
29
+ }
30
+ }
31
+
32
+ public void testIgnoreGetterNotSetter1595 () throws Exception
33
+ {
34
+ ObjectMapper mapper = new ObjectMapper ();
35
+ Simple config = new Simple ();
36
+ config .setId (123 );
37
+ config .setName ("jack" );
38
+ String json = mapper .writeValueAsString (config );
39
+ assertEquals (aposToQuotes ("{'id':123}" ), json );
40
+ Simple des = mapper .readValue (aposToQuotes ("{'id':123,'name':'jack'}" ), Simple .class );
41
+ assertEquals ("jack" , des .getName ());
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments