NSJSONSerialization适用于IOS 6,但不适用于IOS 5.0

时间:2013-04-21 14:23:47

标签: ios objective-c ios5 ios6 nsjsonserialization

我正在努力恢复iOS 5.1与我发布的应用程序的兼容性,目前需要6.0。

此代码在6.0下完美运行,但在5.1下运行时,解析会在解析完全相同的JSON结果时返回null对象和错误。

NSData *responseData = [request responseData];
NSError *jsonError;
NSDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&jsonError];

if ((responseData == nil) || (responseDict == nil)) {
   // I only get here when running on 5.1            
}

我尝试过弱连接Foundation框架。 jsonError

  

错误Domain = NSCocoaErrorDomain Code = 3840“操作无法完成。(Cocoa error 3840.)”(字符8周围的对象的重复键)UserInfo = 0x11d58530 {NSDebugDescription =字符8周围对象的重复键。 }

我已经验证了我的JSON,并且在字符8处只有一个对象类型的实例,而字符8只是一个冒号:

{"site":{

0 个答案:

没有答案