use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class ListStringFieldTest_stream method test_error_nu.
public void test_error_nu() throws Exception {
String text = "{\"values\":[nu";
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_TreeSet method test_list.
public void test_list() throws Exception {
String text = "{\"values\":[\"a\",\"b\",\"ab\\\\c\"]}";
JSONReader reader = new JSONReader(new StringReader(text));
Model model = reader.readObject(Model.class);
Assert.assertEquals(3, model.values.size());
Assert.assertTrue(model.values.contains("a"));
Assert.assertTrue(model.values.contains("b"));
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class ListStringFieldTest_stream_TreeSet 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_TreeSet 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 ListStringFieldTest_stream_TreeSet method test_map_empty.
public void test_map_empty() throws Exception {
String text = "{\"model\":{\"values\":[]}}";
JSONReader reader = new JSONReader(new StringReader(text));
Map<String, Model> map = reader.readObject(new TypeReference<Map<String, Model>>() {
});
Model model = (Model) map.get("model");
Assert.assertEquals(0, model.values.size());
}
Aggregations