我想从JSONArray
JSONObject
JSONObject jsonObject=new JSONObject(response_view);
for(int x=0; x<jsonObject.length(); x++) {
JSONArray jsonArray = jsonObject.getJSONArray("Here I have to pass");
}
这是我的JSON
,
{
"Mr. VICKRAM SINGH_269": [{
"status": "P",
"date": "2017-02-05"
}, {
"status": "P",
"date": "2017-02-06"
}],
"Mr. VIVEK KUMAR YADAV_276": [{
"status": "P",
"date": "2017-02-05"
}, {
"status": "P",
"date": "2017-02-06"
}]
}
答案 0 :(得分:1)
你可以解析Json,如下所示:
try{
JSONObject json = new JSONObject(jsonRespondeString);
Iterator<String> iterator = json.keys();
while (iterator.hasNext()){
String key = iterator.next();
JSONArray jsonArray = json.getJSONArray(key);
for(int i=0;i<jsonArray.length();i++){
JSONObject object = jsonArray.getJSONObject(i);
String value1 = object.getString("key1");
String value2 = object.getString("key2");
}
}
}
catch (JSONException e){
e.printStackTrace();
}
您可以从键中获取姓名和ID:
String str="Mr. VICKRAM SINGH_269";
String array[]= str.split("_");
String name =array[0];
String id =array[1];
答案 1 :(得分:0)
JSONArray jsonArray=jsonObject.getJSONArray("Write the name of your array here");
然后循环你的jsonArray对象