我正在解析 iphone 应用程序中的 json 数据。但它没有正确解析它。
我正在使用以下代码:
- (void)getSurveyList {
user_id=user_id;
NSLog(@"This is uerid %@",user_id);
NSArray *tempArray =[[DataManager staticVersion] startParsing:@"http://myser-solutions.com/app/surveyList.php?user_id=user_id"];
for (int i = 0; i<[tempArray count]; i++) {
id *item = [tempArray objectAtIndex:i];
NSDictionary *dict = (NSDictionary *) item;
ObjectData *theObject =[[ObjectData alloc] init];
[theObject setUser_id:[dict objectForKey:@"user_Id"]];
[theObject setSurvey_Id:[dict objectForKey:@"survey_Id"]];
[theObject setSurvey_Name:[dict objectForKey:@"survey_Name"]];
[theObject setTotal_Question:[dict objectForKey:@"total_Question"]];
[theObject setAdministrator_Email:[dict objectForKey:@"administrator_Email"]];
[theObject setStart_Date:[dict objectForKey:@"start_Date"]];
[theObject setEnd_Date:[dict objectForKey:@"end_Date"]];
[theObject setStatus:[dict objectForKey:@"status"]];
[theObject setAdministrator_Email:[dict objectForKey:@"user_Password"]];
[surveyList addObject:theObject];
[theObject release];
theObject=nil;
int count =[surveyList count];
NSLog(@"Total is %d",count);
}
}
在我调试代码时它不会进入循环。我不知道为什么。
JSON响应
ali40[{"user_Id":"ali40","survey_Id":"1","survey_Name":"Veritas 调查","total_Questions":"20","administrator_Email":"engr.jamshedali@hotmail.com", "start_Date":"20-9-2012","end_Date":"1-10-2012","status":"Active","user_Password":"jackson12"},{"user_Id":"ali40", "survey_Id":"2","survey_Name":"Celeritas 调查","total_Questions":"20","administrator_Email":"jani_06sw@yahoo.com","start_Date":"10-11-2012"," end_Date":"12-12-2012","status":"Active","user_Password":"jackson12"}]