Package com.alibaba.fastjson

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


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


        StringWriter out = new StringWriter();
        JSONWriter writer = new JSONWriter(out);
        writer.config(SerializerFeature.UseSingleQuotes, true);
        writer.startObject();
        writer.writeObject("a");
        writer.writeObject("1");
       
        writer.writeObject("b");
        writer.writeObject("2");
       
        writer.writeObject("c");
View Full Code Here

        writer.config(SerializerFeature.UseSingleQuotes, true);
        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

    public void test_writer() throws Exception {
        StringWriter out = new StringWriter();
        JSONWriter writer = new JSONWriter(out);
        writer.config(SerializerFeature.UseSingleQuotes, true);
        writer.writeObject(Collections.emptyMap());
        writer.close();

        Assert.assertEquals("{}", out.toString());
    }
}
View Full Code Here

    public void test_writer() throws Exception {
        StringWriter out = new StringWriter();
        JSONWriter writer = new JSONWriter(out);
        writer.startArray();
        writer.writeObject("1");
        writer.writeObject("2");
        writer.writeObject("3");
        writer.endArray();
        writer.close();
View Full Code Here

    public void test_writer() throws Exception {
        StringWriter out = new StringWriter();
        JSONWriter writer = new JSONWriter(out);
        writer.startArray();
        writer.writeObject("1");
        writer.writeObject("2");
        writer.writeObject("3");
        writer.endArray();
        writer.close();

        Assert.assertEquals("[\"1\",\"2\",\"3\"]", out.toString());
View Full Code Here

        StringWriter out = new StringWriter();
        JSONWriter writer = new JSONWriter(out);
        writer.startArray();
        writer.writeObject("1");
        writer.writeObject("2");
        writer.writeObject("3");
        writer.endArray();
        writer.close();

        Assert.assertEquals("[\"1\",\"2\",\"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.