@Test
public void testNestedStructure() throws JSONException {
JsonObject jsonObject = Json.createObjectBuilder()
.add("title", "The Matrix")
.add("year", 1999)
.add("cast", Json.createArrayBuilder()
.add("Keanu Reaves")
.add("Laurence Fishburne")
.add("Carrie-Anne Moss"))
.build();
StringWriter w = new StringWriter();
try (JsonWriter writer = Json.createWriter(w)) {
writer.write(jsonObject);
}
JSONAssert.assertEquals("{\"title\":\"The Matrix\",\"year\":1999,\"cast\":[\"Keanu Reaves\",\"Laurence Fishburne\",\"Carrie-Anne Moss\"]}", w.toString(), JSONCompareMode.STRICT);
}