Package com.alibaba.fastjson.serializer

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


    // private JavaBeanSerializer serializer = new JavaBeanSerializer(Long_100_Entity.class);

    public String encode(Object object) throws Exception {
        SerializeWriter out = new SerializeWriter();
        out.config(SerializerFeature.DisableCircularReferenceDetect, true);
//        out.config(SerializerFeature.DisableCheckSpecialChar, true);

        JSONSerializer serializer = new JSONSerializer(out);
        serializer.write(object);
        serializer.getPropertyFilters().add(new PropertyFilter() {
View Full Code Here


public class SerializeWriterTest_7 extends TestCase {

  public void test_0() throws Exception {
    SerializeWriter out = new SerializeWriter(1);
    out.config(SerializerFeature.QuoteFieldNames, true);
    out.config(SerializerFeature.UseSingleQuotes, true);
    out.writeFieldValue(',', "name", (Enum) null);
    Assert.assertEquals(",'name':null", out.toString());
  }
View Full Code Here

public class SerializeWriterTest_7 extends TestCase {

  public void test_0() throws Exception {
    SerializeWriter out = new SerializeWriter(1);
    out.config(SerializerFeature.QuoteFieldNames, true);
    out.config(SerializerFeature.UseSingleQuotes, true);
    out.writeFieldValue(',', "name", (Enum) null);
    Assert.assertEquals(",'name':null", out.toString());
  }

  public void test_1() throws Exception {
View Full Code Here

    Assert.assertEquals(",'name':null", out.toString());
  }

  public void test_1() throws Exception {
    SerializeWriter out = new SerializeWriter(1);
    out.config(SerializerFeature.QuoteFieldNames, true);
    out.config(SerializerFeature.UseSingleQuotes, true);
    out.writeFieldName("名称");
    Assert.assertEquals("'名称':", out.toString());
  }
View Full Code Here

  }

  public void test_1() throws Exception {
    SerializeWriter out = new SerializeWriter(1);
    out.config(SerializerFeature.QuoteFieldNames, true);
    out.config(SerializerFeature.UseSingleQuotes, true);
    out.writeFieldName("名称");
    Assert.assertEquals("'名称':", out.toString());
  }

  public void test_2() throws Exception {
View Full Code Here

    Assert.assertEquals("'名称':", out.toString());
  }

  public void test_2() throws Exception {
    SerializeWriter out = new SerializeWriter(1);
    out.config(SerializerFeature.QuoteFieldNames, false);
    out.writeFieldName("名称");
    Assert.assertEquals("名称:", out.toString());
  }

  public void test_3() throws Exception {
View Full Code Here

    Assert.assertEquals("名称:", out.toString());
  }

  public void test_3() throws Exception {
    SerializeWriter out = new SerializeWriter(1);
    out.config(SerializerFeature.QuoteFieldNames, false);
    out.writeFieldName("a\n\n\n\n");
    Assert.assertEquals("\"a\\n\\n\\n\\n\":", out.toString());
  }
 
  public void test_4() throws Exception {
View Full Code Here

    Assert.assertEquals("\"a\\n\\n\\n\\n\":", out.toString());
  }
 
  public void test_4() throws Exception {
    SerializeWriter out = new SerializeWriter(1);
    out.config(SerializerFeature.QuoteFieldNames, false);
    out.config(SerializerFeature.UseSingleQuotes, true);
    out.writeFieldName("a\n\n\n\n");
    Assert.assertEquals("'a\\n\\n\\n\\n':", out.toString());
  }
}
View Full Code Here

  }
 
  public void test_4() throws Exception {
    SerializeWriter out = new SerializeWriter(1);
    out.config(SerializerFeature.QuoteFieldNames, false);
    out.config(SerializerFeature.UseSingleQuotes, true);
    out.writeFieldName("a\n\n\n\n");
    Assert.assertEquals("'a\\n\\n\\n\\n':", out.toString());
  }
}
View Full Code Here

public class SerializeWriterTest_5 extends TestCase {

    public void test_0() throws Exception {
        SerializeWriter out = new SerializeWriter(1);
        out.config(SerializerFeature.QuoteFieldNames, true);
        out.writeFieldValue(',', "name", (Enum) null);
        Assert.assertEquals(",\"name\":null", out.toString());
    }
   
    public void test_1() throws Exception {
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.