use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class JSONCreatorTest 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());
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class DenyTest3 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,,aa");
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);
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class DenyTest5 method test_c3p0.
public void test_c3p0() throws Exception {
ParserConfig config = new ParserConfig();
config.setAutoTypeSupport(true);
Object obj = null;
Exception error = null;
try {
obj = JSON.parseObject("{\"@type\":\"com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase\"}", Object.class, config);
System.out.println(obj.getClass());
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class BooleanFieldSerializerTest method parseObjectNoAsm.
@SuppressWarnings("unchecked")
public static final <T> T parseObjectNoAsm(String input, Type clazz, int featureValues, Feature... features) {
if (input == null) {
return null;
}
for (Feature feature : features) {
featureValues = Feature.config(featureValues, feature, true);
}
ParserConfig config = new ParserConfig();
config.setAsmEnable(false);
DefaultJSONParser parser = new DefaultJSONParser(input, config, featureValues);
T value = (T) parser.parseObject(clazz);
if (clazz != JSONArray.class) {
parser.close();
}
return (T) value;
}
use of com.alibaba.fastjson.parser.ParserConfig in project fastjson by alibaba.
the class BooleanFieldSerializerTest_primitive method parseObjectNoAsm.
@SuppressWarnings("unchecked")
public static final <T> T parseObjectNoAsm(String input, Type clazz, int featureValues, Feature... features) {
if (input == null) {
return null;
}
for (Feature feature : features) {
featureValues = Feature.config(featureValues, feature, true);
}
ParserConfig config = new ParserConfig();
config.setAsmEnable(false);
DefaultJSONParser parser = new DefaultJSONParser(input, config, featureValues);
T value = (T) parser.parseObject(clazz);
if (clazz != JSONArray.class) {
parser.close();
}
return (T) value;
}
Aggregations