【发布时间】:2018-07-21 08:25:46
【问题描述】:
如果我使用以下方法从 Twitter API 解析推文:
tweet.entities.media
我得到下面的 json。但是我将如何访问 media_url 属性?它嵌套在 json 对象内一个非常困难的地方。
tweet.entities.media[0].media_url
返回错误。
{
"image": [
{
"id": 511403875438301200,
"id_str": "511403875438301185",
"indices": [
44,
66
],
"media_url": "http://some_url.jpg",
"media_url_https" : "https: //some_url.jpg",
"url": "http://whatever.com",
"display_url": "pic.twitter.com/BNIPh3ZlRD",
"expanded_url": "https://twitter.com/some_url/1",
"type": "photo",
"sizes": {
"thumb": {
"w": 150,
"h": 150,
"resize": "crop"
},
"small": {
"w": 680,
"h": 482,
"resize": "fit"
},
"large": {
"w": 2048,
"h": 1453,
"resize": "fit"
},
"medium": {
"w": 1200,
"h": 851,
"resize": "fit"
}
}
}
]
}
【问题讨论】:
标签: javascript json twitter nodes