use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class ReaderLongFieldTest method test_long_error_map.
public void test_long_error_map() throws Exception {
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader("{\"model\":{\"value\":3001,\"value2\":-4001}["));
reader.readObject(new TypeReference<Map<String, Model>>() {
});
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class ListStringFieldTest_stream method test_null.
public void test_null() throws Exception {
String text = "{\"values\":null}";
JSONReader reader = new JSONReader(new StringReader(text));
Model model = reader.readObject(Model.class);
Assert.assertNull(model.values);
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class ListStringFieldTest_stream method test_error.
public void test_error() throws Exception {
String text = "{\"values\":[1";
JSONReader reader = new JSONReader(new StringReader(text));
Exception error = null;
try {
reader.readObject(Model.class);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class ListStringFieldTest_stream method test_empty.
public void test_empty() throws Exception {
String text = "{\"values\":[]}";
JSONReader reader = new JSONReader(new StringReader(text));
Model model = reader.readObject(Model.class);
Assert.assertEquals(0, model.values.size());
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class ListStringFieldTest_stream method test_error_2.
public void test_error_2() throws Exception {
String text = "{\"model\":{\"values\":[][";
JSONReader reader = new JSONReader(new StringReader(text));
Exception error = null;
try {
reader.readObject(new TypeReference<Map<String, Model>>() {
});
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Aggregations