ios解析json

if (_helps == nil) {
        
        NSString *path = [[NSBundle mainBundle] pathForResource:@"help.json" ofType:nil];
        
        NSData *data = [NSData dataWithContentsOfFile:path];
        
        NSArray *dictArray = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:NULL];
        
        NSMutableArray *models = [[NSMutableArray alloc] initWithCapacity:dictArray.count];
        
        for (NSDictionary *dict in dictArray) {
            NJHelp *help = [NJHelp helpWithDict:dict];
            [models addObject:help];
        }
        _helps = models;
    }

 

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