【问题标题】:parse text file using json in iphone [closed]在iphone中使用json解析文本文件[关闭]
【发布时间】:2012-03-05 05:51:12
【问题描述】:

如何使用 iPhone 中的“JSON”解析器解析存储在资源文件夹中的文本文件“.txt”? 任何建议将不胜感激。 谢谢 Neha Mehta。

【问题讨论】:

标签: iphone ios json parsing


【解决方案1】:

加载文本文件..并初始化 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];    

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-22
    • 2020-06-04
    • 2013-12-10
    • 1970-01-01
    • 1970-01-01
    • 2017-11-06
    • 2015-01-11
    相关资源
    最近更新 更多