从 Imgur API 中提取数据文件 json 时出现问题
Problem extract data file json from Imgur API
我在从 Imgur API 的 GET 创建的 json 文件中提取数据时遇到问题。
也就是json:
{
"id": "ADgvagy",
"title": "This game is so much fun ",
...
"include_album_ads": false,
"images": [
{
"id": "VLeeDfj",
...
"in_gallery": false,
"link": "https://i.imgur.com/VLeeDfj.mp4",
"mp4_size": 2707912,
"mp4": "https://i.imgur.com/VLeeDfj.mp4",
"gifv": "https://i.imgur.com/VLeeDfj.gifv",
"hls": "https://i.imgur.com/VLeeDfj.m3u8",
"processing": {
"status": "completed"
},
"comment_count": null,
...
"score": null
}
]
},
当我提取 title 数据时我没有问题 this.props.post.title.
我试过:
this.props.post.images.link -> TypeError: undefined is not an object (evaluating 'this.props.post.images.link')
this.props.post.images[0].link -> TypeError: undefined is not an object (evaluating 'this.props.post.images[0]')
感谢您的宝贵时间。
我找到了。正确的做法是 this.props.post["images"][0].link
我在从 Imgur API 的 GET 创建的 json 文件中提取数据时遇到问题。
也就是json:
{
"id": "ADgvagy",
"title": "This game is so much fun ",
...
"include_album_ads": false,
"images": [
{
"id": "VLeeDfj",
...
"in_gallery": false,
"link": "https://i.imgur.com/VLeeDfj.mp4",
"mp4_size": 2707912,
"mp4": "https://i.imgur.com/VLeeDfj.mp4",
"gifv": "https://i.imgur.com/VLeeDfj.gifv",
"hls": "https://i.imgur.com/VLeeDfj.m3u8",
"processing": {
"status": "completed"
},
"comment_count": null,
...
"score": null
}
]
},
当我提取 title 数据时我没有问题 this.props.post.title.
我试过: this.props.post.images.link -> TypeError: undefined is not an object (evaluating 'this.props.post.images.link')
this.props.post.images[0].link -> TypeError: undefined is not an object (evaluating 'this.props.post.images[0]')
感谢您的宝贵时间。
我找到了。正确的做法是 this.props.post["images"][0].link