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.的更多相关文章

  1. 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 ...

  2. 【iOS】iOS Error Domain=NSCocoaErrorDomain Code=3840 "未能完成操作。(“Cocoa”错误 3840。)"

    昨天遇到的这个问题,详细信息: ----->类和方法__25+[Manager noticeRequest:]_block_invoke399----->错误信息Error Domain= ...

  3. iOS解析JSON字符串报错Error Domain=NSCocoaErrorDomain Code=3840 "Invalid escape sequence around character 586."

    将服务器返回的JSON string转化成字典时报错: Error Domain=NSCocoaErrorDomain Code=3840 "Invalid escape sequence ...

  4. error = Error Domain=NSCocoaErrorDomain Code=3840

    json解析,同样的请求,有一个请求,无反应.纠结了几天,终于解决了. error = Error Domain=NSCocoaErrorDomain Code=3840 "Unescape ...

  5. 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 ...

  6. [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 ...

  7. Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed.

    地图定位 错误:使用CoreLocation获取地理位置信息,报错 Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be ...

  8. 使用Parse内付费服务出现的Error Domain=Parse Code=146 "The operation couldn’t be completed. (Parse error 146.)

    因为开发一个应用有个内付费去广告功能,介于苹果官方提供的方法没用过,感觉有些复杂,于是选用了第三方组件Parse来解决这个问题,简单易操作: Parse简化苹果官方内付费问题,使用方法分厂简单只有两个 ...

  9. 报错Domain=NSCocoaErrorDomain Code=3840 "Garbage at end."

    网络请求出现报错:Domain=NSCocoaErrorDomain Code=3840 "Garbage at end." 出现的问题是后台返回了两次json数据!

随机推荐

  1. webform控件

    简单控件: 1.Label 会被编译成span标签 属性: Text:文本内容 CssClass:CSS样式 <asp:Label ID=" CssClass="aaa&qu ...

  2. excel基本

    1,换行:control+option(alt)+enter

  3. split和join的用法

    第一点:split 直接举例子,比较直观, >>> f = 'www.baidu.com.cn' >>> f.split()['www.baidu.com.cn'] ...

  4. [No00008C]图解SQL的各种连接join让你对SQL的连接一目了然

    对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对于Select出来的结果集是什么样子有点不是很清楚.Codin ...

  5. [LeetCode] Intersection of Two Arrays 两个数组相交

    Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1] ...

  6. [LeetCode] Min Stack 最小栈

    Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. pu ...

  7. [LeetCode] Minimum Path Sum 最小路径和

    Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...

  8. 初探Socket

    使用Socket Socket是两台主机之间的一个连接,它可以完成7个操作. 连接远程机器 发送数据 接收数据 关闭连接 绑定端口 监听入站数据 在绑定端口上接受来自远程机器的连接 Java中的Soc ...

  9. jetbrain系列IDE设置

    1.代码提示默认ctrl+space(这是全角半角切换),改为alt+/,这与cyclic expand word冲突,直接删掉它就可以了 2.ctrl+M,进入presentation mode,与 ...

  10. CentOS 7.0 使用 yum 安装 MariaDB 与 MariaDB 的简单配置

    1.安装MariaDB 安装命令 yum -y install mariadb mariadb-server 安装完成MariaDB,首先启动MariaDB,两条命令都可以 systemctl sta ...