Domain=NSCocoaErrorDomain Code=3840 "Unescaped control character around character 203." UserInfo={NS
2016-12-19 14:31
716 查看
error = Error Domain=NSCocoaErrorDomain Code=3840 "Unescaped control character around character 203." UserInfo={NSDebugDescription=Unescaped
control character around character 203.}
json在做请求数据解析的时候,部分数据控制台会输出上面的一串代码,大概意思是,持有控制字符,在**字节处。出现这个问题的原因就是:因为服务器返回的字符串里面有换行符,所以我们要在接收到的数据里面,将换行符替换掉,然后再转模型。但是AFN的GET
或者POST里面并没有提供给我们相应的数据,所以就直接进入了
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error)
block块,输出了错误信息。我是这样解决的:手动过滤掉 “\t” “\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];
}
输出的字典直接解析即可
control character around character 203.}
json在做请求数据解析的时候,部分数据控制台会输出上面的一串代码,大概意思是,持有控制字符,在**字节处。出现这个问题的原因就是:因为服务器返回的字符串里面有换行符,所以我们要在接收到的数据里面,将换行符替换掉,然后再转模型。但是AFN的GET
或者POST里面并没有提供给我们相应的数据,所以就直接进入了
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error)
block块,输出了错误信息。我是这样解决的:手动过滤掉 “\t” “\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];
}
输出的字典直接解析即可
相关文章推荐
- Error Domain=NSCocoaErrorDomain Code=3000 "未找到应用程序的“aps-environment”的权利字符串" UserInfo=0x1bad30 {NSLocalizedDescription=未找到应用程序的“aps-environment”的权利字符串}
- Error Domain=NSCocoaErrorDomain Code=3000 "未找到应用程序的“aps-environment”的授权字符串" UserInfo={NSLocalizedDes
- Unescaped control character around character 344.
- AFNetworking提示3840 Unescaped control character around character XXX
- Unescaped control character around character 189
- Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={NSLocalizedDescription=unsuppor
- Unescaped control character around character
- 关于iOS 插入日历功能以报错Error Domain=EKErrorDomain Code=1 "尚未设定日历。" UserInfo={NSLocalizedDescription=尚未设定日历。}
- iOS解析JSON字符串报错Error Domain=NSCocoaErrorDomain Code=3840 "Invalid escape sequence around character 586."
- :Error Domain=ShareSDKErrorDomain Code=207 "(null)" UserInfo={error_message=Can't share because plat
- error LNK2019: unresolved external symbol "__declspec(dllimport) const CReadUserInfo::`vftable'" (__
- iOS开发:AFNetWorking请求报错:NSDebugDescription=Number wound up as NaN around character
- Nautilus-Share-Message: Called "net usershare info" but it failed: Failed to
- iPhone开发笔记(22)-JSONValue Failed. Error is : Unescaped control character的解决方法
- Accelerometer-based User Interfaces for the Control of a Physically Simulated Character
- Error Domain=com.albertodebortoli.goldraccoon Code=-1000 "(null)" UserInfo={message=Can't overwrite directory!}
- "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=;PassWord=;Initial Catalog=;Data Source="
- 错误:Error Domain=NSCocoaErrorDomain Code=3840 "Garbage at end." UserInfo={NSDebugDescription=Garbage
- 一脸懵逼加从入门到绝望学习hadoop之 org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.AccessControlException): Permission denied: user=Administrator, access=WRITE, inode="/":root:supergroup:drwxr-xr报错
- error LNK2019: unresolved external symbol "__declspec(dllimport) const CReadUserInfo::`vftable'" (__