JSONkit解析

#import "forthViewController.h"

#import "GDataXMLNode.h"

#import "student.h"

#import "JSONKit.h"

#import "wljx.h"

@interface forthViewController ()

@end@implementation forthViewController

- (void)viewDidLoad {   

 [super viewDidLoad];    


}

- (void)didReceiveMemoryWarning {  

  [super didReceiveMemoryWarning];    

 }

-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event{

NSLog(@"jsonki 解析");

//1

//    NSString *filepath =[[NSBundle mainBundle]pathForResource:@"JSON_stu" ofType:@"txt"];

//    NSData *date =[NSData dataWithContentsOfFile:filepath];

//    //3.使用jsonkit中的objectFromJsondata

//    NSArray *array =[date objectFromJSONData];

//    for (NSDictionary *DIC in array) {

//        student *STU =[[student alloc]init];

//        [STU setValuesForKeysWithDictionary:DIC];

//        NSLog(@"%@",STU);

//    }

NSString *filepath = [[NSBundle mainBundle]pathForResource:@"JSON1" ofType:@"txt"];

NSData *data =[NSData dataWithContentsOfFile:filepath];

NSArray *array =[data objectFromJSONData];

for (NSDictionary *dic in array) {

wljx *stu =[[wljx alloc]init];

[stu setValuesForKeysWithDictionary:dic];

NSLog(@"%@",stu);

}

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容