Converts the JSON string returned by the server into a dictionary-times error:
Error domain=nscocoaerrordomain code=3840 "Invalid escape sequence around character 586."
After careful lookup, after the original resolution of the "\" character to replace the "\" or "\ \" After the resolution succeeds. The specific parsing code is as follows:
-(Nsdictionary *) Parsejsonstringtonsdictionary: (NSString *) jsonstring{jsonstring= [Jsonstring stringbyreplacingoccurrencesofstring:@"\ r \ n"Withstring:@""]; Jsonstring= [Jsonstring stringbyreplacingoccurrencesofstring:@"\ n"Withstring:@""]; Jsonstring= [Jsonstring stringbyreplacingoccurrencesofstring:@"\ t"Withstring:@""]; jsonstring = [jsonstring stringbyreplacingoccurrencesofstring:@ "\ \" withstring:@ ""]; Nserror*error2=Nil; Nsdictionary*dict = [nsjsonserialization jsonobjectwithdata:[jsonstring datausingencoding:nsutf8stringencoding] Options: Nsjsonreadingmutablecontainers error:&Error2]; if([dict isValid]) {returndict; } returnNil;}
iOS parsing JSON string error error Domain=nscocoaerrordomain code=3840 "Invalid escape sequence around character 586."