如何获取此 json。它具有动态值。下面是json。
{
Level1:
{
row1:
{
1: "on",
2: "on",
3: "on",
4: "on",
5: "on",
6: "on",
7: "on",
8: "on",
9: "on",
10: "on",
attr: {
total: "10",
type: "gold"
}
},
row2: {
1: "on",
2: "on",
3: "on",
4: "on",
5: "on",
6: "on",
7: "on",
8: "on",
9: "on",
10: "on",
attr: {
total: "10",
type: "gold"
}
}
},
Level3: {
row1: {
1: "on",
2: "on",
3: "on",
4: "on",
5: "on",
6: "on",
7: "on",
8: "on",
9: "on",
10: "on",
attr: {
total: "10",
type: "silver"
}
}
}
}
在这个数量级中,行数是动态的,里面的座位也是动态的,如何解决这个问题我不明白。请指导以上,我已经花了一天的时间。下面是我尝试过的代码。
arrLevels = [self.mGetDataDict allKeys]; // getting all levels here in array
NSLog(@"keys:%@", arrLevels);
for(int i=0; i<[arrLevels count]; i++) // trying to get rows in array
{
receiveDataDict = [self.mGetDataDict valueForKey:[arrLevels objectAtIndex:i]];
[arrRows addObject:[NSString stringWithFormat:@"%d", [receiveDataDict count]]];
NSLog(@"data:%@", receiveDataDict);
for(int j=0; j<[receiveDataDict count]; j++)
{
NSLog(@"count:%d", [receiveDataDict count]);
dictRow = [receiveDataDict valueForKey:@"attr"];
[arrTot addObject:[dictRow valueForKey:@"total"]];
[arrType addObject:[dictRow valueForKey:@"type"]];
}
}