我有一個帶有兩個數組的json文件,其中一個嵌套。我需要從嵌套數組中獲取數字,並將它們與未佔用數組中的值(id)進行匹配,以便我可以將未使用數組中的匹配值發送到另一個函數。我一直試圖找出連續兩天的情況,並沒有能夠弄清楚我做錯了什麼。任何指針或幫助將不勝感激。從嵌套數組中獲取特定值
我有數據給我的json在這裏作爲參考。
{
"videos": [
{
"id": 1,
"title": "Lego!",
"created": 1509804047011,
"duration": 5,
"poster": "./videos/small.png",
"video": "./videos/small.mp4"
},
{
"id": 2,
"title": "Big Bunny",
"created": 1507804047011,
"duration": 62,
"poster": "./videos/bunny.png",
"video": "./videos/bunny.mp4"
},
{
"id": 3,
"title": "Prufu myndband",
"created": 1505904047011,
"duration": 3600,
"poster": "./videos/16-9.png",
"video": "./videos/bunny.mp4"
},
{
"id": 4,
"title": "Prufu myndband með löngum texta sem fer í tvær línur",
"created": 1504904047011,
"duration": 220,
"poster": "./videos/16-9.png",
"video": "./videos/bunny.mp4"
}
],
"categories": [
{
"title": "New videos",
"videos": [1, 2]
},
{
"title": "Amazing videos",
"videos": [1, 3, 4]
},
{
"title": "Funny videos",
"videos": [2, 3, 4]
}
]
}
感謝哥們,會看到它是如何變成:) –