use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray method test_error_2.
public void test_error_2() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{}");
Exception error = null;
try {
parser.accept(JSONToken.NULL);
} 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_12.
public void test_12() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("['1']");
Object[] array = parser.parseArray(new Type[] { int.class });
Assert.assertEquals(new Integer(1), array[0]);
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray method test_8.
public void test_8() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53.254\"");
parser.config(Feature.AllowISO8601DateFormat, true);
Object value = parser.parse();
Assert.assertEquals(new Date(1294552193254L), value);
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParser_parseArray method test_1.
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[1,2,3]");
parser.config(Feature.AllowArbitraryCommas, true);
List list = new ArrayList();
parser.parseArray(int.class, list);
Assert.assertEquals("[1, 2, 3]", list.toString());
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultJSONParserTest2 method test_4.
public void test_4() throws Exception {
JSONException error = null;
try {
DefaultJSONParser parser = new DefaultJSONParser("{");
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.parse();
} catch (JSONException e) {
error = e;
}
Assert.assertNotNull(error);
}
Aggregations