I have a JSON string that I use for my iOS app and it works fine, however it doesn’t have a key on the array. I don’t know how to call JSONArray in this case, can anybody make a suggestion besides changing my JSON to be different for the Android App (I’d like to use the same script for all my apps). Here is my JSON String:
[{"url":"uploads\/audio\/A Cold One.mp3", "title":"A Cold One"}, ...]
And my code looks like this:
JSONObject root = new JSONObject(result);
JSONArray jItems = root.getJSONArray("");
My exception:
Download stopped: org.json.JSONException: Value [{"url":"uploads\/audio\/A Cold One.mp3", "title:"A Cold One"}, ...]
Thanks!
use this
yourJSONString should start with ‘[‘. in your case the
yourJSONStringisresult. you don’t have to convert it in to JSONObject in between.HTH.