Ich möchte die Zahl "followers_count" eines Twitter-Benutzers zurückgeben. Wenn ich eine get-Anforderung an den api tun das JSON ich zurückgekehrt bin, ist:Abrufen von Werten aus einem JSON-Objekt
EDIT: Es auf die Antwort aus mehreren Teilen ist der Teil Ich möchte wie Daten aus beginnt zu extrahieren:
body:'[{"id":842072275,"id_str":"842072275","name":"BreaK","screen_name":"BreaK_71","location":"England","description":"Full Time Streamer from the UK","url":"http:\\/\\/t.co\\/YZTfi5U7AE","entities":{"url":{"urls":[{"url":"http:\\/\\/t.co\\/YZTfi5U7AE","expanded_url":"http:\\/\\/www.twitch.tv\\/break71","display_url":"twitch.tv\\/break71","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":4159,"friends_count":211,"listed_count":43,"created_at":"Sun Sep 23 17:13:19 +0000 2012","favourites_count":4262,"utc_offset":7200,"time_zone":"Amsterdam","geo_enabled":false,"verified":false,"statuses_count":9763,"lang":"en","status":{"created_at":"Fri Apr 08 17:46:52 +0000 2016","id":718495339188195328,"id_str":"718495339188195328","text":"Hey I\'m live with some @BattleRoyaleMod talking hype about the Tournament tomorrow and messing around. Lets gooo! https:\\/\\/t.co\\/4V9CHaTcIK","entities":{"hashtags":[],"symbols":[],"user_mentions":[{"screen_name":"BattleRoyaleMod","name":"PLAYERUNKNOWN","id":1880574811,"id_str":"1880574811","indices":[23,39]}],"urls":[{"url":"https:\\/\\/t.co\\/4V9CHaTcIK","expanded_url":"http:\\/\\/twitch.tv\\/break71","display_url":"twitch.tv\\/break71","indices":[114,137]}]},"truncated":false,"source":"\\u003ca href=\\"http:\\/\\/twitter.com\\" rel=\\"nofollow\\"\\u003eTwitter Web Client\\u003c\\/a\\u003e","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,"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":3,"favorite_count":5,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"},"contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"1A1B1F","profile_background_image_url":"http:\\/\\/pbs.twimg.com\\/profile_background_images\\/642608935812374528\\/7t7IqgIJ.png","profile_background_image_url_https":"https:\\/\\/pbs.twimg.com\\/profile_background_images\\/642608935812374528\\/7t7IqgIJ.png","profile_background_tile":false,"profile_image_url":"http:\\/\\/pbs.twimg.com\\/profile_images\\/693388490642423808\\/vdfXvyl4_normal.png","profile_image_url_https":"https:\\/\\/pbs.twimg.com\\/profile_images\\/693388490642423808\\/vdfXvyl4_normal.png","profile_banner_url":"https:\\/\\/pbs.twimg.com\\/profile_banners\\/842072275\\/1410269304","profile_link_color":"ED7811","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"F6FFD1","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false}]' }
Wie kann ich Extrahieren Sie nur das Schlüsselwertpaar "followers_count". Da dies der einzige Teil ist, den ich brauche. Ich kann andere nachher wählen, aber das ist der Hauptteil. Ich habe versucht, etwas zu tun, wie:
console.log(response.body['followers_count']);
Aber das funktioniert nicht.
Haben Sie JSon analysiert? Wo ist die Antwort definiert? – Areca
'var params = {Bildschirmname: 'twitter'}; client.get ('Benutzer/Nachschlagen', Parameter, Funktion (Fehler, Tweets, Antwort) { if (Fehler) { console.log (Fehler); } else { console.log ("Hallo"); console.log(); var responseObject = JSON.parse (Antwort); console.log (responseObject). // Raw Response-Objekt } }); ' – Barry