我想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"
}]
}
你可以像下面这样解析 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];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句