File tree Expand file tree Collapse file tree
main/java/com/jsoniter/annotation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public String value() {
4040
4141 @ Override
4242 public String [] from () {
43- return new String [0 ] ;
43+ return new String []{ gsonObj . value ()} ;
4444 }
4545
4646 @ Override
Original file line number Diff line number Diff line change 1+ package com .jsoniter ;
2+
3+ import com .google .gson .Gson ;
4+ import com .google .gson .annotations .SerializedName ;
5+ import com .jsoniter .annotation .GsonAnnotationSupport ;
6+ import junit .framework .TestCase ;
7+
8+ public class TestGson extends TestCase {
9+
10+ public void setUp () {
11+ GsonAnnotationSupport .enable ();
12+ }
13+
14+ public void tearDown () {
15+ GsonAnnotationSupport .disable ();
16+ }
17+
18+ public static class TestObject1 {
19+ @ SerializedName ("field-1" )
20+ public String field1 ;
21+ }
22+
23+ public void test_SerializedName () {
24+ Gson gson = new Gson ();
25+ TestObject1 obj = gson .fromJson ("{\" field-1\" :\" hello\" }" , TestObject1 .class );
26+ assertEquals ("hello" , obj .field1 );
27+ obj = JsonIterator .deserialize ("{\" field-1\" :\" hello\" }" , TestObject1 .class );
28+ assertEquals ("hello" , obj .field1 );
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments