Android - Calling getJSONArray throwing JSONException with no stack trace

Posted by Agathron on Stack Overflow See other posts from Stack Overflow or by Agathron
Published on 2010-04-07T00:28:51Z Indexed on 2010/04/07 0:33 UTC
Read the original article Hit count: 240

Filed under:
|
|

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!

© Stack Overflow or respective owner

Related posts about android

Related posts about JSON