读取本地json文件,并转换为dictionary

Posted davidyff

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了读取本地json文件,并转换为dictionary相关的知识,希望对你有一定的参考价值。

        NSData * data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"demo001" ofType:@"json"]];
        NSLog(@"第一个输出%@",data);
        
        id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
        NSDictionary *responseDic = jsonObject;
        NSLog(@"第二个输出%@",responseDic);

以上是关于读取本地json文件,并转换为dictionary的主要内容,如果未能解决你的问题,请参考以下文章