概要:
成都創(chuàng)新互聯(lián)是由多位在大型網(wǎng)絡(luò)公司、廣告設(shè)計(jì)公司的優(yōu)秀設(shè)計(jì)人員和策劃人員組成的一個(gè)具有豐富經(jīng)驗(yàn)的團(tuán)隊(duì),其中包括網(wǎng)站策劃、網(wǎng)頁美工、網(wǎng)站程序員、網(wǎng)頁設(shè)計(jì)師、平面廣告設(shè)計(jì)師、網(wǎng)絡(luò)營(yíng)銷人員及形象策劃。承接:成都網(wǎng)站建設(shè)、網(wǎng)站制作、網(wǎng)站改版、網(wǎng)頁設(shè)計(jì)制作、網(wǎng)站建設(shè)與維護(hù)、網(wǎng)絡(luò)推廣、數(shù)據(jù)庫開發(fā),以高性價(jià)比制作企業(yè)網(wǎng)站、行業(yè)門戶平臺(tái)等全方位的服務(wù)。
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的時(shí)候都是標(biāo)準(zhǔn)格式,json數(shù)據(jù)當(dāng)中沒有 \n \r \t 等制表符。
今天在解析的時(shí)候發(fā)現(xiàn)json解析時(shí)好時(shí)壞,用在線json解析也米有問題。找了半天終于發(fā)現(xiàn)是制表符在作怪,由于標(biāo)準(zhǔn)的json解析是不允許有這幾個(gè)制表符的。所以在收到保溫的時(shí)候我們需要把這幾個(gè)制表符給過濾掉。
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;
//系統(tǒng)自帶的解析方式。
NSDictionary * userInfo = [NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableLeaves error:&e]; if (e) { NSLog(@"%@",e); }
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!