Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
73 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
src/test/java/com/alibaba/json/bvt/serializer/JSONFieldTest6.java
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
src/test/java/com/alibaba/json/bvt/serializer/JSONFieldTest_unwrapped_0.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.alibaba.json.bvt.serializer; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.annotation.JSONField; | ||
import junit.framework.TestCase; | ||
import org.junit.Assert; | ||
|
||
public class JSONFieldTest_unwrapped_0 extends TestCase { | ||
|
||
public void test_jsonField() throws Exception { | ||
VO vo = new VO(); | ||
vo.id = 123; | ||
vo.localtion = new Localtion(127, 37); | ||
|
||
String text = JSON.toJSONString(vo); | ||
Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text); | ||
|
||
} | ||
|
||
public static class VO { | ||
public int id; | ||
|
||
@JSONField(unwrapped = true) | ||
public Localtion localtion; | ||
} | ||
|
||
public static class Localtion { | ||
public int longitude; | ||
public int latitude; | ||
|
||
public Localtion(int longitude, int latitude) { | ||
this.longitude = longitude; | ||
this.latitude = latitude; | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/test/java/com/alibaba/json/bvt/serializer/JSONFieldTest_unwrapped_1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.alibaba.json.bvt.serializer; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.annotation.JSONField; | ||
import junit.framework.TestCase; | ||
import org.junit.Assert; | ||
|
||
public class JSONFieldTest_unwrapped_1 extends TestCase { | ||
|
||
public void test_jsonField() throws Exception { | ||
VO vo = new VO(); | ||
vo.id = 123; | ||
vo.localtion = new Localtion(127, 37); | ||
|
||
String text = JSON.toJSONString(vo); | ||
Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text); | ||
|
||
} | ||
|
||
public static class VO { | ||
public int id; | ||
|
||
@JSONField(unwrapped = true) | ||
public Localtion localtion; | ||
} | ||
|
||
public static class Localtion { | ||
public int longitude; | ||
public int latitude; | ||
|
||
public Localtion(int longitude, int latitude) { | ||
this.longitude = longitude; | ||
this.latitude = latitude; | ||
} | ||
} | ||
} |