Package com.alibaba.fastjson

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


public class JSONReader_obj_3 extends TestCase {

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


    }

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

        reader.startObject();

        Assert.assertEquals("val", reader.readString());

        reader.startObject();
        Assert.assertEquals("id", reader.readString());
View Full Code Here

        reader.startObject();

        Assert.assertEquals("val", reader.readString());

        reader.startObject();
        Assert.assertEquals("id", reader.readString());
        Assert.assertEquals(Integer.valueOf(123), reader.readInteger());
        reader.endObject();

        reader.endObject();
View Full Code Here

        reader.startArray();

       
       
        Assert.assertTrue(reader.hasNext());
        reader.startObject();
        reader.endObject();
       
        Assert.assertTrue(reader.hasNext());
        reader.startObject();
        reader.endObject();
View Full Code Here

        Assert.assertTrue(reader.hasNext());
        reader.startObject();
        reader.endObject();
       
        Assert.assertTrue(reader.hasNext());
        reader.startObject();
        reader.endObject();
       
        int count = 2;
       
        while (reader.hasNext()) {
View Full Code Here

        reader.endObject();
       
        int count = 2;
       
        while (reader.hasNext()) {
            reader.startObject();
            reader.endObject();
            count++;
        }
        Assert.assertEquals(10, count);
View Full Code Here

    public void test_read() throws Exception {

        JSONReader reader = new JSONReader(new StringReader(text));

        reader.startObject();

        int count = 0;
        while (reader.hasNext()) {
            String key = (String) reader.readObject();
            String value = reader.readString();
View Full Code Here

    }

    public void test_read_1() throws Exception {
        JSONReader reader = new JSONReader(new JSONScanner(text));

        reader.startObject();

        int count = 0;
        while (reader.hasNext()) {
            String key = (String) reader.readObject();
            Long value = reader.readLong();
View Full Code Here

    String resource = "2.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        
    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());
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.