1. Parsing problems with JSON data format error
unescaped control character around character XXXX
And the data couldn ' t be read because it isn ' t in the correct format.
Error code is 3840
When this happens, it is generally caused by the non-specification in the JSON data, the presence of an escape character in the JSON data may cause this, such as a/t/n/0, etc.
Data is less canonical workaround: 1. Background modification Data
2. Judging the data in your own project, take afnetworking when the library downloads data
Download the data you need to search
Afhttprequestoperationmanager *manager = [Afhttprequestoperationmanager manager];
Manager.responseserializer = [Afhttpresponseserializer serializer];
[Manager get:urlstring Parameters:nil success:^ (afhttprequestoperation *operation, id responseobject) {
NSString * str = [[NSString alloc]initwithdata:responseobject encoding:nsutf8stringencoding];
NSString * str2 = [str stringbyreplacingoccurrencesofstring:@ "\ T" withstring:@ ""];
STR2 = [str2 stringbyreplacingoccurrencesofstring:@ "\ n" withstring:@ ""];
STR2 = [str2 stringbyreplacingoccurrencesofstring:@ "\ r" withstring:@ ""];
Nsdictionary *dict = [nsjsonserialization jsonobjectwithdata:[str2 datausingencoding:nsutf8stringencoding] Options: Nsjsonreadingmutablecontainers Error:nil];
Parse the resulting NSData data into a string form, determine whether the data contains these escape characters, the words are replaced with an empty string, and then convert the string to the NSData type of data, and then parse it into JSON data.
iOS parsing data when error=3840