I am developing iOS App. I get JSON data from PHP server in the following code.
NSURL *requestUrl = [NSURL URLWithString:urlString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:requestUrl];
NSHTTPURLResponse *httpResponse;
NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&httpResponse error:nil];
NSString *str= [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSError *e = nil;
NSArray *array =[NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments|NSJSONReadingMutableContainers|NSJSONReadingMutableLeaves error:&e];
NSLog(@"str=%@",str);
NSLog(@"error=%@",e);
NSLog(@"error=%@",e)
says: "Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Badly formed object around character 3010.) UserInfo=0x15ed7f40 {NSDebugDescription=Badly formed object around character 3010.}".
NSLog(@"str=%@",str)
contains: "\343\201"
unexpectedly.
I think the problem is JSON data is not proper and above "\343\201"
causes this problem.
Could you tell me how to solve this problem?