I'm sending out a request to an external API and parsing a response with the SBJson parser. However, I suspect the response is so long, it is somehow getting jumbled.
In my mainviewcontroller.h file I set NSMutableData *receivedData;
so that I can use it in the connection methods in the mainviewcontroller.m file.
However, after the connection finishes loading, I execute the following:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *dataString = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
NSArray *allData = [dataString JSONValue];
}
However, I get a bunch of errors saying that the JSON is not properly formatted. So, when I look at the JSON, its very long – but here and there, there are problems... for example, the "updated_at" below.
{
"id": 7844333,
"position": 3,
"content": "Cell height is off by 5 pixels",
"created_at": "2012-06-04T20:31:30-05:00",
"updated_at": "2ator": {
"id": 98258,
"name": "Brian"
}
What I think happened above is that updated at has a value of "2012-06...etc" and the next key-value item would be creator : { id, name } but it somehow got jumbled into updated at.
Anyone having a similar problem? I don't think the problem is with the JSONValue because I nslog out the dataString before it gets parsed, and thats where I find the JSON errors.
What I mean by that is that NSString *dataString = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
is just a long string, but has bad JSON in it because it is jumbled.