The following code is printing hash values instead of Array
JSONObject myjson1 = new JSONObject(expectedResult);
Iterator x = myjson1.keys();
JSONArray jsonArray = new JSONArray();
while (x.hasNext()){
String key = (String) x.next();
jsonArray.put(myjson1.get(key));
System.out.println(x);
}
The output is as follows:
java.util.HashMap$KeyIterator@42a0b130
java.util.HashMap$KeyIterator@3c2a5fb9
java.util.HashMap$KeyIterator@6e68bc46
java.util.HashMap$KeyIterator@3223cb64
java.util.HashMap$KeyIterator@256c426b
PS: Converting Json to Array (key : value) form