本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
示例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();
}
示例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());
}
示例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());
}
示例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();
}
示例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());
}
示例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;
}
示例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());
}
示例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));
}
示例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());
}
示例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());
}