I'm trying to pull a value from a name in a JSONbject that is created from a JSONArray, the JSONAarray is created from the main(root) JSONObject.
Here's the JSON:
{"filelist": [{
"1": {
"filename": "sample.mp3",
"baseurl": "http://etc.com/"
}}]}
I'm fairly sure the JSON is correctly formatted.
Here is the Java (for Android SDK, this is in the OnCreate method in main Activity class):
String jsonString = new String("{\"filelist\": [{ \"1\": { \"filename\": \"sample.mp3\", \"baseurl\": \"http://etc.com/\" }}]}");
JSONObject jObj = new JSONObject(jsonString);
JSONArray jArr = new JSONArray(jObj.getJSONArray("filelist").toString());
JSONObject jSubObj = new JSONObject(jArr.getJSONObject(0).toString());
textView1.setText(jSubObj.getString("filename"));
Thanks for taking a look and any answers are much appreciated.