当我尝试解析JSON响应,我得到了一个空的响应与此错误:我的应用程序没有解析JSON响应
JSONValue failed. Error trace is: (
"Error Domain=org.brautaset.JSON.ErrorDomain Code=11 \"Unexpected end of string\" UserInfo=0x797c420 {NSLocalizedDescription=Unexpected end of string}"
)
这是我尝试发送JSON请求和我怎样努力解析其响应:
发送JSON请求:
- (void)viewWillAppear:(BOOL)animated{
//Specify the adress of the webservice (url)
NSURL *url = [NSURL URLWithString:@"http://xxxxxxxxxxx.com/webservices/"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
NSString *jsonStringArray=[aMutableArray JSONRepresentation];
NSLog(@"-------------");
NSLog(@"%@",jsonStringArray);
NSLog(@"-------------");
[request setPostValue:jsonStringArray forKey:@"liste_des_themes"];
NSLog(@"The response string is: %@",request.responseString);
[request setDelegate:self];
[request startAsynchronous];
}
对于NSLog
这里我想送它我得到一个正确的JSON格式之前显示JSON字符串:
NSLog(@"%@",jsonStringArray);//["Mairie","Préfectures et sous-préfectures"]
现在第二NSLog
,我得到空:
NSLog(@"The response string is: %@",request.responseString);//The response string is: (null)
当解析响应:
-(void)requestFinished:(ASIHTTPRequest *)request
{
if(request.responseStatusCode==200)
{
NSLog(@"This block gets called, response code is 200");//This block gets called, response code is 200
//parse the response
NSLog(@"The response string is: %@",request.responseString);
NSString *responseString=[request responseString];
NSDictionary *responseDict=[responseString JSONValue];
}
}
对于NSLog
试图显示响应字符串,我什么也没得到,既不为零也不正确:
NSLog(@"The response string is: %@",request.responseString);
//The response string is:
而在这之后,我得到这个错误跟踪:
JSONValue failed. Error trace is: (
"Error Domain=org.brautaset.JSON.ErrorDomain Code=11 \"Unexpected end of string\" UserInfo=0x797c420 {NSLocalizedDescription=Unexpected end of string}"
)
你能帮助我吗? thanx提前。
对我来说,它看起来像一个服务器端问题 – vikingosegundo