use of com.alibaba.fastjson.JSONWriter in project fastjson by alibaba.
the class JSONWriterTest method test_2.
public void test_2() throws Exception {
StringWriter out = new StringWriter();
JSONWriter writer = new JSONWriter(out);
writer.writeStartObject();
writer.writeKey("id");
writer.writeValue(33);
writer.writeKey("name");
writer.writeValue("jobs");
writer.writeEndObject();
writer.flush();
Assert.assertEquals("{\"id\":33,\"name\":\"jobs\"}", out.toString());
}
use of com.alibaba.fastjson.JSONWriter in project fastjson by alibaba.
the class JSONWriterTest method test_1.
public void test_1() throws Exception {
StringWriter out = new StringWriter();
JSONWriter writer = new JSONWriter(out);
writer.writeStartObject();
writer.writeKey("id");
writer.writeValue(33);
writer.writeEndObject();
writer.flush();
Assert.assertEquals("{\"id\":33}", out.toString());
}
use of com.alibaba.fastjson.JSONWriter in project fastjson by alibaba.
the class JSONWriterTest_0 method test_writer.
public void test_writer() throws Exception {
StringWriter out = new StringWriter();
JSONWriter writer = new JSONWriter(out);
writer.startArray();
writer.writeObject("1");
writer.writeObject("2");
writer.writeObject("3");
writer.endArray();
writer.close();
Assert.assertEquals("[\"1\",\"2\",\"3\"]", out.toString());
}
Aggregations