{"5303b93":["F2424F",40.53,22.97,0,0,0,"0000","T-LGTS2","A139","-",1421675730,"","","",1,0,"UPDATE-YOUR-FR24-APP",0],
"5323c35":["F2424F",50.10,14.26,51,0,0,"2104","T-LKPR27","A139","",1421675730,"","","",1,0,"UPDATE-YOUR-FR24-APP",0]}
答案 0 :(得分:0)
也许是这样的:
JSONObject jsonObj = new JSONObject(str);
JSONArray arrayJson = jsonObj.getJSONArray("5303b93");
for (int i = 0; i < arrayJson.length(); i++) {
String values= arrayJson.getString(i);
}
因为不是&#34; 5303b93
&#34;第一个数组的关键?
如果要迭代忽略键的所有数组
JSONObject jsonObj = new JSONObject(str);
Iterator it = jsonObj.keys();
while (it.hasNext()) {
JSONArray arrayJson = jsonObj.getJSONArray((String)it.next());
for (int i = 0; i < arrayJson.length(); i++) {
String values= arrayJson.getString(i);
}
}
答案 1 :(得分:0)
试试这个
<强>的strings.xml 强>
<string name="json_data">{"5303b93":["F2424F",40.53,22.97,0,0,0,"0000","T-LGTS2","A139","-",1421675730,"","","",1,0,"UPDATE-YOUR-FR24-APP",0], "5323c35":["F2424F",50.10,14.26,51,0,0,"2104","T-LKPR27","A139","",1421675730,"","","",1,0,"UPDATE-YOUR-FR24-APP",0]}</string>
JAVA代码:
JSONObject jsonObj = null;
try {
jsonObj = new JSONObject(getString(R.string.json_data));
JSONArray jsonArray1 = jsonObj.getJSONArray("5303b93");
JSONArray jsonArray2 = jsonObj.getJSONArray("5323c35");
for(int i= 0 ; i<jsonArray1.length(); i++){
if(jsonArray1.getString(i) != null){
String tempStr = jsonArray1.getString(i);
if(tempStr != null)
Log.i("===First Array==="+i, "==="+tempStr+"===");
}
}
for(int i= 0 ; i<jsonArray2.length(); i++){
if(jsonArray2.getString(i) != null){
String tempStr = jsonArray2.getString(i);
if(tempStr != null)
Log.i("===Second Array==="+i, "==="+tempStr+"===");
}
}
} catch (JSONException e) {
e.printStackTrace();
}