Я использовал это в качестве примера, надеюсь, что вы можете применить его к своему сценарию, скажем, что переменная называется bg, следовательно
let bg = [ { uid: 123456789,
person:
{ uid: 1234,
first_name: 'frank',
last_name: 'doe',
contact: [Object] },
house:
{ hid: 5724,
house_name: 'Peterson House',
house_style: 'Modern' },
neighborhood:
{ nid: 379,
neighborhood_name: 'Dexter',
neighborhood_type: 'Old' },
media: {
items: [
{
photo_id: 1234,
photo: {
photo_img_sm: 'https://media.net/photos/123_200x200.jpg',
photo_img_md: 'https://media.net/photos/456_640x640.jpg',
photo_img_lg: 'https://media.net/photos/789_1280x1280.jpg'
}
}
]
}} ]
Вы можете получить доступ к таким фотографиям
bg[0].media["items"][0]["photo"]
или с использованием точечной нотации
bg[0].media["items"][0].photo
, если было несколько элементов, как вы сказали, что у вас есть
let gb = [ { uid: 123456789,
person:
{ uid: 1234,
first_name: 'frank',
last_name: 'doe',
contact: [Object] },
house:
{ hid: 5724,
house_name: 'Peterson House',
house_style: 'Modern' },
neighborhood:
{ nid: 379,
neighborhood_name: 'Dexter',
neighborhood_type: 'Old' },
media: {
items: [
{
photo_id: 1234,
photo: {
photo_img_sm: 'https://media.net/photos/123_200x200.jpg',
photo_img_md: 'https://media.net/photos/456_640x640.jpg',
photo_img_lg: 'https://media.net/photos/789_1280x1280.jpg'
}
}
]
}
} ,{ uid: 123456789,
person:
{ uid: 1234,
first_name: 'frank',
last_name: 'doe',
contact: [Object] },
house:
{ hid: 5724,
house_name: 'Peterson House',
house_style: 'Modern' },
neighborhood:
{ nid: 379,
neighborhood_name: 'Dexter',
neighborhood_type: 'Old' },
media: {
items: [
{
photo_id: 1234,
photo: {
photo_img_sm: 'https://media.net/photos/123_200x200.jpg',
photo_img_md: 'https://media.net/photos/456_640x640.jpg',
photo_img_lg: 'https://media.net/photos/789_1280x1280.jpg'
}
}
]
}
},{ uid: 123456789,
person:
{ uid: 1234,
first_name: 'frank',
last_name: 'doe',
contact: [Object] },
house:
{ hid: 5724,
house_name: 'Peterson House',
house_style: 'Modern' },
neighborhood:
{ nid: 379,
neighborhood_name: 'Dexter',
neighborhood_type: 'Old' },
media: {
items: [
{
photo_id: 1234,
photo: {
photo_img_sm: 'https://media.net/photos/123_200x200.jpg',
photo_img_md: 'https://media.net/photos/456_640x640.jpg',
photo_img_lg: 'https://media.net/photos/789_1280x1280.jpg'
}
}
]
}
},{ uid: 123456789,
person:
{ uid: 1234,
first_name: 'frank',
last_name: 'doe',
contact: [Object] },
house:
{ hid: 5724,
house_name: 'Peterson House',
house_style: 'Modern' },
neighborhood:
{ nid: 379,
neighborhood_name: 'Dexter',
neighborhood_type: 'Old' },
media: {
items: [
{
photo_id: 1234,
photo: {
photo_img_sm: 'https://media.net/photos/123_200x200.jpg',
photo_img_md: 'https://media.net/photos/456_640x640.jpg',
photo_img_lg: 'https://media.net/photos/789_1280x1280.jpg'
}
}
]
}
},{ uid: 123456789,
person:
{ uid: 1234,
first_name: 'frank',
last_name: 'doe',
contact: [Object] },
house:
{ hid: 5724,
house_name: 'Peterson House',
house_style: 'Modern' },
neighborhood:
{ nid: 379,
neighborhood_name: 'Dexter',
neighborhood_type: 'Old' },
media: {
items: [
{
photo_id: 1234,
photo: {
photo_img_sm: 'https://media.net/photos/123_200x200.jpg',
photo_img_md: 'https://media.net/photos/456_640x640.jpg',
photo_img_lg: 'https://media.net/photos/789_1280x1280.jpg'
}
}
]
}
}]
Вы можете перебирать каждый из них и по-прежнему получать доступ к переменной photo, например
gb.forEach(onePhoto =>{ for (d in onePhoto["media"]['items'][0].photo){console.log(onePhoto["media"]['items'][0].photo[d])}})