Package com.alibaba.fastjson

Examples of com.alibaba.fastjson.JSONReader.readObject()


    public void test_1() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("{\"id\":123}"));

        reader.startObject();
        reader.readObject();

        Exception error = null;
        try {
            reader.hasNext();
        } catch (Exception e) {
View Full Code Here


        JSONReader reader = new JSONReader(new StringReader("[{\"id\":123}]"));

        reader.startArray();

        VO vo = new VO();
        reader.readObject(vo);

        Assert.assertEquals(123, vo.getId());

        reader.endArray();
View Full Code Here

    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();
    }
View Full Code Here

    public void test_array() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("[[],[],3,null,{\"name\":\"jobs\"},{\"id\":123},{\"id\":1},{\"id\":2}]"));
        reader.startArray();

        JSONArray first = (JSONArray) reader.readObject();
        JSONArray second = (JSONArray) reader.readObject();

        Assert.assertNotNull(first);
        Assert.assertNotNull(second);
View Full Code Here

    public void test_array() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("[[],[],3,null,{\"name\":\"jobs\"},{\"id\":123},{\"id\":1},{\"id\":2}]"));
        reader.startArray();

        JSONArray first = (JSONArray) reader.readObject();
        JSONArray second = (JSONArray) reader.readObject();

        Assert.assertNotNull(first);
        Assert.assertNotNull(second);

        Assert.assertEquals(new Integer(3), reader.readInteger());
View Full Code Here

        Assert.assertEquals(new Integer(3), reader.readInteger());
        Assert.assertNull(reader.readString());
       
        {
            Map<String, Object> map = new HashMap<String, Object>();
            reader.readObject(map);
            Assert.assertEquals("jobs", map.get("name"));
        }

        {
            VO vo = new VO();
View Full Code Here

            Assert.assertEquals("jobs", map.get("name"));
        }

        {
            VO vo = new VO();
            reader.readObject(vo);
            Assert.assertEquals(123, vo.getId());
        }
       
        while (reader.hasNext()) {
            VO vo = reader.readObject(VO.class);
View Full Code Here

            reader.readObject(vo);
            Assert.assertEquals(123, vo.getId());
        }
       
        while (reader.hasNext()) {
            VO vo = reader.readObject(VO.class);
            Assert.assertNotNull(vo);
        }
        reader.endArray();
        reader.close();
    }
View Full Code Here

    JSONReader reader = new JSONReader(new InputStreamReader(is, "UTF-8"));
   
    reader.startObject();
   
    Assert.assertEquals("company", reader.readString());
    Assert.assertTrue(reader.readObject() instanceof JSONObject);
   
    Assert.assertEquals("count", reader.readString());
    Assert.assertEquals(5, reader.readObject());
   
    Assert.assertEquals("pagecount", reader.readString());
View Full Code Here

   
    Assert.assertEquals("company", reader.readString());
    Assert.assertTrue(reader.readObject() instanceof JSONObject);
   
    Assert.assertEquals("count", reader.readString());
    Assert.assertEquals(5, reader.readObject());
   
    Assert.assertEquals("pagecount", reader.readString());
    Assert.assertEquals(0, reader.readObject());
   
    Assert.assertEquals("pageindex", reader.readString());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.