¸ÅÒª£º
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µÄʱºò¶¼ÊDZê×¼¸ñʽ£¬jsonÊý¾Ýµ±ÖÐûÓÐ \n \r \t µÈÖÆ±í·û¡£
½ñÌìÔÚ½âÎöµÄʱºò·¢ÏÖjson½âÎöʱºÃʱ»µ£¬ÓÃÔÚÏßjson½âÎöÒ²Ã×ÓÐÎÊÌâ¡£ÕÒÁ˰ëÌìÖÕÓÚ·¢ÏÖÊÇÖÆ±í·ûÔÚ×÷¹Ö£¬ÓÉÓÚ±ê×¼µÄjson½âÎöÊDz»ÔÊÐíÓÐÕ⼸¸öÖÆ±í·ûµÄ¡£ËùÒÔÔÚÊÕµ½±£ÎµÄʱºòÎÒÃÇÐèÒª°ÑÕ⼸¸öÖÆ±í·û¸ø¹ýÂ˵ô¡£
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 ½âÎöÓöµ½´íÎóÎÊÌâ½â¾ö°ì·¨】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!