【发布时间】:2012-03-05 05:51:12
【问题描述】:
如何使用 iPhone 中的“JSON”解析器解析存储在资源文件夹中的文本文件“.txt”? 任何建议将不胜感激。 谢谢 Neha Mehta。
【问题讨论】:
-
欢迎来到 Stack Overflow。请阅读How to Ask、What have you tried?和How To s The Smart Way。
如何使用 iPhone 中的“JSON”解析器解析存储在资源文件夹中的文本文件“.txt”? 任何建议将不胜感激。 谢谢 Neha Mehta。
【问题讨论】:
加载文本文件..并初始化 JSON..simple.
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];
【讨论】: