use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class ListFieldTest method test_codec_null.
public void test_codec_null() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
Assert.assertEquals("{\"value\":null}", text);
ParserConfig config = new ParserConfig();
config.setAutoTypeSupport(true);
config.setAsmEnable(false);
V0 v1 = JSON.parseObject(text, V0.class, config, JSON.DEFAULT_PARSER_FEATURE);
Assert.assertEquals(v1.getValue(), v.getValue());
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class Bug_102_for_rongganlin method test_bug.
public void test_bug() throws Exception {
TestBean testProcessInfo = new TestBean();
com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
jo.put("id", 121);
ParserConfig config = new ParserConfig();
testProcessInfo = TypeUtils.cast(jo, TestBean.class, config);
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class StringFieldTest method test_codec_null.
public void test_codec_null() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
Assert.assertEquals("{\"value\":null}", text);
ParserConfig config = new ParserConfig();
config.setAsmEnable(false);
V0 v1 = JSON.parseObject(text, V0.class, config, JSON.DEFAULT_PARSER_FEATURE);
Assert.assertEquals(v1.getValue(), v.getValue());
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class DefaultExtJSONParserTest_3 method test_7.
public void test_7() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("123");
ParserConfig mapping = new ParserConfig();
parser.setConfig(mapping);
Assert.assertEquals(mapping, parser.getConfig());
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class JSONCreatorFactoryTest method test_create_2.
public void test_create_2() throws Exception {
Entity entity = new Entity(123, "菜姐");
String text = JSON.toJSONString(entity);
ParserConfig config = new ParserConfig();
config.setAsmEnable(false);
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertEquals(entity.getId(), entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
Aggregations