[Solved] i have json data given below and i want to display it in a table


In your .h file take NSMutableArray :

@property (nonatomic, retain) NSMutableArray *employeeData;

in .m file

@synthesize employeeData;

Then Make Necessary changes in your code.

-(void)getEmpData
{

 self.employeeData=[[NSMutableArray alloc] init];


     NSData *jsonData = @"Your Json Data";

            NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&error];

        NSArray *arrDepartment = [jsonDictionary objectForKey:@"Departments"];

        NSArray *arrEmployees = [[arrDepartment objectAtIndex:0] objectForKey:@"Employees"];


          self.employeeData= [arrEmployees mutableCopy];  
}



-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

NSDictionary *dict =[self.employeeData objectAtIndex:indexPath.row];

             NSLog(@"empname=%@", [dict objectForKey:@"name"]); 
             NSLog(@"empid=%@",[dict objectForKey:@"id"]); 
             NSLog(@"salary=%@",[dict objectForKey:@"salary"]);           

}

3

solved i have json data given below and i want to display it in a table