use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class JSONReader_map method test_map.
public void test_map() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{\"id\":123}"));
Map<String, Object> map = new HashMap<String, Object>();
reader.readObject(map);
Assert.assertEquals(123, map.get("id"));
reader.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class JSONReader_map method test_array.
public void test_array() throws Exception {
JSONReader reader = new JSONReader(new StringReader("[{\"id\":123}]"));
reader.startArray();
Map<String, Object> map = new HashMap<String, Object>();
reader.readObject(map);
Assert.assertEquals(123, map.get("id"));
reader.endArray();
reader.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class JSONReader_obj method test_obj.
public void test_obj() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{\"id\":123}"));
VO vo = new VO();
reader.readObject(vo);
Assert.assertEquals(123, vo.getId());
reader.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class JSONReader_obj_2 method test_array.
public void test_array() throws Exception {
JSONReader reader = new JSONReader(new StringReader("[{\"id\":123}]"));
reader.startArray();
VO vo = reader.readObject(VO.class);
Assert.assertEquals(123, vo.getId());
reader.endArray();
reader.close();
}
use of com.alibaba.fastjson.JSONReader in project fastjson by alibaba.
the class JSONReader_obj_3 method test_obj.
public void test_obj() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{\"id\":123}"));
reader.startObject();
Assert.assertEquals("id", reader.readString());
Assert.assertEquals(Integer.valueOf(123), reader.readInteger());
reader.endObject();
reader.close();
}
Aggregations