views:

238

answers:

1

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!

A: 

So, something like this doesn't help? I doubt you can get an Exception without a stacktrace:

JSONarray jarray = null;
try {
   jarray = jobj.getJSONArray("Forum");
}
catch(JSONException je) { je.printStackTrace(); }
synic
I tried that and put a break point on the line but it skipped right over it and printed nothing in the log.
Agathron