[
{
"novelname":"西游记",
"novelauthor":"吴承恩",
"novelpage":100000
},
{
"novelname":"水浒传",
"novelauthor":"施耐庵",
"novelpage":100000
},
{
"novelname":"还珠格格",
"novelauthor":"琼瑶",
"novelpage":100000
},
]
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)awakeFromNib//用storyboard的时候,用这个初始化
{
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self parserJson];
}
- (void)parserJson
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"Novel" ofType:@"json"];
NSData *data = [[NSData alloc] initWithContentsOfFile:path];
NSArray *array = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingMutableContainers error:nil];
NSLog(@"%@",array);
//把数字转换成字符串
NSNumber *num = [NSNumber numberWithInt:100];
NSString *str = [NSString stringWithFormat:@"%@",num];
}