Error = 3840 when parsing data in iOS and error3840 when parsing data in ios
1. An error occurred while parsing the JSon data format.
Unescaped control character around character XXXX
And The data couldn 'tbe read because it isn' t in the correct format.
Error code 3840
In this case, it is generally caused by non-standard json data, which may be caused by escape characters in json data, such as/t/n/0.
Solution to nonstandard data: 1. modify data in the background
2. Determine the data in your project and take the AFNetWorking library for data download.
// Download the data to be searched
AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager];
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];
Parses the parsed NSData into a string to determine whether the data contains these escape characters. If the data contains these escape characters, replace them with an empty string and convert the string to NSData, then parse the data into JSon data.