Iphone json解析期间获取错误

Iphone json解析期间获取错误,iphone,ios,objective-c,json,nsarray,Iphone,Ios,Objective C,Json,Nsarray,我在json解析过程中遇到错误。当我尝试使用浏览器发送参数时,它会向我发送记录存储成功的成功消息。但当我通过iphone发送表单参数时,我什么也得不到,在数组中我得到NULL值。这是json解析代码 NSString *string1 = [[NSString alloc]initWithFormat:@"http://195.78.76.34/bedspace/mobileapi.php?action=save_room_info&Area=%@&Address=%@&am

我在json解析过程中遇到错误。当我尝试使用浏览器发送参数时,它会向我发送记录存储成功的成功消息。但当我通过iphone发送表单参数时,我什么也得不到,在数组中我得到
NULL
值。这是json解析代码

  NSString *string1 = [[NSString alloc]initWithFormat:@"http://195.78.76.34/bedspace/mobileapi.php?action=save_room_info&Area=%@&Address=%@&Living_room=%@&Amenties=%@&Type_of_cost=%@&cost_of_room=%@&Security_deposit=%@&STLC=%@&Days_available=%@&Bill_included=%@&Broadband_available=%@&Exc_Smoke=%@&Exc_gender=%@&Exc_pets=%@&Exc_age=%@&Exc_language=%@&Exc_nationality=%@&Exc_Sexorientition=%@&Exc_intrest=%@&Pre_smoke=%@&Pre_gender=%@&Pre_occupation=%@&Pre_pets=%@&Pre_min_age=%@&Pre_max_age=%@&Pre_nationaltiy=%@&Pre_Language=%@&Pre_Sexorientition=%@&Misc=%@&Title=%@&Description=%@&Your_name=%@&Your_email=%@&Email_alert=%@&No_of_rooms=%@&Country=%@&City=%@&State=%@&Size_of_property=%@&Type_of_property=%@&Occupets_property=%@&My_property_status=%@&Amenties_two=%@&Size_of_room=%@&Refrence_required=%@",area,address,livingRoomVal,amenties,typeOfCost,costOfRoom,securityDeposit,STLC,daysAvailable,billsIncluded,broadbandAvailable,eSmoke,eGender,ePets,eAge,eLanguage,eNationality,eSexOrientation,eInterest,pSmoke,pGender,pOccupation,pPets,pMinAge,pMaxAge,pNationality,pLanguage,pSexOrientation,misc,title,description,yourName,yourEmail,emailAlerts,noOfRooms,country,city,state,sizeOfProperty,typeOfProperty,occupentsOfProperty,myPropertyStatus,amentiesTwo,sizeOfRoom,refrenceRequired];
    NSLog(@"string 1 value %@",string1);
    NSURL *urlRequest = [NSURL URLWithString:string1];
    NSURLRequest *request = [[NSURLRequest alloc]initWithURL:urlRequest];
   NSData *dataResponce = [NSURLConnection sendSynchronousRequest:request returningResponse:Nil error:Nil];

    NSError *jsonParsingError = nil;
    NSArray *publicTimeline = [NSJSONSerialization JSONObjectWithData:dataResponce options:0 error:&jsonParsingError]; 
 NSLog(@"get values %@",publicTimeline);

我不知道是什么问题。我也使用了
SBJsonParser
,但我在数组中没有得到任何东西,之后我使用了NSJSONSerialization,同样的问题仍然发生,我在NSData和NSArray中没有得到任何东西。

您不能用参数填充URL,并且仍然希望它是合法的,因此您需要在使用之前对URL进行URL编码:

NSURL *urlRequest = [NSURL URLWithString:[string1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

您无法使用参数填充URL,并且仍然希望它是合法的,因此您需要在使用前对URL进行URL编码:

NSURL *urlRequest = [NSURL URLWithString:[string1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

显示什么错误日志?尝试使用NSMutableURLRequest并设置HTTP方法POST,这可能有助于您了解参数值是什么?brother我使用了相同的代码来存储注册表记录,它成功地存储了,并且我已经进行了100次json解析,将记录存储在数据库中,从数据库中获取记录,并成功地获取。我不知道为什么我在nslog中获取错误,我在nsarray中获取空值,以及我记录nsdata,它也返回null。显示什么错误日志?尝试使用NSMutableURLRequest并设置HTTP方法POST,这可能有助于您了解参数值是什么?brother我使用了相同的代码来存储注册表记录,它成功地存储了,并且我已经进行了100次json解析,将记录存储在数据库中,从数据库中获取记录,并成功地获取。我不知道为什么我在nslog中获取错误,我在nsarray中获取空值,以及我记录nsdata,它也返回null