概要:
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:@"rn"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:[NSDictionaryclass]]) {
if(userInfo) {
[userArr release];
}
userInfo = (NSDictionary*)returnObject;
}
elseif([returnObject isKindOfClass:[NSArrayclass]]) {
userArr = (NSArray*)returnObject;
}
NSError* e = nil; //系统自带的解析方式。 NSDictionary * userInfo = [NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableLeaves error:&e];
if(e) {
NSLog(@"%@",e);
} |
凡尔赛法环免广告版 最新版v1.69.1
下载天煞异种 安卓版v1.0.21
下载十三月 (Undecember)最新官方中文版v3.26.0200
下载我不是废柴无限99999钻999999金币游戏 不减反增版v1.2.16
下载我的女友是声优免广告 安卓版v1
我的女友是声优免广告是一款非常好玩的模拟经营类手游,玩家在游
石器帝国去广告版 v8
石器帝国免广告版是游戏的破解版本,在该版本中为玩家去除了广告
校园恋爱模拟器真人版去广告版 v0.0.7
校园恋爱模拟器真人版免广告版是游戏的破解版本,在该版本中为玩
教练我要开球馆内置菜单修改器 安卓版v1.5.4
教练我要开球馆内购版是一款模拟经营类游戏,玩家们将在游戏中创
我的游轮无限砖石 安卓版v1.7.0
我的游轮无限金币钻石版是一款模拟经营类游戏,你将成为一艘游轮