use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class ListStringFieldTest_stream_hashSet 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);
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class ListStringFieldTest_stream_hashSet method test_list.
public void test_list() throws Exception {
String text = "{\"values\":[\"a\",null,\"b\",\"ab\\\\c\"]}";
JSONReader reader = new JSONReader(new StringReader(text));
Model model = reader.readObject(Model.class);
Assert.assertEquals(4, model.values.size());
Assert.assertTrue(model.values.contains("a"));
Assert.assertTrue(model.values.contains("b"));
Assert.assertTrue(model.values.contains(null));
Assert.assertTrue(model.values.contains("ab\\c"));
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class ListStringFieldTest_stream_hashSet method test_notMatch.
public void test_notMatch() throws Exception {
String text = "{\"value\":[]}";
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 ReaderBooleanFieldTest method test_bool_error_f2.
public void test_bool_error_f2() throws Exception {
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader("{\"value\":fal}"));
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 ReaderBooleanFieldTest method test_bool_error_2.
public void test_bool_error_2() throws Exception {
Exception error = null;
try {
JSONReader reader = new JSONReader(new StringReader("{\"value\":tru}"));
reader.readObject(Model.class);
} catch (JSONException ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Aggregations