Can any one suggest and send me sample code for fetching JSON response. Few APIs I am getting data in the form of the NSDictionary
and few APIs I am getting data in the form of NSArray
.
This is my API request with Alamofire.
APIManager.sharedInstance.getTeacherProfileDataFromURL(){(userJson)-> Void in
let swiftyJsonVar = JSON(userJson)
print("userJson userJson userJson userJson",userJson)
print("swiftyJsonVar",swiftyJsonVar)
}
1) API WITH JSON ARRAY OF DATA
{
"status": 1,
“student”: [
{
"name": "Sprouse",
"subject": [
“english”
],
"personal_email": "",
"school_email": "cole.sprouse483@demo.in",
"phone": "9665478544",
"class_teacher": false,
"image": "/assets/default_male.png"
},
{
"name": “elen”,
"subject": [
"Social Science"
],
"personal_email": "",
"school_email": "elena.gilbert564@demo.in",
"phone": "9066260799",
"class_teacher": false,
"image": "/assets/default_female.png"
},
],
"message": "Details fetched successfully."
}
2) ANOTHER API WITH JSON DICTIONARY OF DATA
{
"status": 1,
"dashboard": {
"announcement": [
{
"title": "Independence Day Celebration",
"posted_on": "13 August, 2017"
}
],
"student": {
"attendance_percent": 100,
"assignment": [
{
"title": "Alphabets in HINDI",
"end_date": "13/09/2017",
"subject": "Hindi",
"teacher_name": "Bonnie Bennette"
}
],
"leave_apply": 13
},
"image": "/system/images/86/j1f9DiJi_thumb.jpg?1504593436"
},
"message": "Details fetched successfully."
}