Have the following code:
String s= v.request("engine/?key=", "P4z72NmBa91&method=load");
JSONParser parser = new JSONParser();
Object obj = parser.parse(s);
JSONArray arr = (JSONArray)obj;
System.out.println(arr);
Which outputs:
[
{"time":"2012-09-10 19:09:08",
"username":"SomeUsername",
"times_logged":"1",
"ip":"33.33.33.33"
}
]
Sorry if the above is not formatted correctly.
Anyway, there are multiple sets of these in arr, and when I do arr.get(0) it returns the first one, as expected. What isn't working right is I can't do arr.get(0).get(1) or arr.get(0).get("time") or anything like that. I've tried to set it up like this:
for(int i = 0; i < arr.size(); i++) {
JSONArray p = (JSONArray)arr.get(i);
System.out.println(p.get(0));
}
, and I get the error mentioned in the title of my question. Although I believe that arr isn't a JSONArray, but a JSONObject? If that is the case, how can I iterate through off things contained in arr and get each item?