I am sending a request to a server in the following way:
- (void) getData
{
NSString *url= @"http://example.com";
NSMutableURLRequest *theRequest= [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
exampleConnection =[[NSURLConnection alloc] initWithRequest:theRequest delegate:self startImmediately:YES];
}
And for this the response is a JSON file, which I am parsing as follows:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"Connection did finish loading %@",[connection currentRequest]);
NSDictionary *exampleDictionary = [NSJSONSerialization JSONObjectWithData:receivedData options: NSJSONReadingAllowFragments error:nil];
NSLog(@"%@", exampleDictionary); // which gives me null
}
The response worked fine earlier. But now it gives me a null, which is obviously because something is hindering the conversion from JSON to NSDictionary. I investigated and found that the problem was because there were a couple of foreign characters (Chinese or something), at which the parsing process was going wrong.
I am not sure how to solve this problem. Does anyone have any ideas?