I'm using JSON in my android application in the following manner:
Code:
Integer numberOfItemsInResp = pagination.getInt("items");
JSONArray results = jsonResponse.getJSONArray("results");
for (int i = 0; i < numberOfItemsInResp; i++){
JSONObject perResult = results.getJSONObject(i);
}
Problem is when the i reaches 50, then JSONObject perResult = results.getJSONObject(i) throws "org.json.JSONException: Index 50 out of range [0..50)" Exception.
Is there any limitation attached to JSONArray?
What is numberOfItemsInResp? Suggest you do this:
JSONArray results = jsonResponse.getJSONArray("results");
final int numberOfItemsInResp = results.length();
for (int i = 0; i < numberOfItemsInResp; i++){
JSONObject perResult = results.getJSONObject(i);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With