-
Notifications
You must be signed in to change notification settings - Fork 495
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
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
core/src/test/java/com/alibaba/fastjson2/issues/Issue605.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,39 @@ | ||
package com.alibaba.fastjson2.issues; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.experimental.Accessors; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue605 { | ||
@Test | ||
public void test() { | ||
WinningInformationBo bo = new WinningInformationBo(); | ||
bo.isSuccess = true; | ||
bo.wxId = "abc"; | ||
bo.parems = new HashMap<>(); | ||
|
||
String str = JSON.toJSONString(bo); | ||
assertEquals("{\"parems\":{},\"success\":true,\"wxId\":\"abc\"}", str); | ||
|
||
WinningInformationBo bo1 = JSON.parseObject(str, WinningInformationBo.class); | ||
assertEquals(bo.wxId, bo1.wxId); | ||
assertEquals(bo.isSuccess, bo1.isSuccess); | ||
assertEquals(bo.parems, bo1.parems); | ||
} | ||
|
||
@Setter | ||
@Getter | ||
@Accessors(chain = true) | ||
public static class WinningInformationBo{ | ||
private boolean isSuccess; | ||
private String wxId; | ||
private Map<String, String> parems; | ||
} | ||
} |