Package com.alibaba.fastjson

Examples of com.alibaba.fastjson.JSONWriter.writeObject()


        req.setScreenHeight(100);// 父类中的属性
        req.setScreenWidth(12);// 父类中的属性
        req.setTag("11");
        JSONWriter writer = new JSONWriter(strWriter);
        writer.startArray();
        writer.writeObject(req);
        writer.endArray();
        writer.close();
       
        String text = strWriter.toString();
       
View Full Code Here


            list.add(Integer.toString(i));
        }
        File file = File.createTempFile("fastjson-stream-large", "json");
        JSONWriter writer = new JSONWriter(new FileWriter(file));
        writer.startArray();
        writer.writeObject(list);
        writer.endArray();
        writer.close();

        System.out.println(FileUtils.readFileToString(file));
View Full Code Here

    public void test_writer() throws Exception {
        StringWriter out = new StringWriter();
        JSONWriter writer = new JSONWriter(out);
        writer.startObject();
        writer.writeObject("a");
        writer.writeObject("1");
       
        writer.writeObject("b");
        writer.writeObject("2");
       
View Full Code Here

    public void test_writer() throws Exception {
        StringWriter out = new StringWriter();
        JSONWriter writer = new JSONWriter(out);
        writer.startObject();
        writer.writeObject("a");
        writer.writeObject("1");
       
        writer.writeObject("b");
        writer.writeObject("2");
       
        writer.writeObject("c");
View Full Code Here

        JSONWriter writer = new JSONWriter(out);
        writer.startObject();
        writer.writeObject("a");
        writer.writeObject("1");
       
        writer.writeObject("b");
        writer.writeObject("2");
       
        writer.writeObject("c");
        writer.writeObject("3");
       
View Full Code Here

        writer.startObject();
        writer.writeObject("a");
        writer.writeObject("1");
       
        writer.writeObject("b");
        writer.writeObject("2");
       
        writer.writeObject("c");
        writer.writeObject("3");
       
        writer.endObject();
View Full Code Here

        writer.writeObject("1");
       
        writer.writeObject("b");
        writer.writeObject("2");
       
        writer.writeObject("c");
        writer.writeObject("3");
       
        writer.endObject();
        writer.close();
View Full Code Here

       
        writer.writeObject("b");
        writer.writeObject("2");
       
        writer.writeObject("c");
        writer.writeObject("3");
       
        writer.endObject();
        writer.close();

        Assert.assertEquals("{\"a\":\"1\",\"b\":\"2\",\"c\":\"3\"}", out.toString());
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.