I have problems with some public json services with serveices formatted this way
jsonFlickrFeed({
"title": "Uploads from everyone",
"link": "http://www.flickr.com/photos/",
"description": "",
"modifi ... })
NSJSONSerialization seems to be unable to make its work
NSURL *jsonUrl = [NSURL URLWithString:@"http://d.yimg.com/autoc.finance.yahoo.com/autoc?query=yahoo&callback=YAHOO.Finance.SymbolSuggest.ssCallback"];
NSError *error = nil;
NSData *jsonData = [NSData dataWithContentsOfURL:jsonUrl options:kNilOptions error:&error];
NSMutableDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:&error];
NSLog(@"%@", jsonResponse);
Using the latest web API I have solved my problem.
For reference, the old web API is: http://api.flickr.com/services/feeds/photos_public.gne?id=xxxxxxxx&lang=en-us&format=json
The current web API is: http://api.flickr.com/services/feeds/photos_public.gne?id=xxxxxxxx&lang=en-us&format=json&nojsoncallback=1
It's done.
I think that NSJSONSerialization can't deal with the jsonFlickrFeed ( ... ) in your JSON code. The problem is that the pure response is invalid JSON (test it here).
So you will have to build a way around this issue. You could for example search for the string jsonFlickrFeed( in the response and delete it or - the easier way - just cut off the beginning until the valid JSON starts and cut off the last character (which should be the bracket).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With