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 3
3
import com .jsoniter .annotation .JsonMissingProperties ;
4
4
import com .jsoniter .annotation .JsonProperty ;
5
5
import com .jsoniter .fuzzy .StringIntDecoder ;
6
+ import com .jsoniter .output .JsonStream ;
6
7
import junit .framework .TestCase ;
7
8
8
9
import java .io .IOException ;
@@ -121,4 +122,23 @@ public void test_required() throws IOException {
121
122
TestObject8 entity = JsonIterator .deserialize (test , TestObject8 .class );
122
123
assertEquals (200 , entity .code2 );
123
124
}
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
+ }
124
144
}
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public void test_encoder() throws IOException {
40
40
public static class TestObject3 {
41
41
public String field1 = "hello" ;
42
42
43
- @ JsonProperty (to = { "field-1" } )
43
+ @ JsonProperty ("field-1" )
44
44
public String getField1 () {
45
45
return field1 ;
46
46
}
@@ -50,4 +50,22 @@ public void test_getter() throws IOException {
50
50
String output = JsonStream .serialize (new TestObject3 ());
51
51
assertEquals ("{\" field-1\" :\" hello\" }" , output );
52
52
}
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
+ }
53
71
}
You can’t perform that action at this time.
0 commit comments