我是JSON解析的新手。我正在使用SBJson 3.1,並試圖獲取數據以應對我所遇到的錯誤。我在谷歌上搜索了很多,但沒有人問過或解釋實際上錯誤Illegal Start of Token
的含義。所以請能有人解釋我這個?我該如何調試這個錯誤?JSON值失敗。錯誤是:令牌非法啓動[<]
到目前爲止我寫的代碼是:
-(IBAction) Start:(id)sender
{
responseData = [[NSMutableData data] retain];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:URL]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
-(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[responseData setLength:0];
}
-(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[responseData appendData:data];
}
-(void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
label.text = [NSString stringWithFormat:@"Connection failed: %@", [error description]];
[connection release];
responseData = nil;
}
-(void) connectionDidFinishLoading:(NSURLConnection *)connection
{
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];
NSDictionary *dict = [responseString JSONValue];
}
什麼是你的JSON輸入? –
我只是提供URL「xyz/Final/webserviceName.php」來獲取整個數據以用於測試目的。 – NightFury
哦,是的,我完全可以用它來告訴你問題是什麼。如何告訴我什麼是數據? –