use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_15 method test_writer_1.
@SuppressWarnings("rawtypes")
public void test_writer_1() 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("", "a");
serializer.write(map);
} finally {
out.close();
}
Assert.assertEquals("{'':'a'}", strOut.toString());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_4 method test_0.
public void test_0() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.WriteTabAsSpecial, true);
out.writeFieldValue(',', "name", "\t");
Assert.assertEquals(",\"name\":\"\\t\"", out.toString());
out.close();
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_5 method test_3.
public void test_3() 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());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_5 method test_0.
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());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_7 method test_2.
public void test_2() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, false);
out.writeFieldName("名称");
Assert.assertEquals("名称:", out.toString());
}
Aggregations