use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class UnquoteNameTest method test_unquote_reader.
public void test_unquote_reader() throws Exception {
String text = "{_id:1001}";
JSONReader reader = new JSONReader(new StringReader(text));
Model model = reader.readObject(Model.class);
Assert.assertEquals(1001, model._id);
reader.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class ListStringFieldTest_createError method test_reader.
public void test_reader() throws Exception {
Exception error = null;
try {
String text = "{\"values\":[]}";
JSONReader reader = new JSONReader(new StringReader(text));
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_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 method test_error_rbacket.
public void test_error_rbacket() throws Exception {
String text = "{\"values\":[null,]";
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_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.assertEquals("a", model.values.get(0));
Assert.assertEquals(null, model.values.get(1));
Assert.assertEquals("b", model.values.get(2));
Assert.assertEquals("ab\\c\"", model.values.get(3));
}
Aggregations