use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray_2 method test_error_1.
public void test_error_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[['1']]");
parser.config(Feature.AllowISO8601DateFormat, false);
Exception error = null;
try {
parser.parseArrayWithType(new TypeReference<Map<?, ?>>() {
}.getType());
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray_2 method test_error_5.
public void test_error_5() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[]");
parser.config(Feature.AllowISO8601DateFormat, false);
Assert.assertEquals(1, parser.parseArray(new Type[] { Integer[].class }).length);
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray_2 method test_error_0.
public void test_error_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("['1','2'}");
parser.config(Feature.AllowISO8601DateFormat, false);
Exception error = null;
try {
List<Object> list = new ArrayList<Object>();
parser.parseArray(Integer.class, list);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray_2 method test_1.
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("['1','2']");
parser.config(Feature.AllowISO8601DateFormat, false);
List<Object> list = new ArrayList<Object>();
parser.parseArray(Integer.class, list);
Assert.assertEquals(new Integer(1), list.get(0));
Assert.assertEquals(new Integer(2), list.get(1));
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray_2 method test_error_6.
public void test_error_6() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("['1' 1 '2'}");
parser.config(Feature.AllowISO8601DateFormat, false);
Exception error = null;
try {
parser.parseArray(new Type[] { Integer.class });
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Aggregations