我與格式化這樣的GeoJSON的數據集工作:使用通配符在Javascript
{
"type": "Feature",
"properties": {
"startcong": "109",
"district": "7",
"statename": "Pennsylvania",
"member": {
"112": {
"21168": {
"party": "Republican",
"name": "Meehan, Pat",
"district": "7"
}
},
"109": {
"15447": {
"party": "Republican",
"name": "Weldon, Curt", "district": "7"}
},
"110": {
"20744": {
"party": "Democrat",
"name": "Sestak, Joe",
"district": "7"
}
},
"111": {
"20744": {
"party": "Democrat",
"name": "Sestak, Joe",
"district": "7"
}
}
},
"endcong":
"112",
"id": "042109112007"
}
}
我和如何訪問這些嵌套對象掙扎。例如,我可以使用feature.properties.member[112][21168]
來訪問party
屬性。但是:
- 第二個編號對象(「21168」)並不總是一致編號。
- 第二個編號的對象始終是唯一的嵌套對象。
有沒有辦法像使用通配符那樣訪問同一個party
屬性?理想情況下,類似於feature.properties.member[112][*].party
。