Reputation: 8192
Feeding the json-parser with the this data: http://mapadosradares.com.br/api/get_initial_load yields this error: Token 'start of array' not expected after outer-most array or object
Here is my code:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
NSLog(@"Connection didReceiveData of length: %u", data.length);
// Printing the received data
size_t length = [data length];
unsigned char aBuffer[length];
[data getBytes:aBuffer length:length];
//aBuffer[length - 1] = 0;
NSLog(@"\n\n\n\n%s\n\n\n\n", aBuffer);
SBJsonStreamParserStatus status = [parser parse:data];
if (status == SBJsonStreamParserError) {
NSLog(@"Parser error: %@", parser.error);
} else if (status == SBJsonStreamParserWaitingForData) {
NSLog(@"Parser waiting for more data");
}
}
As far as I can tell the JSON is perfectly fine. Any thoughts?
UPDATE:
Here's the parser initalization:
- (void) getInitialLoad
{
adapter = [[SBJsonStreamParserAdapter alloc] init];
parser = [[SBJsonStreamParser alloc] init];
adapter.delegate = self;
parser.delegate = adapter;
NSString *url = @"http://mapadosradares.com.br/api/get_initial_load";
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
}
Upvotes: 1
Views: 1422
Reputation: 17906
Are you properly initializing the parser between requests? You haven't shown your code, but it seems like this would be a reasonable error to expect if you ran two successive calls to the feed through the parser.
By the way, I ran the feed output through the excellent JSON parser at http://jsonlint.com and it does appear to be fine.
Upvotes: 2