【发布时间】:2013-04-19 00:33:13
【问题描述】:
我现在正在拔头发。我似乎无法弄清楚如何使用 Jade 访问以下 json 对象中的“媒体”内容。
{
"summary":"Jose Mourinho names his Real Madrid side to face Borussia Dortmund in the Champions League semi-final 24 hours early.",
"type":"STY",
"lastUpdated":"2013-04-23T16:31:39+00:00",
"firstCreated":"2013-04-23T16:31:39+00:00",
"hasShortForm":true,
"media":{
"images":{
"index":{
"67193384":{
"height":261,
"width":464,
"href":"http://thesun.co.uk/media/images/67193000/jpg/_67193384_67193383.jpg",
"altText":"Jose Mourinho"
}
}
}
},
},
我可以访问摘要、类型、更新等。但我不知道如何访问 media.images.index.67193384 中的图像元数据
for item in results
p #{item.summary}
p #{item.lastUpdated}
p #{item.media[0]} // ???
有人可以帮我弄清楚吗?我从未尝试访问对象内对象内的对象数据。此外,images.index 中的 67193384 对象是唯一的,并且会总是不同 从结果到结果。
谢谢!
【问题讨论】:
-
您在制作 JSON 吗?它看起来不正确。图片不是数组。此外,使用“67193384”作为键也无济于事。
标签: javascript json node.js express pug