当前位置: 首页>>代码示例>>Java>>正文


Java SerializeWriter.config方法代码示例

本文整理汇总了Java中com.alibaba.fastjson.serializer.SerializeWriter.config方法的典型用法代码示例。如果您正苦于以下问题:Java SerializeWriter.config方法的具体用法?Java SerializeWriter.config怎么用?Java SerializeWriter.config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.fastjson.serializer.SerializeWriter的用法示例。


在下文中一共展示了SerializeWriter.config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();
    
    SerializeWriter writer = new SerializeWriter(out, 10);
    writer.config(SerializerFeature.QuoteFieldNames, true);
    Assert.assertEquals(10, writer.getBufferLength());
    
    writer.writeFieldValue(',', "abcde01245abcde", "123");
    writer.close();
    
    String text = out.toString();
    Assert.assertEquals(",\"abcde01245abcde\":\"123\"", text);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:StreamWriterTest_writeFieldValue_string.java

示例2: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();
    
    SerializeWriter writer = new SerializeWriter(out, 10);
    writer.config(SerializerFeature.BrowserCompatible, true);
    Assert.assertEquals(10, writer.getBufferLength());
    
    writer.writeString("abcde12345678\t");
    writer.close();
    
    String text = out.toString();
    Assert.assertEquals("\"abcde12345678\\t\"", text);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:StreamWriterTest_writeValueString1.java

示例3: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();
    
    SerializeWriter writer = new SerializeWriter(out, 10);
    writer.config(SerializerFeature.QuoteFieldNames, true);
    writer.config(SerializerFeature.UseSingleQuotes, true);
    Assert.assertEquals(10, writer.getBufferLength());
    
    writer.writeFieldValue(',', "abcde01245abcde", "123");
    writer.close();
    
    String text = out.toString();
    Assert.assertEquals(",'abcde01245abcde':'123'", text);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:StreamWriterTest_writeFieldValue_string_singQuote.java

示例4: test_writer_2

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_writer_2() throws Exception {
    StringWriter strOut = new StringWriter();
    SerializeWriter out = new SerializeWriter(strOut, 1);
    out.config(SerializerFeature.UseSingleQuotes, true);

    try {
        JSONSerializer serializer = new JSONSerializer(out);

        Map map = Collections.singletonMap("ab", "a");
        serializer.write(map);
    } finally {
        out.close();
    }
    Assert.assertEquals("{ab:'a'}", strOut.toString());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:SerializeWriterTest_15.java

示例5: encode

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public String encode(Object object) throws Exception {
        SerializeConfig config = new SerializeConfig();
        SerializeWriter out = new SerializeWriter();
        out.config(SerializerFeature.DisableCircularReferenceDetect, true);
//        out.config(SerializerFeature.DisableCheckSpecialChar, true);

        JSONSerializer serializer = new JSONSerializer(out, config);
        serializer.write(object);

        String text = out.toString();

        out.close();

        return text;
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:FastjsonSCodec.java

示例6: test_4

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_4() throws Exception {
    SerializeWriter out = new SerializeWriter(1);
    out.config(SerializerFeature.QuoteFieldNames, true);
    out.config(SerializerFeature.WriteTabAsSpecial, false);
    out.writeFieldValue(',', "name", "\t\n \b\n\r\f\\ \"");
    Assert.assertEquals(",\"name\":\"\\t\\n \\b\\n\\r\\f\\\\ \\\"\"", out.toString());
    out.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:SerializeWriterTest_4.java

示例7: test_14

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_14() throws Exception {
	SerializeWriter out = new SerializeWriter(4);
	out.config(SerializerFeature.UseSingleQuotes, false);

	out.writeString("1\"");
	Assert.assertEquals("\"1\\\"\"", out.toString());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:StringSerializerTest.java

示例8: test_4

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_4() throws Exception {
    SerializeWriter out = new SerializeWriter(1);
    out.config(SerializerFeature.QuoteFieldNames, true);
    out.config(SerializerFeature.UseSingleQuotes, true);
    out.writeFieldValue(',', "name", (String) null);
    Assert.assertEquals(",'name':null", out.toString());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:SerializeWriterTest_5.java

示例9: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    SerializeWriter out = new SerializeWriter(1);
    out.config(SerializerFeature.WriteTabAsSpecial, true);
    out.writeString("\t\n \b\n\r\f\\ \"");
    Assert.assertEquals("\"\\t\\n \\b\\n\\r\\f\\\\ \\\"\"", out.toString());
    out.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:SerializeWriterTest_2.java

示例10: test_7

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_7() throws Exception {
	SerializeWriter out = new SerializeWriter(1);
	out.config(SerializerFeature.UseSingleQuotes, true);

	out.writeString("中国");
	Assert.assertEquals("'中国'", out.toString());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:StringSerializerTest.java

示例11: encode

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
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);

        String text = out.toString();

        out.close();

        return text;
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:FastjsonGenCodec.java

示例12: test_5

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_5() throws Exception {
	SerializeWriter out = new SerializeWriter();
	out.config(SerializerFeature.UseSingleQuotes, true);

	out.writeString((String) null);
	Assert.assertEquals("null", out.toString());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:StringSerializerTest.java

示例13: testWriterSerializerFeature

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
@Test
public void testWriterSerializerFeature() throws Exception {
    SerializeWriter writer=new SerializeWriter();
    writer.config(SerializerFeature.WriteEnumUsingToString,true);
    Assert.assertTrue(writer.isEnabled(SerializerFeature.WriteEnumUsingToString));
    writer.config(SerializerFeature.WriteEnumUsingName,true);
    Assert.assertTrue(writer.isEnabled(SerializerFeature.WriteEnumUsingName));
    Assert.assertFalse(writer.isEnabled(SerializerFeature.WriteEnumUsingToString));
    writer.config(SerializerFeature.WriteEnumUsingToString,true);
    Assert.assertTrue(writer.isEnabled(SerializerFeature.WriteEnumUsingToString));
    Assert.assertFalse(writer.isEnabled(SerializerFeature.WriteEnumUsingName));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:EnumTest3.java

示例14: test_6

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_6() throws Exception {
	SerializeWriter out = new SerializeWriter(1);
	out.config(SerializerFeature.UseSingleQuotes, true);

	out.writeString((String) null);
	Assert.assertEquals("null", out.toString());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:StringSerializerTest.java

示例15: test_7_d

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_7_d() throws Exception {
	SerializeWriter out = new SerializeWriter(1);
	out.config(SerializerFeature.UseSingleQuotes, false);

	out.writeString("中国");
	Assert.assertEquals("\"中国\"", out.toString());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:StringSerializerTest.java


注:本文中的com.alibaba.fastjson.serializer.SerializeWriter.config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。