简体   繁体   中英

Problem extract data file json from Imgur API

I have a problem to extract a data from a json file created from a GET from Imgur API.

That is the 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 } ] },

I have no problem to extract the title data when I do this.props.post.title .

I tried : 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]')

Thanks for your time.

I found it. The correct way is to do this.props.post["images"][0].link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM