0622.獲取json文件的數據

 

一、Json文件結構分析json

 

二、在OC中讀取Json文件數組

//       一、獲取全路徑
        NSString *full = [[NSBundle mainBundle] pathForResource:@"help.json" ofType:nil];
//       二、獲取文件的數據
        NSData *data = [NSData dataWithContentsOfFile:full];
//       三、將數據轉化成NSArray數組
        NSArray *jsonArr = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:NULL];

 2.1 給pathForResource傳入一個文件名稱,就能夠獲取文件所在的全路徑blog

 2.2 把文件轉化成NSData數據it

 2.3 使用NSJSONSerialization類裏面的JSONObjectWithData:方法就能夠把數據所有轉化成一個NSArray數組,裏面存放NSDictionary字典io

相關文章
相關標籤/搜索