The 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 around character 1419.}
Before parsing JSON is a standard format, there is no \ r \ n \ \ t tab in the JSON data.
Today, when parsing, I found that JSON parsing is good and bad, with online JSON parsing is also a problem. Looking for a long time finally found that the tab in the mischief, because the standard JSON parsing is not allowed to have these several tabs. So we need to filter out these tabs when we receive the insulation.
NSString * responsestring = [request responsestring];
responsestring = [responsestring stringbyreplacingoccurrencesofstring:@ "\ r \ n" withstring:@ "];
responsestring = [responsestring stringbyreplacingoccurrencesofstring:@ "\ n" withstring:@ "];
responsestring = [responsestring stringbyreplacingoccurrencesofstring:@ "T" "withstring:@"];
NSLog (@ "responsestring =%@", responsestring);
Sbjsonparser *parser = [[[Sbjsonparser Alloc]init] autorelease];
ID returnobject = [parser objectwithstring:responsestring];
Nsdictionary *userinfo = nil;
Nsarray *userarr = nil;
if ([Returnobject Iskindofclass:[nsdictionary class]]) {
if (userInfo) {
[Userarr release];
}
UserInfo = (nsdictionary*) returnobject;
}
else if ([Returnobject Iskindofclass:[nsarray class]]) {
Userarr = (nsarray*) returnobject;
}
nserror* e = nil;
The method of parsing the system itself.
nsdictionary * userInfo = [nsjsonserialization jsonobjectwithdata:[jsonstring datausingencoding: Nsutf8stringencoding] Options:nsjsonreadingmutableleaves error:&e];
if (e) {
NSLog (@ "%@", e);
}