iOS json 解析遇到error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed.
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Unescaped control character around character 1419.) UserInfo=0x1563cdd0 {NSDebugDescription=Unescaped control character around character 1419.}
之前解析json的时候都是标准格式,json数据当中没有 \n \r \t 等制表符。
今天在解析的时候发现json解析时好时坏,用在线json解析也米有问题。找了半天终于发现是制表符在作怪,由于标准的json解析是不允许有这几个制表符的。所以在收到保温的时候我们需要把这几个制表符给过滤掉。
NSString * responseString = [request
responseString];
responseString = [responseString stringByReplacingOccurrencesOfString:@"\r\n"
withString:@""];
responseString = [responseString stringByReplacingOccurrencesOfString:@"\n"
withString:@""];
responseString = [responseString stringByReplacingOccurrencesOfString:@"\t"
withString:@""];
NSLog(@"responseString = %@",responseString);
SBJsonParser *parser = [[[SBJsonParser
alloc]init]
autorelease];
id returnObject = [parser
objectWithString:responseString];
NSDictionary *userInfo =
nil;
NSArray *userArr =
nil;
if ([returnObject
isKindOfClass:[NSDictionary
class]]) {
if (userInfo) {
[userArr
release];
}
userInfo = (NSDictionary*)returnObject;
}
else if ([returnObject
isKindOfClass:[NSArray
class]]) {
userArr = (NSArray*)returnObject;
}
NSError* e = nil;
//系统自带的解析方式。
NSDictionary * userInfo = [NSJSONSerialization
JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding]
options:NSJSONReadingMutableLeaves
error:&e];
if (e) {
NSLog(@"%@",e);
}
iOS json 解析遇到error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed.的更多相关文章
- NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)"
原文: http://stackoverflow.com/questions/19874935/afnetworking-2-0-post-issue-cocoa-error-3840json-tex ...
- 【iOS】iOS Error Domain=NSCocoaErrorDomain Code=3840 "未能完成操作。(“Cocoa”错误 3840。)"
昨天遇到的这个问题,详细信息: ----->类和方法__25+[Manager noticeRequest:]_block_invoke399----->错误信息Error Domain= ...
- iOS解析JSON字符串报错Error Domain=NSCocoaErrorDomain Code=3840 "Invalid escape sequence around character 586."
将服务器返回的JSON string转化成字典时报错: Error Domain=NSCocoaErrorDomain Code=3840 "Invalid escape sequence ...
- error = Error Domain=NSCocoaErrorDomain Code=3840
json解析,同样的请求,有一个请求,无反应.纠结了几天,终于解决了. error = Error Domain=NSCocoaErrorDomain Code=3840 "Unescape ...
- iOS使用UIWebView遇到Error Domain=WebKitErrorDomain Code=101 “The operation couldn’t be completed. (WebKitErrorDomain error 101
现在在接触iOS开发,今天在调试一个界面加载web页面的问题,发现死活无法加载,浏览器里能正常打开,加上相应代码之后得到了错误信息为: 2013-04-18 15:05:06.446 Client_D ...
- [ios] 定位报错Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error ...
- Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed.
地图定位 错误:使用CoreLocation获取地理位置信息,报错 Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be ...
- 使用Parse内付费服务出现的Error Domain=Parse Code=146 "The operation couldn’t be completed. (Parse error 146.)
因为开发一个应用有个内付费去广告功能,介于苹果官方提供的方法没用过,感觉有些复杂,于是选用了第三方组件Parse来解决这个问题,简单易操作: Parse简化苹果官方内付费问题,使用方法分厂简单只有两个 ...
- 报错Domain=NSCocoaErrorDomain Code=3840 "Garbage at end."
网络请求出现报错:Domain=NSCocoaErrorDomain Code=3840 "Garbage at end." 出现的问题是后台返回了两次json数据!
随机推荐
- 首页大图淡入淡出效果工具flexslider
网站首页放几张高清大图轮流播放展示是目首页设计的流行做法,虽然woothemes.com已经公布了比较成熟的flexslider工具,但本着造轮子的心态,我也做了一个自己的flexslider,当然我 ...
- Python学习实践-----打印日历
使用python语言实现在控制台打印日历 输入年.月.日 输出对应日历,指定的日数输出为'--' 程序没有做严格的输入验证,故输入整数即可. 以下为没有优化的源码: print_calendar.py ...
- 自动化运维工具ansible部署以及使用
测试环境master 192.168.16.74webserver1 192.168.16.70webserver2 192.168.16.72安装ansiblerpm -Uvh http://ftp ...
- dubbo 配置解析
1.dubbo 常用配置 <dubbo:service/> 服务配置,用于暴露一个服务,定义服务的元信息,一个服务可以用多个协议暴露,一个服务也可以注册到多个注册中心.eg.<dub ...
- RESTful API 设计指南
转自:http://www.ruanyifeng.com/blog/2014/05/restful_api.html 网络应用程序,分为前端和后端两个部分.当前的发展趋势,就是前端设备层出不穷(手机. ...
- 43. Multiply Strings
/** * @param {string} num1 * @param {string} num2 * @return {string} */ var multiply = function(num1 ...
- Python NaN
NaN, Not a Number, 非数. 它即不是无穷大, 也不是无穷小, 而是python/numpy/... 觉得无法计算时返回的一个符号(自己的推测, 未考证(TODO)). import ...
- 精选30道Java笔试题解答
转自:http://www.cnblogs.com/lanxuezaipiao/p/3371224.html 都 是一些非常非常基础的题,是我最近参加各大IT公司笔试后靠记忆记下来的,经过整理献给与我 ...
- 关于pc端直播
写这篇文章首先是想给自己一个总结.整理,还有就是给那些 没有特别明白直播是怎么回事的人一点 思路 最近公司想要做pc端直播,作为一个自认为很菜的前端实在是不知从何下手,所以只能用国人最爱的百度,搜索了 ...
- 测试或运维工作过程中最常用的几个linux命令?
大家在测试工作过程中,可能会遇到需要你去服务器修改一些配置文件,譬如说某个字段的值是1 则关联老版本,是0则关联新版本,这时候你可能就需要会下vi的命令操作:或者查看session设置的时长,可能需 ...