use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParserTest method test_parseArrayWithType_error_1.
public void test_parseArrayWithType_error_1() throws Exception {
Method method = DefaultExtJSONParserTest.class.getMethod("f", Collection.class, Collection.class, Collection.class, Collection.class, Collection.class, Collection.class, Collection.class);
Type[] types = method.getGenericParameterTypes();
Exception error = null;
try {
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
DefaultJSONParser parser = new DefaultJSONParser(text);
parser.parseArrayWithType(types[6]);
;
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class InitStringFieldAsEmptyTest method test_1.
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{}");
parser.config(Feature.InitStringFieldAsEmpty, false);
Model model = parser.parseObject(Model.class);
Assert.assertNull(null, model.value);
parser.close();
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParserTest_0 method test_0.
public void test_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("123");
Assert.assertEquals(new Integer(123), (Integer) parser.parse());
parser.config(Feature.IgnoreNotMatch, false);
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParserTest_0 method test_2.
public void test_2() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{}");
parser.parseObject(Object.class);
}
use of com.alibaba.fastjson.parser.DefaultJSONParser in project fastjson by alibaba.
the class DefaultExtJSONParserTest_0 method test_error_2.
public void test_error_2() throws Exception {
JSONException error = null;
try {
DefaultJSONParser parser = new DefaultJSONParser("{\"errorValue\":33}");
parser.parseArray(User.class);
} catch (JSONException e) {
error = e;
}
Assert.assertNotNull(error);
}
Aggregations