1213141516171819202122
public void test_0() throws Exception { StringWriter out = new StringWriter(); JSONWriter writer = new JSONWriter(out); writer.writeStartObject(); writer.writeEndObject(); writer.flush(); Assert.assertEquals("{}", out.toString()); }
2526272829303132333435
JSONWriter writer = new JSONWriter(out); writer.writeStartObject(); writer.writeKey("id"); writer.writeValue(33); writer.writeEndObject(); writer.flush(); Assert.assertEquals("{\"id\":33}", out.toString()); }
4344454647484950515253
writer.writeValue(33); writer.writeKey("name"); writer.writeValue("jobs"); writer.writeEndObject(); writer.flush(); Assert.assertEquals("{\"id\":33,\"name\":\"jobs\"}", out.toString()); }
6566676869707172737475
writer.writeKey("children"); writer.writeStartArray(); writer.writeStartObject(); writer.writeEndObject(); writer.writeStartObject(); writer.writeEndObject(); writer.writeEndArray();
6869707172737475767778
writer.writeStartObject(); writer.writeEndObject(); writer.writeStartObject(); writer.writeEndObject(); writer.writeEndArray(); writer.writeEndObject(); writer.flush();
7273747576777879808182
writer.writeStartObject(); writer.writeEndObject(); writer.writeEndArray(); writer.writeEndObject(); writer.flush(); Assert.assertEquals("{\"id\":33,\"name\":\"jobs\",\"children\":[{},{}]}", out.toString()); }
8687888990919293949596
JSONWriter writer = new JSONWriter(out); writer.writeStartArray(); writer.writeStartObject(); writer.writeEndObject(); writer.writeStartObject(); writer.writeEndObject(); writer.writeStartArray();
8990919293949596979899
writer.writeStartObject(); writer.writeEndObject(); writer.writeStartObject(); writer.writeEndObject(); writer.writeStartArray(); writer.writeEndArray(); { writer.writeStartArray();
1314151617181920212223
2627282930313233343536