[英]NSJSONSerialization works on iOS6 but not on iOS5.1
I'm working on restoring iOS5.1 compatibility to an app I shipped which requires 6.0 currently. 我正在努力将iOS5.1兼容性恢复到我目前要求6.0的应用中。
This code works perfectly under 6.0 but when running under 5.1 parsing returns a null object and an error when parsing the exact same JSON result. 该代码在6.0下可以完美运行,但是在5.1下运行时,解析返回空对象,并且在解析完全相同的JSON结果时返回错误。
I tried weak linking the Foundation framework 我尝试弱连接基金会框架
The jsonError is - jsonError是-
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn't be completed. (Cocoa error 3840.)" (Duplicate key for object around character 8.) UserInfo=0x11d58530 {NSDebugDescription=Duplicate key for object around character 8.}
I have validated my JSON set with and there is only a single instance of the object type at character 8 and character 8 is simply a colon: 我已经使用验证了我的JSON集,并且在字符8处只有一个对象类型的实例,而字符8只是一个冒号:
{"site":{
Here's the code... 这是代码...
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
}
try a different reading option for the JSONSerialization? 为JSONSerialization尝试其他读取选项?
NSJSONReadingAllowFragments
That is what I use for my iOS 6 version of my project 这就是我用于项目的iOS 6版本的内容
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.