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);

}

}

你可能感兴趣的:(JSONkit解析)