Package com.alibaba.fastjson.serializer

Examples of com.alibaba.fastjson.serializer.JSONSerializer.config()


    public void test_6() throws Exception {
        JSONSerializer serializer = new JSONSerializer(new SerializeWriter());

        serializer.config(SerializerFeature.QuoteFieldNames, false);
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
        serializer.config(SerializerFeature.UseSingleQuotes, true);
        Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.UseSingleQuotes));

        serializer.write(Collections.singletonMap("a'ge", 33));

        Assert.assertEquals("{'a\\'ge':33}", serializer.getWriter().toString());
View Full Code Here


    }

    public void test_6_s() throws Exception {
        JSONSerializer serializer = new JSONSerializer(new SerializeWriter());

        serializer.config(SerializerFeature.QuoteFieldNames, false);
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
        serializer.config(SerializerFeature.UseSingleQuotes, true);
        Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.UseSingleQuotes));

        serializer.write(Collections.singletonMap("a'ge", 33));
View Full Code Here

    public void test_6_s() throws Exception {
        JSONSerializer serializer = new JSONSerializer(new SerializeWriter());

        serializer.config(SerializerFeature.QuoteFieldNames, false);
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
        serializer.config(SerializerFeature.UseSingleQuotes, true);
        Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.UseSingleQuotes));

        serializer.write(Collections.singletonMap("a'ge", 33));

        Assert.assertEquals("{'a\\'ge':33}", serializer.getWriter().toString());
View Full Code Here

    }

    public void test_7() throws Exception {
        JSONSerializer serializer = new JSONSerializer();

        serializer.config(SerializerFeature.QuoteFieldNames, false);
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.QuoteFieldNames));

        serializer.write(new User(33));

        Assert.assertEquals("{age:33}", serializer.getWriter().toString());
View Full Code Here

    }

    public void test_7_s() throws Exception {
        JSONSerializer serializer = new JSONSerializer();

        serializer.config(SerializerFeature.QuoteFieldNames, false);
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.QuoteFieldNames));

        serializer.write(new User(33));

        Assert.assertEquals("{age:33}", serializer.getWriter().toString());
View Full Code Here

    }

    public void test_8() throws Exception {
        JSONSerializer serializer = new JSONSerializer();

        serializer.config(SerializerFeature.UseSingleQuotes, true);
        Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.UseSingleQuotes));

        serializer.write(new User(33));

        Assert.assertEquals("{'age':33}", serializer.getWriter().toString());
View Full Code Here

    }

    public void test_8_s() throws Exception {
        JSONSerializer serializer = new JSONSerializer();

        serializer.config(SerializerFeature.UseSingleQuotes, true);
        Assert.assertEquals(true, serializer.isEnabled(SerializerFeature.UseSingleQuotes));

        serializer.write(new User(33));

        Assert.assertEquals("{'age':33}", serializer.getWriter().toString());
View Full Code Here

    }

    public void test_9() throws Exception {
        JSONSerializer serializer = new JSONSerializer();

        serializer.config(SerializerFeature.QuoteFieldNames, false);
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
        serializer.config(SerializerFeature.WriteMapNullValue, false);
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.WriteMapNullValue));

        StringWriter out = new StringWriter();
View Full Code Here

    public void test_9() throws Exception {
        JSONSerializer serializer = new JSONSerializer();

        serializer.config(SerializerFeature.QuoteFieldNames, false);
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
        serializer.config(SerializerFeature.WriteMapNullValue, false);
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.WriteMapNullValue));

        StringWriter out = new StringWriter();

        Map map = new LinkedHashMap();
View Full Code Here

    }

    public void test_9_s() throws Exception {
        JSONSerializer serializer = new JSONSerializer();

        serializer.config(SerializerFeature.QuoteFieldNames, false);
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.QuoteFieldNames));
        serializer.config(SerializerFeature.WriteMapNullValue, false);
        Assert.assertEquals(false, serializer.isEnabled(SerializerFeature.WriteMapNullValue));

        SerializeWriter out = new SerializeWriter();
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.