我正在尝试使用 Json-Framework 从我的网站解析输出(在 iPhone 上)。网站上的数据是一组新闻对象...通过 PHP 的 json_encode() 传递。
JSON 输出在这里: http: //pastebin.com/Be429nHx
我能够连接到服务器并存储 JSON 数据,然后执行以下操作:
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
// Create a dictionary from the JSON string
NSDictionary *results = [jsonString JSONValue];
NSArray *items = [results valueForKeyPath:@"data.array"];
NSLog(@" NewsID : %@", [[items objectAtIndex:1] objectForKey:@"newsID"]);
我从 NSLog() 行收到以下错误:
-JSONValue failed. Error is: Didn't find full object before EOF
Event Id : (null)
STATE: <SBJsonStreamParserStateStart: 0x4e3c960>
JSONValue failed. Error is: Token 'key-value separator' not expected before outer-most array or object
Event Id : (null)
任何帮助将不胜感激......谢谢!