Android - Calling getJSONArray throwing JSONException with no stack trace
- by Agathron
Hi all,
I'm currently working on an android app that pulls a list of forums from a JSON feed. I'm trying to parse the feed and immediately upon calling getJSONArray a JSON exception is being thrown with no stack trace. The JSON being returned is stored in an JSONObject jobj with the format as follows:
{
"Forum":
[
{"ForumName":"CEC Employee Communications Forum","ForumId":"105"},
{"ForumName":"CEC External Stakeholder Relations Forum","ForumId":"109"},
{"ForumName":"See All...","ForumId":"0"}
]
}
However when running the following code, I get an immediate exception without a stack trace:
JSONArray jarray = new JSONArray();
jarray = jobj.getJSONArray("Forum");
Running
jobj.GetJSONArray("Forum").toString();
returns what looks to be a correct array of the format:
[
{"ForumName":"CEC Employee Communications Forum","ForumId":"105"},
{"ForumName":"CEC External Stakeholder Relations Forum","ForumId":"109"},
{"ForumName":"See All...","ForumId":"0"}
]
I also tried
JSONArray jarray = new JSONArray(jobj.GetJSONArray("Forum").toString());
and had the exception thrown immediately. Any help would be greatly appreciated.
Thanks!