My server is written in Rails 4.x and to the to_json method I'm using to return records back through the API is delivering an array of JSON to Android that looks like this:
[{"id":503240,"name":"bob"},{"id":503241,"name":"Tom"}]
It comes down to Android fine and I have no problems using it as a string and logging it.
Now I want to loop through each item of the array grab the id (ultimately to show it on a ListView).
The first thing I need to do is "see" each individual object. So I am parsing the above using the following line of code:
JSONArray jsonResponse = new JSONArray(jsonString);
It "parses" with no errors, but ... when I try to do something like jsonResponse[1], or jsonResponse.getObject(1) to get my hands on the one of the elements of the array (just to log it for example), I can't get past the IDE telling me I'm doing it wrong.
If I can address and manipulate the individual json objects, I'm sure I'll have no problems addressing the individual data elements. It's the arrayness of this that is causing problems.
I'm a little new to Java and I'm spoiled by Ruby and Swift. I'm missing something basic. What am I doing wrong?
Thanks in advance.