public void test_OrderedJsonRead() {
try {
InputStream is = this.getClass().getClassLoader().getResourceAsStream("utf8_ordered.json");
ArrayList orderList = new ArrayList();
OrderedJSONObject obj = new OrderedJSONObject(is);
is.close();
String jsonStr = obj.write(true);
Iterator order = obj.getOrder();
while (order.hasNext()) {
String next = (String) order.next();
orderList.add(next);
}
assertTrue(orderList.get(0).equals("First_Entry"));
assertTrue(orderList.get(1).equals("Second_Entry"));
assertTrue(orderList.get(2).equals("Third_Entry"));
//Validate the nested JSONObject was also contructed in an ordered manner.
OrderedJSONObject jObject = (OrderedJSONObject)obj.get("Second_Entry");
order = jObject.getOrder();
orderList.clear();
StringBuffer buf = new StringBuffer("");
while (order.hasNext()) {
String next = (String) order.next();
orderList.add(next);