@Test
public void testNestedStructure() throws JSONException {
JsonReader jsonReader = Json.createReader(new StringReader("{"
+ " \"title\":\"The Matrix\","
+ " \"year\":1999,"
+ " \"cast\":["
+ " \"Keanu Reaves\","
+ " \"Laurence Fishburne\","
+ " \"Carrie-Anne Moss\""
+ " ]"
+ "}"));
JsonObject json = jsonReader.readObject();
assertNotNull(json);
assertFalse(json.isEmpty());
assertTrue(json.containsKey("title"));
assertEquals("The Matrix", json.getString("title"));
assertTrue(json.containsKey("year"));
assertEquals(1999, json.getInt("year"));
assertTrue(json.containsKey("cast"));
JsonArray jsonArr = json.getJsonArray("cast");
assertNotNull(jsonArr);
assertEquals(3, jsonArr.size());
JSONAssert.assertEquals("["
+ " \"Keanu Reaves\","
+ " \"Laurence Fishburne\","
+ " \"Carrie-Anne Moss\""
+ " ]", jsonArr.toString(), JSONCompareMode.STRICT);
}