use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class RefTest12 method test_0.
public void test_0() throws Exception {
Entity entity = new Entity(123, new Child());
entity.getChild().setParent(entity);
String text = JSON.toJSONString(entity);
System.out.println(text);
ParserConfig config = new ParserConfig();
config.setAsmEnable(false);
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertEquals(entity2, entity2.getChild().getParent());
System.out.println(JSON.toJSONString(entity2));
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class RefTest14 method test_0.
public void test_0() throws Exception {
Group admin = new Group("admin");
User jobs = new User("jobs");
User sager = new User("sager");
User sdh5724 = new User("sdh5724");
admin.getMembers().add(jobs);
jobs.getGroups().add(admin);
admin.getMembers().add(sager);
sager.getGroups().add(admin);
admin.getMembers().add(sdh5724);
sdh5724.getGroups().add(admin);
sager.setReportTo(sdh5724);
jobs.setReportTo(sdh5724);
SerializeConfig serializeConfig = new SerializeConfig();
serializeConfig.setAsmEnable(false);
String text = JSON.toJSONString(admin, serializeConfig, SerializerFeature.PrettyFormat);
System.out.println(text);
ParserConfig config = new ParserConfig();
config.setAsmEnable(false);
JSON.parseObject(text, Group.class, config, 0);
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class ParserConfigTest method test_0.
public void test_0() throws Exception {
ParserConfig config = new ParserConfig();
config.getDeserializers();
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class WriteClassNameTest_Set2 method test_list.
public void test_list() throws Exception {
A a = new A();
Set<B> set = new LinkedHashSet<B>();
set.add(new B());
set.add(new B1());
a.setList(set);
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
// Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set2$A\",\"list\":[{},{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set2$B1\"}]}",
// text);
ParserConfig parserConfig = new ParserConfig();
parserConfig.addAccept("com.alibaba.json.bvt");
A a1 = (A) JSON.parseObject(text, Object.class, parserConfig);
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue("B", new ArrayList<B>(a1.getList()).get(0) instanceof B || new ArrayList<B>(a1.getList()).get(0) instanceof B1);
Assert.assertTrue("B1", new ArrayList<B>(a1.getList()).get(1) instanceof B || new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class FastjsonSCodec method decodeArray.
public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
ParserConfig config = new ParserConfig();
DefaultJSONParser parser = new DefaultJSONParser(text, config);
parser.config(Feature.DisableCircularReferenceDetect, true);
return parser.parseArray(clazz);
}
Aggregations