iphone - 在iphone中使用json解析文本文件

标签 iphone ios json parsing

<分区>

如何在 iphone 中使用“JSON”解析器解析存储在资源文件夹中的文本文件“.txt”? 任何建议将不胜感激。 谢谢内哈·梅塔。

最佳答案

加载文本文件..并初始化 JSON..简单。

   NSString *textPAth = [[NSBundle mainBundle] pathForResource:@"content" ofType:@"txt"];

    NSError *error;
    NSString *content = [NSString stringWithContentsOfFile:textPAth encoding:NSUTF8StringEncoding error:&error];  //error checking omitted

    SBJsonParser *parser = [[SBJsonParser alloc] init];

        NSDictionary *json = [parser objectWithString: content];    

关于iphone - 在iphone中使用json解析文本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9562192/

上一篇:ios - 从后端服务器提取内容更新的最佳解决方案?

下一篇:iOS - 确保应用内电子邮件通过

相关文章:

iphone - 无法在 ios 9 中为 AVCaptureDevice 访问相机。

ios - 如何更改 UITextView 中 UIDataDetector 检测到的链接的颜色?

ios - cocos2d 3.0如何优先处理触摸吞咽

iphone - 当我连接设备 iOS 4.2.1 时,每次在 Xcode Organizer 中都会收到 "Unknown iOS Detected"

iphone - 当应用程序转到后台时如何创建 "return to app"状态栏?

python - 使用 python 处理从 semrush 到 JSON 的 CSV 响应

javascript - 当 json 具有相同名称的键时,new Map() 在 javascript 中如何工作

json - 使用 ARM 模板和 JSON 在 Azure 中创建 VM 时出现 "DiskImageNotReady"错误

iphone - 获取iPhone GO按钮以提交表单

ios - 来自另一个 Controller 的访问方法