Skip to content

Commit

Permalink
Add auto type support to remove dependency among tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rRajivramachandran committed Nov 13, 2023
1 parent c942c83 commit 33e2ae8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/test/java/com/alibaba/fastjson/serializer/TestParse.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class TestParse {
private final Logger logger = Logger.getLogger(TestParse.class.getSimpleName());

private String jsonString;

@Before
public void prepareJsonString() {
TestBean bean = new TestBean();
Expand All @@ -28,8 +27,10 @@ public void prepareJsonString() {

@Test
public void testParse() {
logger.info("parsing json string:" + jsonString);
TestBean testBean = (TestBean) JSON.parse(jsonString);
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"));
Expand Down

0 comments on commit 33e2ae8

Please sign in to comment.