0
votes

I have a JSON file which I am trying to parse as seen below

-(void)loadSuraNames
{
NSURL * url = [NSURL URLWithString:@"http://www.submission.ws/downloads/json/"];

url = [url URLByAppendingPathComponent:@"quran_main.json"];

NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil    error:nil];

NSError *jsonParsingError = nil;
NSArray *array = [NSJSONSerialization JSONObjectWithData:response options:0 error:&jsonParsingError];

NSLog(@"my Json is empty :( %@", array);
}

But I am not getting any data back. Any one has any ideas what the problem is?

I am getting the following error:

Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid escape sequence around character 278.) UserInfo=0xa47ff60 {NSDebugDescription=Invalid escape sequence around character 278.}

1
What does the error tell you? What is the data you are getting back?quellish
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid escape sequence around character 278.) UserInfo=0xa47ff60 {NSDebugDescription=Invalid escape sequence around character 278.}real 19
Looks like you have some bad data. Always remember the recommended way to use NSError - see developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/…quellish

1 Answers

1
votes

The JSON script was adding "/" characters that I manually removed and the problem is gone :)