use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class JSONCreatorTest_double_obj method test_create_2.
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45D, "菜姐");
String text = JSON.toJSONString(entity);
ParserConfig config = new ParserConfig();
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class JSONCreatorTest_float method test_create_2.
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45F, "菜姐");
String text = JSON.toJSONString(entity);
ParserConfig config = new ParserConfig();
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertTrue(entity.getId() == entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class DenyTest method test_0.
public void test_0() throws Exception {
String text = "{}";
ParserConfig config = new ParserConfig();
config.addDeny(null);
config.addDeny("com.alibaba.json.bvtVO.deny");
Exception error = null;
try {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvtVO.deny$A\"}", Object.class, config, JSON.DEFAULT_PARSER_FEATURE);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
JSON.parseObject(text, B.class, config, JSON.DEFAULT_PARSER_FEATURE);
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class DenyTest9 method test_autoTypeDeny.
public void test_autoTypeDeny() throws Exception {
ParserConfig config = new ParserConfig();
assertFalse(config.isAutoTypeSupport());
config.setAutoTypeSupport(true);
assertTrue(config.isAutoTypeSupport());
Properties properties = new Properties();
properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
properties.put(ParserConfig.AUTOTYPE_ACCEPT, "com.alibaba.json.bvt.parser.deser.deny.DenyTest9");
// -ea -Dfastjson.parser.autoTypeAccept=com.alibaba.json.bvt.parser.deser.deny.DenyTest9
config.configFromPropety(properties);
assertFalse(config.isAutoTypeSupport());
Object obj = JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.DenyTest9$Model\"}", Object.class, config);
assertEquals(Model.class, obj.getClass());
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class DenyTest2 method test_0.
public void test_0() throws Exception {
String text = "{}";
ParserConfig config = new ParserConfig();
Properties properties = new Properties();
properties.put(ParserConfig.DENY_PROPERTY, "com.alibaba.json.bvtVO.deny");
config.configFromPropety(properties);
Exception error = null;
try {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvtVO.deny$A\"}", Object.class, config, JSON.DEFAULT_PARSER_FEATURE);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
JSON.parseObject(text, B.class, config, JSON.DEFAULT_PARSER_FEATURE);
}
Aggregations