I am using following code snippet to parse JSON object from the url.
NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlAddress] options:NSDataReadingUncached error:&error];
if (error != nil) {
NSLog(@"%@",[error localizedDescription]);
} else {
NSLog(@"No Error: %@", data); //looks good here. console displays the raw data
}
id result = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
if (error != nil) {
NSLog(@"%@",[error localizedDescription]);
return nil;
} else {
NSLog(@"No Error: %@", [result objectForKey:@"exams"]); //console displays the value ("No Error: value for key...") unless a degree symbol is present in which case it displays No Error: (null)
}
I have some 10 urlAddresses,for 7 urls JSONObjectWithData returns json object.for remaining 3 urls JSONObjectWithData returns null.I tried opening this urls in safari.I have seen some junk characters in it.I suspect problem is with this junk character.How to solve this issue?
I have seen this "JSONObjectWithData returns null if degree symbol is in json object" link similar.suggested to use unicode escape sequence.How to use this "unicode escape sequence" to solve my issue.