-1
說我有這個隨機JSON文件:獲得一個變量從一個JSON裏面相關的數據裏面
{
"categoryName": "Appetizers & Sides",
"categories": [
{
"categoryID": "294",
"parentID": "304",
"subjectID": "7",
"categoryName": "Apps and Side Dishes (Laura)",
"categoryDescription": "Learn to make amazing appetizers and side dishes with Laura in the Kitchen.",
"videosCount": "101",
"forumCategoryID": "163"
},
{
"categoryID": "285",
"parentID": "304",
"subjectID": "7",
"categoryName": "Side Dishes",
"categoryDescription": "Side dish recipes for salads, vegetables, sauces with Hilah cooking.",
"videosCount": "38",
"forumCategoryID": "163"
}
]
}
我怎樣才能獲得的類別名稱,如果我有的categoryID?
大加讚賞,
托馬斯
非常感謝你! – ThomasG
如果我可能會問,[0]的功能是什麼? – ThomasG
filter將返回一個數組,並且由於您知道parentId是唯一的,所以它將始終返回一個具有單個元素的數組。這就是我使用[0]的原因。 –