从这个JSON响应中,我需要获取名称,电子邮件,移动设备并将其显示为列表视图。我无法找到如何特别获得JSON数组响应。请帮我解决这个问题。提前谢谢。
{
"status":200,
"success":"TRUE",
"data":
{
"todayCallBacks":
[
{"callback_date":"18-01-2018 10:30","remarks":"","name":"asdasd","email":"","mobile":"213213","company":"asdasd","feedback":"teasdasd","id":"60","amount":"2313.00","product":"Brouchure","location":"","landline":"213413"},{"callback_date":"18-01-2018 14:50","remarks":"","name":"asdasd","email":"","mobile":"123123213","company":"adsadasd","feedback":"asdasdsd","id":"53","amount":"2141.00","product":"Brouchure","location":"","landline":"213123"},{"callback_date":"18-01-2018 15:50","remarks":"","name":"asdasdasd","email":"","mobile":"23123","company":"asdasd","feedback":"asdasdasdasd","id":"63","amount":"0.00","product":"Brouchure","location":"","landline":"123123"},
{"callback_date":"19-01-2018 15:50","remarks":"","name":"asdasd","email":"","mobile":"1241241241","company":"asdasd","feedback":"adasdasd","id":"58","amount":"123213.00","product":"Web page designing","location":"","landline":"12412412412"},{"callback_date":"19-01-2018 19:45","remarks":"","name":"sadsa","email":"","mobile":"313213","company":"dasd","feedback":"asdasd","id":"55","amount":"2412.00","product":"Brouchure","location":"","landline":"21312321"}
]
}
}
答案 0 :(得分:0)
试试这个
try {
JSONObject resObject = new JSONObject("your json response");
JSONObject jsonObject = resObject.getJSONObject("data");
JSONArray jsonArray = jsonObject.getJSONArray("todayCallBacks");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject1 = jsonArray.getJSONObject(i);
String callback_date = jsonObject1.getString("callback_date");
String remarks = jsonObject1.getString("remarks");
String name = jsonObject1.getString("name");
String email = jsonObject1.getString("email");
String mobile = jsonObject1.getString("mobile");
String company = jsonObject1.getString("company");
String feedback = jsonObject1.getString("feedback");
String id = jsonObject1.getString("id");
String amount = jsonObject1.getString("amount");
String product = jsonObject1.getString("product");
String location = jsonObject1.getString("location");
String landline = jsonObject1.getString("landline");
Log.i("Data", ":" + callback_date);
Log.i("Data", ":" + remarks);
Log.i("Data", ":" + name);
Log.i("Data", ":" + email);
Log.i("Data", ":" + mobile);
Log.i("Data", ":" + company);
Log.i("Data", ":" + feedback);
Log.i("Data", ":" + id);
Log.i("Data", ":" + amount);
Log.i("Data", ":" + product);
Log.i("Data", ":" + location);
Log.i("Data", ":" + landline);
}
} catch (JSONException E) {
E.printStackTrace();
}
<强>输出强>
答案 1 :(得分:0)
JSONObject json = new JSONObject(response);
JSONObject json2 = json.getJsonObject("data");
JSONArray contacts = json2.getJSONArray("todayCallBacks");
for (int i = 0; i < contacts.length(); i++) {
JSONObject c = contacts.getJSONObject(i);
}