[
{
"Profile": {
"id": "13",
"user_id": "13",
"first_name": "samm",
"profile_image": "13-IMG_169.png",
"where_from": "abro",
"where_live": "simba",
"age": "24",
"profile_type": null,
"company_name": "nick",
"job_title": "developer",
"industry": "software",
"education": "bscs",
"what_you_do": "developement",
"detail_summery": "summary",
"location": null,
"state_id": "1",
"city_id": "84",
"favorite_music_bands": "",
"favorite_teams": "",
"favorite_books": "",
"favorite_movies": null,
"small_intro": "developer"
}
}
],
{
"LookingData": [
{
"user_looking_id": "675",
"looking_id": "1",
"looking_text": "Expand Professional network"
},
{
"user_looking_id": "456",
"looking_id": "2",
"looking_text": "Prospect new business / sales"
},
{
"user_looking_id": "453",
"looking_id": "3",
"looking_text": "Share trade expertise / stories"
},
{
"user_looking_id": "123",
"looking_id": "5",
"looking_text": "Recruitment"
},
{
"user_looking_id": "654",
"looking_id": "6",
"looking_text": "Seeking business partner"
},
{
"user_looking_id": "123",
"looking_id": "7",
"looking_text": "Advise"
}
]
},
{
"MusicData": [
{
"user_music_id": "54",
"music_id": "2",
"music_name": "Country"
}
]
},
{
"SportData": [
{
"user_sport_id": "234",
"sport_id": "4",
"sport_name": "Hockey"
}
]
},
{
"HobbyData": []
},
[],
{
"MovieData": [
{
"user_movie_id": "645",
"movie_id": "6",
"movie_name": "Drama"
}
]
},
[],
{
"CarrerData": [
{
"user_carrer_id": "34",
"carrer_id": "2",
"carrer_name": "Marketing"
},
{
"user_carrer_id": "645",
"carrer_id": "8",
"carrer_name": "Sales"
}
]
}
]
使用此行获取 json 数组...
NSDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:data //1
options:0
error:&error];
并使用 for 循环获取配置文件数据...
for (NSDictionary *obj in [responseDict valueForKey:@"Profile"])
{
model.userProfileObj.userFirstName = [NSString stringWithFormat:@"%@",[obj valueForKey:@"first_name"]];
}
但在这种情况下,循环运行很多时间并将空值分配给变量。
在此之后我想解析“LookingData”数组,但我使用这段代码得到了空值:
NSDictionary *dictUserLooking=[responseDict valueForKey:@"LookingData"];