use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_18 method test_writer_1.
public void test_writer_1() throws Exception {
SerializeWriter out = new SerializeWriter(14);
out.config(SerializerFeature.QuoteFieldNames, true);
try {
JSONSerializer serializer = new JSONSerializer(out);
VO vo = new VO();
vo.setValue("#");
serializer.write(vo);
Assert.assertEquals("{\"value\":\"#\"}", out.toString());
} finally {
out.close();
}
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_19 method test_writer_1.
public void test_writer_1() throws Exception {
SerializeWriter out = new SerializeWriter(14);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.UseSingleQuotes, true);
try {
JSONSerializer serializer = new JSONSerializer(out);
VO vo = new VO();
vo.getValues().add("#");
serializer.write(vo);
Assert.assertEquals("{'values':['#']}", out.toString());
} finally {
out.close();
}
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_3 method test_0.
public void test_0() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.writeFieldValue(',', "name", "jobs");
Assert.assertEquals(",\"name\":\"jobs\"", out.toString());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_4 method test_5.
public void test_5() throws Exception {
SerializeWriter out = new SerializeWriter(1000);
out.config(SerializerFeature.QuoteFieldNames, true);
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();
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_4 method test_4.
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();
}
Aggregations