Error = Error Domain=nscocoaerrordomain code=3840 "unescaped control character around character 203." userinfo={nsdebugdescription=unescaped control character around character 203.}
JSON when parsing the request data, some data consoles output a string of code above, presumably meaning, holding the control character at the * * byte. The reason for this problem is that because there are line breaks in the string returned by the server, we need to replace the newline character in the received data and then turn the model back. But AFN's get or post did not provide us with the corresponding data, so we went directly into the
failure:^ (Nsurlsessiondatatask * _nullable task, Nserror * _nonnull error) block, output error message. I solved it by manually filtering out "\ n" "\ r"
Nsurl * URL = [Nsurl urlwithstring:@ "http://*********/****/home/content/showarticle"];
Nsurlrequest * request = [nsurlrequest Requestwithurl:url];
Nsurlsession * session = [nsurlsession sharedsession];
Nsurlsessiondatatask * Datatask = [session datataskwithrequest:request completionhandler:^ (NSData * _Nullable data, Nsurlresponse * _nullable response, Nserror * _nullable error) {
NSString * str = [[NSString alloc]initwithdata:data encoding:nsutf8stringencoding];
NSString * str2 = [str stringbyreplacingoccurrencesofstring:@ "T" withstring:@ "];
STR2 = [str2 stringbyreplacingoccurrencesofstring:@ "\ n" withstring:@ "];
STR2 = [str2 stringbyreplacingoccurrencesofstring:@ "\ r" withstring:@ "];
Nsdictionary * UserInfo = [nsjsonserialization jsonobjectwithdata:[str2 datausingencoding:nsutf8stringencoding] Options:nsjsonreadingmutableleaves Error:nil];
NSLog (@ "%@", userInfo);
}];
[Datatask resume];
The output dictionary can be parsed directly