我是 JSON 解析的新手。我正在使用 SBJson 3.1 并尝试获取数据以响应我遇到的上述错误。我在谷歌上搜索了很多,但没有人问过或解释过错误的真正Illegal Start of Token
含义。所以请有人可以解释一下吗?我该如何调试这个错误?
到目前为止我写的代码是:
-(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];
}