use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class ObjectArraySerializerTest method test_0.
public void test_0() throws Exception {
SerializeWriter out = new SerializeWriter(1);
JSONSerializer.write(out, new Object[] { "a12", "b34" });
Assert.assertEquals("[\"a12\",\"b34\"]", out.toString());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class PrimitiveTest method test_0_s.
public void test_0_s() throws Exception {
SerializeWriter out = new SerializeWriter();
JSONSerializer.write(out, (byte) 1);
Assert.assertEquals("1", out.toString());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class PrimitiveTest method test_5_s.
public void test_5_s() throws Exception {
SerializeWriter out = new SerializeWriter();
JSONSerializer.write(out, new boolean[] {});
Assert.assertEquals("[]", out.toString());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_16 method test_writer_1.
public void test_writer_1() throws Exception {
StringWriter strOut = new StringWriter();
SerializeWriter out = new SerializeWriter(strOut, 14);
out.config(SerializerFeature.BrowserCompatible, true);
try {
JSONSerializer serializer = new JSONSerializer(out);
VO vo = new VO();
vo.setValue("abcd\t");
serializer.write(vo);
} finally {
out.close();
}
Assert.assertEquals("{value:\"abcd\\t\"}", strOut.toString());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest_17 method test_direct.
public void test_direct() throws Exception {
SerializeWriter out = new SerializeWriter(6);
out.config(SerializerFeature.QuoteFieldNames, true);
try {
JSONSerializer serializer = new JSONSerializer(out);
VO vo = new VO();
vo.setValue(123456789);
serializer.write(vo);
Assert.assertEquals("{\"value\":123456789}", out.toString());
} finally {
out.close();
}
}
Aggregations