-3
{
  "data": [
    {
      "0": {
        "degree": "HSC",
        "start_date": "01-01-2007",
        "end_date": "01-01-2008"
      },
      "1": {
        "degree": "BE",
        "start_date": "01-01-2008",
        "end_date": "31-05-2012"
      },
      "2": {
        "degree": "MCM",
        "start_date": "29-07-2015",
        "end_date": "31-07-2015"
      },
      "3": {
        "exp_designation": "aaa",
        "exp_description": "aa",
        "exp_startdate": "23-07-2015",
        "exp_enddate": "01-07-2015",
        "latest": "0"
      },
      "4": {
        "exp_designation": "aaa",
        "exp_description": "asasasas",
        "exp_startdate": "01-07-2015",
        "exp_enddate": "31-07-2015",
        "latest": "0"
      },
      "user_id": "1",
      "user fullname": "",
      "user_phone": "2147483647",
      "user_email": "",
      "user_address": "Uruli kanchan",
      "user_status": "",
      "user_speciality": "eye",
      "username": "",
      "password": "niki"
    }
  ]
}

How to parse this json in android ? i want to display

"0": {
        "degree": "HSC",
        "start_date": "01-01-2007",
        "end_date": "01-01-2008"
      },
      "1": {
        "degree": "BE",
        "start_date": "01-01-2008",
        "end_date": "31-05-2012"
      },
      "2": {
        "degree": "MCM",
        "start_date": "29-07-2015",
        "end_date": "31-07-2015"
      },
      "3": {
        "exp_designation": "aaa",
        "exp_description": "aa",
        "exp_startdate": "23-07-2015",
        "exp_enddate": "01-07-2015",
        "latest": "0"
      },
      "4": {
        "exp_designation": "aaa",
        "exp_description": "asasasas",
        "exp_startdate": "01-07-2015",
        "exp_enddate": "31-07-2015",
        "latest": "0"
      },

these in custom list view ?

is it a correct json ?

how to parse ?

currently im getting some json data as follows,

// Getting JSON Array
                user = json.getJSONArray("data");
                JSONObject feedObj = user.getJSONObject(0);
                item.setUserid(feedObj.getInt("user_id"));
                item.setUserFullname(feedObj.getString("user fullname"));

                item.setUserPhone(feedObj.getString("user_phone"));
                MobileNo.setText(item.getUserPhone());

                item.setUserEmail(feedObj.getString("user_email"));
                Email.setText(item.getUserEmail());

                item.setUserAddress(feedObj.getString("user_address"));
                Address.setText(item.getUserAddress());

                item.setUserStatus(feedObj.getString("user_status"));

                item.setUserSpeciality(feedObj.getString("user_speciality"));
                SelSpeciality.setText(item.getUserSpeciality());

                item.setUsername(feedObj.getString("username"));
                item.setPassword(feedObj.getString("password"));
                item.setImgSmall(feedObj.getString("img_small"));
                item.setImgLarge(feedObj.getString("img"));
                item.setUserConnection(feedObj.getString("connection"));
Marc B
  • 356,200
  • 43
  • 426
  • 500
DAK
  • 1
  • 1

1 Answers1

0

I think that you should consider using some library like Gson. If using Gson, you can create an a model with the same naming as your Json.

Here is a reference: How can I convert JSON to a HashMap using Gson?

Community
  • 1
  • 1
ranchuk
  • 83
  • 2
  • 4