File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed
src/test/java/com/jsoniter Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 33import com .jsoniter .annotation .JsonMissingProperties ;
44import com .jsoniter .annotation .JsonProperty ;
55import com .jsoniter .fuzzy .StringIntDecoder ;
6+ import com .jsoniter .output .JsonStream ;
67import junit .framework .TestCase ;
78
89import java .io .IOException ;
@@ -121,4 +122,23 @@ public void test_required() throws IOException {
121122 TestObject8 entity = JsonIterator .deserialize (test , TestObject8 .class );
122123 assertEquals (200 , entity .code2 );
123124 }
125+
126+ public static class TestObject9 {
127+ private String field1 = "hello" ;
128+
129+ public String getField1 () {
130+ return field1 ;
131+ }
132+
133+ @ JsonProperty ("field-1" )
134+ public void setField1 (String field1 ) {
135+ this .field1 = field1 ;
136+ }
137+ }
138+
139+ public void test_getter_and_setter () throws IOException {
140+ String test ="{\" field-1\" :\" hi\" }" ;
141+ TestObject9 entity = JsonIterator .deserialize (test , TestObject9 .class );
142+ assertEquals ("hi" , entity .getField1 ());
143+ }
124144}
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public void test_encoder() throws IOException {
4040 public static class TestObject3 {
4141 public String field1 = "hello" ;
4242
43- @ JsonProperty (to = { "field-1" } )
43+ @ JsonProperty ("field-1" )
4444 public String getField1 () {
4545 return field1 ;
4646 }
@@ -50,4 +50,22 @@ public void test_getter() throws IOException {
5050 String output = JsonStream .serialize (new TestObject3 ());
5151 assertEquals ("{\" field-1\" :\" hello\" }" , output );
5252 }
53+
54+ public static class TestObject4 {
55+ private String field1 = "hello" ;
56+
57+ @ JsonProperty ("field-1" )
58+ public String getField1 () {
59+ return field1 ;
60+ }
61+
62+ public void setField1 (String field1 ) {
63+ this .field1 = field1 ;
64+ }
65+ }
66+
67+ public void test_getter_and_setter () throws IOException {
68+ String output = JsonStream .serialize (new TestObject4 ());
69+ assertEquals ("{\" field-1\" :\" hello\" }" , output );
70+ }
5371}
You can’t perform that action at this time.
0 commit comments