我有那个 JSON 响应
{"as_of":"2013-04-22T19:50:41Z","trends":[{"events":null,
"query":"%23RhymeATweepsName","url":"http:\/\/twitter.com\/search?
q=%23RhymeATweepsName","promoted_content":null,
"name":"#RhymeATweepsName"},
{"events":null,"query":"%23EarthDayPK","url":
"http:\/\/twitter.com\/search?
=%23EarthDayPK","promoted_content":null,"name":
"#EarthDayPK"}],"locations":
[{"woeid":*******,"name":"********"}],"created_at":"2013-04-22T19:38:16Z"}
我正在用以下代码解析它
jArray = new JSONArray(result);
JSONObject post = null;
for (int ii = 0; ii < jArray.length(); ii++) {
post = jArray.getJSONObject(ii);
String name = post.getJSONObject("trends").getString("name") + "\n";
}
}
但它抛出异常“JSONArray 无法转换为 JSONObject 错误”