@Test
public void testNestedStructure() throws JSONException {
JsonGeneratorFactory factory = Json.createGeneratorFactory(null);
StringWriter w = new StringWriter();
JsonGenerator gen = factory.createGenerator(w);
gen
.writeStartObject()
.write("title", "The Matrix")
.write("year", 1999)
.writeStartArray("cast")
.write("Keanu Reaves")
.write("Laurence Fishburne")
.write("Carrie-Anne Moss")
.writeEnd()
.writeEnd();
gen.flush();
JSONAssert.assertEquals("{\"title\":\"The Matrix\",\"year\":1999,\"cast\":[\"Keanu Reaves\",\"Laurence Fishburne\",\"Carrie-Anne Moss\"]}", w.toString(), JSONCompareMode.STRICT);
}