ruby json从数组

时间:2017-10-12 16:19:39

标签: arrays json ruby twitter

我有一个这个json,里面有一个数组。 我怎么能得到:
- full_text
- 图片链接:来自mediaextended_entities media_url_https 来自网址实体的网址 - lang

[{
"created_at": "Thu Oct 12 14:42:03 +0000 2017",
"id": 9184869314823331890,
"id_str": "9184869314823331890",
"full_text": "trying some stuff! \nhttps://somewebsite.com/emjc1MLAbD\n\uf6430\nWhat bird is this? What is its name? It has beautiful feathers. Love the mix of green, white. https://somewebsite.com/q3IqrfVcUz",
"truncated": false,
"display_text_range": [0, 139],
"entities": {
    "hashtags": [],
    "symbols": [],
    "user_mentions": [],
    "urls": [{
        "url": "https://somewebsite.com/emjc1MLAbD",
        "expanded_url": "https://www.pexels.com/royalty-free-images/",
        "display_url": "pexels.com/royalty-free-i\u2026",
        "indices": [20, 43]
    }],
    "media": [{
        "id": 918486209067827200,
        "id_str": "918486209067827200",
        "indices": [140, 163],
        "media_url": "http://pbs.twimg.com/media/DL8eVz6VQAA4VHn.jpg",
        "media_url_https": "https://pbs.twimg.com/media/DL8eVz6VQAA4VHn.jpg",
        "url": "https://somewebsite.com/q3IqrfVcUz",
        "display_url": "pic.twitter.com/q3IqrfVcUz",
        "expanded_url": "https://twitter.com/DevAdama/status/918486931482333189/photo/1",
        "type": "photo",
        "sizes": {
            "small": {
                "w": 680,
                "h": 482,
                "resize": "fit"
            },
            "medium": {
                "w": 1200,
                "h": 850,
                "resize": "fit"
            },
            "thumb": {
                "w": 150,
                "h": 150,
                "resize": "crop"
            },
            "large": {
                "w": 1939,
                "h": 1374,
                "resize": "fit"
            }
        }
    }]
},
"extended_entities": {
    "media": [{
        "id": 918486209067827200,
        "id_str": "918486209067827200",
        "indices": [140, 163],
        "media_url": "http://pbs.twimg.com/media/DL8eVz6VQAA4VHn.jpg",
        "media_url_https": "https://pbs.twimg.com/media/DL8eVz6VQAA4VHn.jpg",
        "url": "https://somewebsite.com/q3IqrfVcUz",
        "display_url": "pic.twitter.com/q3IqrfVcUz",
        "expanded_url": "https://twitter.com/DevAdama/status/918486931482333189/photo/1",
        "type": "photo",
        "sizes": {
            "small": {
                "w": 680,
                "h": 482,
                "resize": "fit"
            },
            "medium": {
                "w": 1200,
                "h": 850,
                "resize": "fit"
            },
            "thumb": {
                "w": 150,
                "h": 150,
                "resize": "crop"
            },
            "large": {
                "w": 1939,
                "h": 1374,
                "resize": "fit"
            }
        }
    }]
},
"metadata": {
    "iso_language_code": "en",
    "result_type": "recent"
},
"source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"in_reply_to_screen_name": null,
"user": {
    "id": 915243599930982401,
    "id_str": "915243599930982401",
    "name": "devAdama",
    "screen_name": "DevAdama",
    "location": "",
    "description": "",
    "url": null,
    "entities": {
        "description": {
            "urls": []
        }
    },
    "protected": false,
    "followers_count": 0,
    "friends_count": 0,
    "listed_count": 0,
    "created_at": "Tue Oct 03 15:54:13 +0000 2017",
    "favourites_count": 0,
    "utc_offset": null,
    "time_zone": null,
    "geo_enabled": false,
    "verified": false,
    "statuses_count": 2,
    "lang": "en",
    "contributors_enabled": false,
    "is_translator": false,
    "is_translation_enabled": false,
    "profile_background_color": "000000",
    "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_tile": false,
    "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
    "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
    "profile_link_color": "981CEB",
    "profile_sidebar_border_color": "000000",
    "profile_sidebar_fill_color": "000000",
    "profile_text_color": "000000",
    "profile_use_background_image": false,
    "has_extended_profile": false,
    "default_profile": false,
    "default_profile_image": true,
    "following": false,
    "follow_request_sent": false,
    "notifications": false,
    "translator_type": "none"
},
"geo": null,
"coordinates": null,
"place": null,
"contributors": null,
"is_quote_status": false,
"retweet_count": 0,
"favorite_count": 0,
"favorited": false,
"retweeted": false,
"possibly_sensitive": false,
"lang": "en"
}, {
"created_at": "Wed Oct 04 17:33:29 +0000 2017",
"id": 915630969218064385,
"id_str": "915630969218064385",
"full_text": "hola!",
"truncated": false,
"display_text_range": [0, 5],
"entities": {
    "hashtags": [],
    "symbols": [],
    "user_mentions": [],
    "urls": []
},
"metadata": {
    "iso_language_code": "es",
    "result_type": "recent"
},
"source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"in_reply_to_screen_name": null,
"user": {
    "id": 915243599930982401,
    "id_str": "915243599930982401",
    "name": "devAdama",
    "screen_name": "DevAdama",
    "location": "",
    "description": "",
    "url": null,
    "entities": {
        "description": {
            "urls": []
        }
    },
    "protected": false,
    "followers_count": 0,
    "friends_count": 0,
    "listed_count": 0,
    "created_at": "Tue Oct 03 15:54:13 +0000 2017",
    "favourites_count": 0,
    "utc_offset": null,
    "time_zone": null,
    "geo_enabled": false,
    "verified": false,
    "statuses_count": 2,
    "lang": "en",
    "contributors_enabled": false,
    "is_translator": false,
    "is_translation_enabled": false,
    "profile_background_color": "000000",
    "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_tile": false,
    "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
    "profile_image_url_https": "https://website.com/sticky/default_profile_images/default_profile_normal.png",
    "profile_link_color": "981CEB",
    "profile_sidebar_border_color": "000000",
    "profile_sidebar_fill_color": "000000",
    "profile_text_color": "000000",
    "profile_use_background_image": false,
    "has_extended_profile": false,
    "default_profile": false,
    "default_profile_image": true,
    "following": false,
    "follow_request_sent": false,
    "notifications": false,
    "translator_type": "none"
},
"geo": null,
"coordinates": null,
"place": null,
"contributors": null,
"is_quote_status": false,
"retweet_count": 0,
"favorite_count": 0,
"favorited": false,
"retweeted": false,
"lang": "es"
}]

1 个答案:

答案 0 :(得分:2)

也许不整洁,但您仍然可以尝试执行以下操作:

*ngIf