Error Domain = NSCocoaErrorDomain Code = 3840 "The operation couldn't be completed. (Cocoa error 3840 .) "(Unescaped control character around character 1419 .) userInfo = 0x1563cdd0 {NSDebugDescription = Unescaped control character Round character 1419 .}
Previously, json was parsed in standard format, and no tabs such as \ n \ r \ t were found in json data.
During the parsing today, we found that json resolution is good or bad, and there is also a problem with online json resolution. After searching for half a day, I finally found that the tabs are playing a strange role, because the standard json parsing does not allow these tabs. Therefore, when receiving the heat preservation, We need to filter out these tabs.
NSString * responseString = [requestresponseString];
ResponseString = [responseString stringByReplacingOccurrencesOfString: @ "\ r \ n" withString: @ ""];
ResponseString = [responseString stringByReplacingOccurrencesOfString: @ "\ n" withString: @ ""];
ResponseString = [responseString stringByReplacingOccurrencesOfString: @ "\ t" withString: @ ""];
NSLog (@ "responseString = % @", responseString );
SBJsonParser * parser = [[SBJsonParseralloc] init] autorelser];
Id returnObject = [parser objectWithString:ResponseString];
NSDictionary * userInfo = nil;
NSArray * userArr = nil;
If ([returnObject isKindOfClass: [NSDictionary class]) {
If (userInfo ){
[UserArrrelease];
}
UserInfo = (NSDictionary *) returnObject;
}
Else if ([returnObjectisKindOfClass: [NSArrayclass]) {
UserArr = (NSArray *) returnObject;
}
NSError * e = nil;
// Resolution method provided by the system.
NSDictionary *UserInfo = [NSJSONSerializationJSONObjectWithData: [jsonString dataUsingEncoding: NSUTF8StringEncoding] options: NSJSONReadingMutableLeaveserror: & e];
If (e ){
NSLog (@ "% @", e );
}