你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> IOS json ½âÎöÓöµ½´íÎóÎÊÌâ½â¾ö°ì·¨

IOS json ½âÎöÓöµ½´íÎóÎÊÌâ½â¾ö°ì·¨

編輯:IOS開發綜合

¸ÅÒª£º

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 ½âÎöÓöµ½´íÎóÎÊÌâ½â¾ö°ì·¨】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved