Skip to content

Commit

Permalink
fix testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Mar 24, 2024
1 parent 1e65fd0 commit 1d91050
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/src/test/java/com/alibaba/fastjson2/issues/Issue567.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.alibaba.fastjson2.issues;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.JSONWriter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;

public class Issue567 {
@Test
public void test() {
Expand All @@ -15,10 +18,9 @@ public void test() {
Bean test = new Bean();
test.setConfig(catConfig);
String json = JSON.toJSONString(test, JSONWriter.Feature.WriteClassName);
System.out.println(json);
//JSON结果 {"@type":"com.example.fastjson2.Test","config":{"@type":"com.example.fastjson2.Test$CatConfig","height":"200","width":"100"}}
Bean t = (Bean) JSON.parseObject(json, Bean.class);
System.out.println(t.getConfig());
Bean t = (Bean) JSON.parseObject(json, Bean.class, JSONReader.Feature.SupportAutoType);
assertTrue(t.getConfig() instanceof Bean.CatConfig);
//对象结果:Test.Config()
}

Expand Down

0 comments on commit 1d91050

Please sign in to comment.