use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class JSONReader_string method test_array_3.
public void test_array_3() throws Exception {
JSONReader reader = new JSONReader(new StringReader("[[[\"abc\"]]]"));
reader.startArray();
reader.startArray();
reader.startArray();
Assert.assertEquals("abc", reader.readString());
reader.endArray();
reader.endArray();
reader.endArray();
reader.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class JSONReaderTest_0 method test_read.
public void test_read() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{}"));
reader.config(Feature.AllowArbitraryCommas, true);
JSONObject object = (JSONObject) reader.readObject();
Assert.assertNotNull(object);
reader.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class BooleanFieldTest2 method test_true_reader.
public void test_true_reader() throws Exception {
String text = "{\"f001\":1001,\"value\":true}";
JSONReader reader = new JSONReader(new StringReader(text));
Model model = reader.readObject(Model.class);
Assert.assertTrue(model.value);
reader.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class BooleanFieldTest2 method test_false_reader.
public void test_false_reader() throws Exception {
String text = "{\"f001\":1001,\"value\":false}";
JSONReader reader = new JSONReader(new StringReader(text));
Model model = reader.readObject(Model.class);
Assert.assertFalse(model.value);
reader.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class IntFieldTest2 method test_model_map.
public void test_model_map() throws Exception {
String text = "{\"model\":{\"id\":-1001,\"id2\":-1002}}";
JSONReader reader = new JSONReader(new StringReader(text));
Map<String, Model> map = reader.readObject(new TypeReference<Map<String, Model>>() {
});
Model model2 = map.get("model");
Assert.assertEquals(-1001, model2.id);
Assert.assertEquals(-1002, model2.id2);
reader.close();
}
Aggregations