use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_7 method test_3.
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());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_7 method test_0.
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());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_7 method test_1.
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());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_8 method test_singleQuote.
public void test_singleQuote() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 1024; ++i) {
buf.append('a');
}
buf.append("中国");
buf.append("\0");
SerializeWriter out = new SerializeWriter(new StringWriter());
try {
JSONSerializer serializer = new JSONSerializer(out);
serializer.config(SerializerFeature.QuoteFieldNames, false);
serializer.config(SerializerFeature.UseSingleQuotes, true);
serializer.write(Collections.singletonMap(buf.toString(), ""));
} finally {
out.close();
}
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_9 method test_error.
public void test_error() throws Exception {
SerializeWriter writer = new SerializeWriter(new StringWriter());
Exception error = null;
try {
writer.writeTo(new StringWriter());
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
writer.close();
}
Aggregations