From 25cfe1077a7f94aa687ac962a4120c5ff3bb7cee Mon Sep 17 00:00:00 2001 From: rRajivramachandran Date: Sun, 5 Nov 2023 18:51:47 -0600 Subject: [PATCH] Add auto type support to remove dependency among tests --- .../java/com/alibaba/fastjson/serializer/TestParse.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/alibaba/fastjson/serializer/TestParse.java b/src/test/java/com/alibaba/fastjson/serializer/TestParse.java index e805dd0976..3ca0f1de0a 100644 --- a/src/test/java/com/alibaba/fastjson/serializer/TestParse.java +++ b/src/test/java/com/alibaba/fastjson/serializer/TestParse.java @@ -2,6 +2,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.parser.ParserConfig; import org.junit.Before; import org.junit.Test; @@ -28,9 +29,11 @@ public void prepareJsonString() { @Test public void testParse() { - logger.info("parsing json string:" + jsonString); - TestBean testBean = (TestBean) JSON.parse(jsonString); - assert testBean.getData() != null; + logger.info("parsing json string:" + jsonString); + final ParserConfig parserConfig = new ParserConfig(); + parserConfig.setAutoTypeSupport(true); + TestBean testBean = (TestBean) JSON.parse(jsonString, parserConfig); + assert testBean.getData() != null; assert "tester".equals(testBean.getName()); assert "value".equals(testBean.getData().getString("key")); }