开发者

Android - Calling getJSONArray throwing JSONException without stacktrace

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"},
         {"ForumNa开发者_如何学编程me":"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.


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(); }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜