如何獲取此JSON。它具有動態值。下面是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"]];
}
}
我想問爲什麼它從底部取數據意味着它首先顯示level3最後一行,然後是level2以及更遠。 –
這裏的數據排序不會保留,它會以隨機訪問的方式訪問數據,而不是順序的方式,這就是爲什麼。 –
我們可以處理它,有沒有辦法呢。 –