out.println("</head>");
out.println("<body>");
out.println("<h1>Reading JSON from a Reader</h1>");
out.println("Reading an empty object<br>");
JsonReader jsonReader = Json.createReader(new StringReader("{}"));
JsonObject json = jsonReader.readObject();
out.println(json);
out.println("<br><br>Reading an object with two elements<br>");
jsonReader = Json.createReader(new StringReader("{"
+ " \"apple\":\"red\","
+ " \"banana\":\"yellow\""
+ "}"));
json = jsonReader.readObject();
out.println(json);
out.println("<br><br>Reading an array with two objects<br>");
jsonReader = Json.createReader(new StringReader("["
+ " { \"apple\":\"red\" },"
+ " { \"banana\":\"yellow\" }"
+ "]"));
JsonArray jsonArr = jsonReader.readArray();
out.println(jsonArr);
out.println("<br><br>Reading a nested structure<br>");
jsonReader = Json.createReader(new StringReader("{"
+ " \"title\":\"The Matrix\","
+ " \"year\":1999,"
+ " \"cast\":["
+ " \"Keanu Reaves\","
+ " \"Laurence Fishburne\","
+ " \"Carrie-Anne Moss\""
+ " ]"
+ "}"));
json = jsonReader.readObject();
out.println(json);
out.println("</body>");
out.println("</html>");
}