Andrew Johnson
Andrew Johnson

Reputation: 13286

Failing to parse JSON... is the encoding messed up?

I am trying to parse the JSON returned here: http://www.waterwayguide.com/map/php/bridge.php?ll=25.514339,-80.076164

However, I can't parse it as I normally would it seems:

NSData *jsonData = [[(ASIHTTPRequest*)[data objectForKey:@"request"] responseString] dataUsingEncoding:NSUTF32BigEndianStringEncoding]; 
NSLog(@"this prints as expected %@", [(ASIHTTPRequest*)[data objectForKey:@"request"] responseString]);
NSArray* jsonNodes = [[CJSONDeserializer deserializer] deserialize:jsonData error:&error];
NSLog(@"this is unexpectedly nil %@", jsonNodes);

I have used this precise code on a different JSON feed and it works nicely. Is there something I can do on the client side to parse this feed properlY?

Upvotes: 0

Views: 313

Answers (1)

Matthew Flaschen
Matthew Flaschen

Reputation: 284786

That feed isn't JSON. Look at the source. It's text/html and it doesn't validate because it attempts to escape ' with \'. Altogether, it seems to be a quick attempt to manually output JSON instead of HTML.

Upvotes: 2

Related Questions