use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class TestNonASM method test_no_asm.
public void test_no_asm() throws Exception {
ParserConfig mapping = new ParserConfig();
mapping.setAsmEnable(false);
Assert.assertEquals(false, mapping.isAsmEnable());
mapping.setAsmEnable(true);
Assert.assertEquals(true, mapping.isAsmEnable());
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class Issue585 method setUp.
protected void setUp() throws Exception {
ParserConfig.global = new ParserConfig();
if (!JSON.DEFAULT_TYPE_KEY.equals("mySpace")) {
JSON.setDefaultTypeKey("mySpace");
}
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue585.");
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class Issue96 method xx_testCast.
public void xx_testCast() {
Page<Sub> page = new Page<Sub>(new Sub(1));
Type type = new TypeReference<Page<Sub>>() {
}.getType();
ParserConfig parserconfig = ParserConfig.getGlobalInstance();
// !!!! this will fail:
// !!!! com.alibaba.fastjson.JSONException: can not cast to : Page<Sub> TypeUtils.java:719
Page<Sub> page1 = TypeUtils.cast(page, type, parserconfig);
System.out.println(page1.sub.getClass());
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class NamingSerTest method test_camel.
public void test_camel() throws Exception {
SerializeConfig config = new SerializeConfig();
config.propertyNamingStrategy = PropertyNamingStrategy.CamelCase;
Model model = new Model();
model.personId = 1001;
String text = JSON.toJSONString(model, config);
Assert.assertEquals("{\"personId\":1001}", text);
ParserConfig parserConfig = new ParserConfig();
parserConfig.propertyNamingStrategy = PropertyNamingStrategy.CamelCase;
Model model2 = JSON.parseObject(text, Model.class, parserConfig);
Assert.assertEquals(model.personId, model2.personId);
Model model3 = JSON.parseObject(text, Model.class);
Assert.assertEquals(model.personId, model3.personId);
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class NamingSerTest method test_snake.
public void test_snake() throws Exception {
SerializeConfig config = new SerializeConfig();
config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
Model model = new Model();
model.personId = 1001;
String text = JSON.toJSONString(model, config);
Assert.assertEquals("{\"person_id\":1001}", text);
ParserConfig parserConfig = new ParserConfig();
parserConfig.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
Model model2 = JSON.parseObject(text, Model.class, parserConfig);
Assert.assertEquals(model.personId, model2.personId);
Model model3 = JSON.parseObject(text, Model.class);
Assert.assertEquals(model.personId, model3.personId);
}
Aggregations