我试图解析这个看起来像我写得很好的JSON,但NSJSONSerialization
不认为相同的AFAIK,因为它返回NSArray
。NSJSONSerialization不解析这个JSON
这是我的代码:
NSData* gamesData = [NSData dataWithContentsOfURL:
[NSURL URLWithString:@"http://s42sport.com/polarice/json/games.json"]
];
NSDictionary* json = nil;
if (gamesData) {
json = [NSJSONSerialization
JSONObjectWithData:gamesData
options:kNilOptions
error:nil];
NSLog(@"%d",json.count);
}
的问题是,
有什么不对的JSON?为什么NSSerialization不会返回给我NSDictionary?
编辑:是的,我刚刚了解了vs {...}。谢谢。
JSON是一个数组。除了你期望它是一本字典以外没有什么不对。 – rmaddy
查看我的代码suerly为你工作... – Jitendra
看起来像你没有花费很多精力在寻找甚至基本的JSON语法。 – hawk