-5

From this JSON response, I need to get the name, email, mobile and show it like a list-view. I can't be able to find how to get the JSON array response in particular.Please help me to sort this problem. Thank you in advance.

{
  "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"}
        ]
      }
}
Gunaseelan
  • 23
  • 1
  • 9

2 Answers2

0

Try this

 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();
}

OUTPUT

enter image description here

Ratilal Chopda
  • 4,162
  • 4
  • 18
  • 31
0

Try this...

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);
}
Community
  • 1
  • 1
Rajasimman R
  • 496
  • 4
  • 14