我想从jason webservice
获取数据获取数据,可能无法从JSON Web服务
JSON的反应是:
{"content":[{"id":"1","asset_id":"62","title":"sample page","alias":"","introtext":"","fulltext":"Some Contents"},{"id":"2","asset_id":"62","title":"sample page2","alias":"","introtext":"","fulltext":"Some Contents"},{"id":"3","asset_id":"62","title":"sample page3","alias":"","introtext":"","fulltext":"Some Contents"}]}
参观Here 我已经在这样做了之后:
private void parseData() {
// Creating JSON Parser instance
JSONParser jParser = new JSONParser();
// getting JSON string from URL
JSONObject json = jParser.getJSONFromUrl(BASE_URL);
try {
// Getting Array of Contents
contents = json.getJSONArray(TAG_CONTENTS);
// looping through All Contents
for(int i = 0; i < contents.length(); i++){
JSONObject c = contents.getJSONObject(i);
// Storing each json item in variable
id = c.getString(TAG_ID);
title = c.getString(TAG_TITLE);
}
textView.setText(id + " " + title);
} catch (JSONException e) {
e.printStackTrace();
}
}
现在我得到了id = 3
和title = sample page3
结果现在我怎么能得到前两个值作为也!!?
这是怎么回事?什么是错误? – 2013-03-03 08:50:38
没有任何错误,但结果也没有显示! – 2013-03-03 08:52:56
你确定你没有结束例外吗?如果是这样,请提供你的堆栈跟踪,并且不要让你的catch部分空着,你应该处理这个异常。 – Triode 2013-03-03 08:58:36