我正在使用 TouchJSON。调用我的 Rails 应用程序以获取 localhost:3000/posts.json 中的所有“帖子”。这将返回一个 JSON 数组,用方括号括起来。我目前设置为将 jsonString 转换为 NSDictionary,但由于方括号而失败。
NSString *jsonString=[self jsonFromURLString:@"http://localhost:3000/posts.json"];
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
self.dictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error];
使用 TouchJSON 库将此结果转换为 NSArray 的最佳方法是什么?
Error Domain=kJSONScannerErrorDomain Code=-101 "Could not scan dictionary. Dictionary that does not start with '{' character."