0

Here is jsonArray:

JSONArray jsonArray = CommonFunctions.GetJSONResults(url, parameters);
CoursesEntity [] CourseDetail=new CoursesEntity[jsonArray.length()];


And here is the value of jsonArray, I am getting after executing above line:

   [
    {
        "UserCourseId": 253,
        "EnrollDate": "2014-05-28T17:54:31.733",
        "Status": 0,
        "IsThirdPartyCourse": true,
        "MappedCourseUrl": "a",
        "MappedUserId": "a",
        "Id": 15,
        "Name": "Diabetes Management",
        "ShortName": null,
        "Synopsis": null,
        "Description": null,
        "Duration": "7",
        "ImagePath": "S.jpg",
        "IsNewCourse": 0,
        "IsDisplayEnrollUnenroll": 0,
        "InstituteName": null,
        "CourseAuthor": null,
        "CourseLink": null
    },
    {
        "UserCourseId": 253,
        "EnrollDate": "2014-05-28T17:54:31.733",
        "Status": 0,
        "IsThirdPartyCourse": true,
        "MappedCourseUrl": "a",
        "MappedUserId": "a",
        "Id": 15,
        "Name": "Diabetes Management",
        "ShortName": null,
        "Synopsis": null,
        "Description": null,
        "Duration": "7",
        "ImagePath": "S.jpg",
        "IsNewCourse": 0,
        "IsDisplayEnrollUnenroll": 0,
        "InstituteName": null,
        "CourseAuthor": null,
        "CourseLink": null
    },
    {
        "UserCourseId": 253,
        "EnrollDate": "2014-05-28T17:54:31.733",
        "Status": 0,
        "IsThirdPartyCourse": true,
        "MappedCourseUrl": "a",
        "MappedUserId": "a",
        "Id": 15,
        "Name": "Diabetes Management",
        "ShortName": null,
        "Synopsis": null,
        "Description": null,
        "Duration": "7",
        "ImagePath": "S.jpg",
        "IsNewCourse": 0,
        "IsDisplayEnrollUnenroll": 0,
        "InstituteName": null,
        "CourseAuthor": null,
        "CourseLink": null
    }
]


How to fetch these values? I tried like below, but it is getting null:

CourseDetail[i].setCourseName(jsonObj.getJSONObject(i).getString("Name"));

1 Answer 1

2

For(int i=0; JsonArray.length(); i++)
{
   JSONObject jsonObj = JsonArray.getJSONObject(i);
   CourseDetail[i].setCourseName(jsonObj.getString("Name")); 

     ... ...

}

Hope this help!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.