From fd2dc77feb7a6d54e262a144f72362e9baaa46e4 Mon Sep 17 00:00:00 2001 From: "shaojin.wensj" Date: Wed, 3 Aug 2022 20:50:02 +0800 Subject: [PATCH] add testcase for issue #605 --- .../alibaba/fastjson2/issues/Issue605.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 core/src/test/java/com/alibaba/fastjson2/issues/Issue605.java diff --git a/core/src/test/java/com/alibaba/fastjson2/issues/Issue605.java b/core/src/test/java/com/alibaba/fastjson2/issues/Issue605.java new file mode 100644 index 0000000000..e3e925701e --- /dev/null +++ b/core/src/test/java/com/alibaba/fastjson2/issues/Issue605.java @@ -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 parems; + } +}