use of com.alibaba.fastjson.parser.DefaultJSONParser 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.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParserTest_3 method test_0.
public void test_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v1:3}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParserTest_6 method test_1.
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{'value':{\"value\":3,\"id\":1}}");
parser.config(Feature.AllowArbitraryCommas, false);
Entity entity = new Entity();
parser.parseObject(entity);
Assert.assertEquals(3, entity.getValue().getValue());
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray method test_16.
public void test_16() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[[1]]");
parser.config(Feature.AllowISO8601DateFormat, false);
Object[] array = parser.parseArray(new Type[] { new TypeReference<List<Integer>>() {
}.getType() });
Assert.assertEquals(new Integer(1), ((List<Integer>) (array[0])).get(0));
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray method test_error.
public void test_error() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{}");
Exception error = null;
try {
parser.parseArray(new ArrayList());
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Aggregations