如何parsing表视图上的API响应?

我的JSON响应数据合成为: –

[{"0":"1","id":"1","1":"Pradeep","name":"Pradeep","2":null,"sender":null,"3":null," 

所以parsing表视图上的“名称”?

我自己的实现是:

我是新的ios开发请帮助我

 -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSDictionary *allDataDictionary=[NSJSONSerialization JSONObjectWithData:webData options:0 error:nil]; // response saved in allDataDictionary NSDictionary *feed=[allDataDictionary objectForKey:@"feed"]; // feeds entry NSArray *feedforentry=[feed objectForKey:@"entry"]; for(NSDictionary *diction in feedforentry) { NSDictionary *title=[diction objectForKey:@"title"]; NSString *label=[title objectForKey:@"label"]; [array addObject:label]; } [[self JustConfesstable]reloadData]; // reload table } 

首先在Dictionary中获取数据,然后使用Keys存储你想要的NSArray ..

 NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingMutableContainers error: &error]; NSLog(@"%@",json); NSLog(@"%@",delegate.firstArray); NSArray * responseArr = json[@"Deviceinfo"]; NSArray * firstarray=[[NSArray alloc]init]; for(NSDictionary * dict in responseArr) { [firstarray addObject:[dict valueForKey:@"name"]]; } 

第一个数组包含名称..你想从那个JSON响应。

然后将该数据传递给tablview。 你想在这里做什么你得到的名字数据的数组。

您需要使用JSONparsing器。 我会推荐: https : //github.com/johnezang/JSONKit

你可以这样做:

 JSONDecoder *jsonKitDecoder = [JSONDecoder decoder]; NSError *error = nil; id objectFromJson = [jsonKitDecoder objectWithData:data error:&error];