use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray method test_17.
public void test_17() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[]");
Object[] array = parser.parseArray(new Type[] { Integer[].class });
Integer[] values = (Integer[]) array[0];
Assert.assertEquals(0, values.length);
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray method test_18.
public void test_18() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("null");
parser.config(Feature.AllowISO8601DateFormat, false);
List<Integer> list = (List<Integer>) parser.parseArrayWithType(new TypeReference<List<Integer>>() {
}.getType());
Assert.assertEquals(null, list);
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray method test_error_7.
public void test_error_7() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{1}");
parser.config(Feature.AllowISO8601DateFormat, false);
Exception error = null;
try {
parser.parseArray(new Type[] {});
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray method test_3.
public void test_3() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[1,2,3]");
parser.config(Feature.AllowArbitraryCommas, true);
List list = new ArrayList();
parser.parseArray(BigDecimal.class, list);
Assert.assertEquals("[1, 2, 3]", list.toString());
Assert.assertEquals(new BigDecimal("1"), list.get(0));
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray method test_10.
public void test_10() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[1,2,3]");
Object[] array = parser.parseArray(new Type[] { Integer[].class });
Integer[] values = (Integer[]) array[0];
Assert.assertEquals(new Integer(1), values[0]);
Assert.assertEquals(new Integer(2), values[1]);
Assert.assertEquals(new Integer(3), values[2]);
}
Aggregations