Package com.alibaba.fastjson

Examples of com.alibaba.fastjson.JSONReader


        if (StringUtils.isNotEmpty(key.getKey()) && StringUtils.isNotEmpty(key.getCrc())) {
            decodeFile(archiveFile, key.getKey(), key.getCrc());
        }

        InputStream input = null;
        JSONReader reader = null;
        try {
            input = new BufferedInputStream(new FileInputStream(archiveFile));
            DbBatch dbBatch = new DbBatch();
            byte[] lengthBytes = new byte[4];
            input.read(lengthBytes);
View Full Code Here


    String text = "[{},{},{},{},{} ,{},{},{},{},{}]";

    public void test_read() throws Exception {

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

        int count = 0;
        while (reader.hasNext()) {
            reader.startObject();
            reader.endObject();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endArray();
        reader.close();
    }
View Full Code Here

        reader.endArray();
        reader.close();
    }

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

        int count = 0;
        while (reader.hasNext()) {
            reader.startObject();
            reader.endObject();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endArray();
        reader.close();
    }
View Full Code Here

    String text = "{\"f0\":0,\"f1\":1,\"f2\":2,\"f3\":3,\"f4\":4, " + //
                  "\"f5\":5,\"f6\":6,\"f7\":7,\"f8\":8,\"f9\":9}";

    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();
            Long value = reader.readLong();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endObject();
        reader.close();
    }
View Full Code Here

        reader.endObject();
        reader.close();
    }

    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();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endObject();
        reader.close();
    }
View Full Code Here

            buf.append("[{\"type\":\"");
            for (int i = 0; i < 8180; ++i) {
                buf.append('A');
            }
            buf.append("\\t");
            JSONReader reader = new JSONReader(new StringReader(buf.toString()));
            reader.readObject();
            reader.close();
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

    String text = "{f0:0,f1:1,f2:2,f3:3,f4:4, " + //
                  "f5:5,f6:6,f7:7,f8:8,f9:9}";

    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();
            Integer value = reader.readInteger();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endObject();
        reader.close();
    }
View Full Code Here

        reader.endObject();
        reader.close();
    }

    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();
            Integer value = reader.readInteger();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endObject();
        reader.close();
    }
View Full Code Here

public class JSONReaderScannerTest_error extends TestCase {

    public void test_e() throws Exception {
        Exception error = null;
        try {
            new JSONReader(new MyReader());
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

    String text = "{\"f0\":{},\"f1\":{},\"f2\":{},\"f3\":{},\"f4\":{}, " + //
                  "\"f5\":{},\"f6\":{},\"f7\":{},\"f8\":{},\"f9\":{}}";

    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();
            Object value = reader.readObject();
            Assert.assertNotNull(key);
            Assert.assertNotNull(value);
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endObject();
        reader.close();
    }
View Full Code Here

TOP

Related Classes of com.alibaba.fastjson.JSONReader

Copyright © 2018 www.massapicom. 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.