iOS json 解析遇到error: Error Domain=NSCocoaErrorDomain Code=3840 quot;The operation couldn’t be comple
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 quot;The operation couldn’t be comple相关推荐
- iOS开发Post请求错误:Error Domain=NSCocoaErrorDomain Code=3840 JSON text did not start with array or ...
由于最近忙着开发项目,好几天没来写博客了.我把最近遇到的一个小bug来和大家分享一下. 最近iOS开发中,客户端需要使用http POST去进行请求服务器.需要发送的是XML格式的,当然接收的也是XM ...
- Error Domain=NSCocoaErrorDomain Code=3840 JSON text did not start with array or object and option
数据请求失败 报错 Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or ob ...
- Error Domain=NSCocoaErrorDomain Code=3840 The operation couldn’t be completed. (Cocoa error 3840.)
AF解析json出错: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn't be completed. (Co ...
- iOS Error Domain=NSCocoaErrorDomain Code=4099
Xcode 控制台报错: [Client] Sending selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 " ...
- DeviceToken 获取失败,原因:Error Domain=NSCocoaErrorDomain Code=3000 未找到应用程序的“aps-environment”的授权字符串......
apns -> 注册推送功能时发生错误, 错误信息: Error Domain=NSCocoaErrorDomain Code=3000 "未找到应用程序的"aps-envi ...
- 七牛报错error: Error Domain=NSCocoaErrorDomain Code=256 “未能打开该文件。
搞了一个项目,发现iOS11.2 可以上传视频成功,但是iOS13到14.0都不成功.debug发现这个问题. QiNiuLogic.m:93 QiNiuLogic <QNResponseInf ...
- 报错: Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099
报错: Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 问题原因: ...
- xcode 报Remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 The connec...
Xcode 运行真机正常 运行模拟器报"Remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=40 ...
- 使用AFNetWorking读取JSON出现NSCocoaErrorDomain Code=3840的解决方法
最近在使用AFNetworkWorking读取JSON时,出现了NSCocoaErrorDomain Code=3840的错误.这种错误应该是服务器端返回JSON格式不对造成的.通过Google搜到这 ...
最新文章
- OpenCV使用CUDA处理图像的教程与实战
- Cerebras发布全球首个人类大脑规模的AI解决方案
- 重新定义数据库历史的时刻——时间序列数据库Schwartz认为InfluxDB最有前途,Elasticsearch也不错...
- python编程在哪里写程序-教你如何编写、保存与运行Python程序的方法
- python 中__name__ = '__main__' 的作用
- 《需求工程——软件建模与分析》阅读笔记二
- cnn 句向量_深度学习目标检测Fast R-CNN论文解读
- Webpack 常用命令总结以及常用打包压缩方法
- IMP-00041: 警告: 创建的对象带有编译警告解决办法
- php 如何保存录像文件,如何录制屏幕并保存下来?
- python选择语句是什么语句_Python语言中的三种选择语句
- Guava - Collections - Immutable collections
- 消灭内存不能为read或written等错误
- Linux 通配符 与 正则表达式 的区别与详解
- LWC 61:741. Cherry Pickup
- PUF论文整理2:2021_A_Novel_Modeling-Attack_Resilient_Arbiter-PUF_Design
- Flutter 自定义实现时间轴、侧边进度条
- 使用spark.streaming.kafka.consumer.poll.ms和reconnect.backoff.ms解决spark streaming消费kafka时任务不稳定的问题
- 如何把Pod本地化(Localize)
- mysql异地灾备架构_最佳实践 数据库异地灾备
热门文章
- 图像分类性能提升方案
- 计算机网络基础概念ppt,1-1计算机网络基础概念.ppt
- mac上安装不了oh my zsh解决方案 亲测有效
- (4)微信UI自动化-联系人采集(C#)
- 移动办公时代,就看华为云桌面
- P2382 化学分子式
- 2019淘宝自动静默关注店铺,在线生成
- prometheus监控ssl证书过期(使用插件blackbox_exporter)
- 安装oracle执行runInstaller文件时报错:“……/install/.oui:Permission denied”
- mysql排行榜制作思路_排行榜的简单设计思路