1
我想解析一個JSONArray
,其中包含JSONObject
s,它們沒有名稱,並且其陣列中的(index
int)位置每週都在更改。我試圖通過它的屬性來解析特定的Object
,但是我的解析器只返回數組中的最後一個對象。如何在解析無名JSONObject的JSONArray時停止for循環?
當我想要解析並確定對象的int索引以便進一步解析時,如何停止循環。
try {
JSONArray jArray = JSONthing.getJSONfromURL("http://something.com");
String attributeiwant = "abc";
for (int i = 0; i < jArray.length(); i++) {
JSONObject alpha = jArray.getJSONObject(i);
String attributeparsed = alpha.getString("widget");
if (attributeparsed == attributeiwant) {
//determine int index of object, so i can parse other attributes
//from same object
}
}
} catch (Exception e) {
Log.e("log_tag", "Error parsing data "+ e.toString());
}
你真棒伊姆蘭。謝謝!!! – 2012-07-31 05:11:35
@ B.Money:最受歡迎的朋友!!! :) – 2012-07-31 05:14:16