hmanel hmanel - 11 months ago 94
JSON Question

Parsing JSON which contains html data

I want to parse json data which contains html but there is a problem

I made a parser with this lines but always I got this error: The operation couldn’t be completed. (Cocoa error 3840.)

NSString *str = [[NSString alloc] initWithData:responseObject encoding:NSASCIIStringEncoding];
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding]
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:dataoptions:NSJSONReadingMutableContainers error:&error];


You need to fix the incoming JSON object. You will need to encode that HTML in your web-service (whatever that may be). You should be able to see the issue when you run your JSON through a validator like JSONViewer or JSONLint.