これはばかげているが、javascriptとjsonの学習を始めたばかりで、twitter APIからJSONオブジェクトにアクセスしたいと思っています。URLからJSONのオブジェクトへのアクセスに問題がある
var myjson;
$.getJSON('url of the Object', function(data) {
myjson = json;
});
しかし、myjsonを開いた後、私は$ .getJSONを使用する場合、オブジェクトが存在していた知っている50個のアレイimage of said myjson
が含まれているオブジェクトを見つけることができません、だから私は何が間違っていたのだろうかと疑問に思っています。
誰かが正しい方向に私を指し示すことができたら、私は本当に感謝します。グーグルで何も起きなかったからです。あなたのコードで
も、私が使用しHERESにTwitterのAPI、
{"statuses":[{"created_at":"Sun Jul 03 13:03:21 +0000 2016","id":749589344554459137,"id_str":"749589344554459137","text":"RT @Pontifex: Loving and forgiving as God loves and forgives. This is a programme of life that can know no interruptions or exceptions.","truncated":false,"entities":{"hashtags":[],"symbols":[],"user_mentions":[{"screen_name":"Pontifex","name":"Pope
Francis","id":500704345,"id_str":"500704345","indices":[3,12]}],"urls":[]},"metadata":{"iso_language_code":"en","result_type":"recent"},"source":"<a href=\ "http:\/\/twitter.com\/download\/android\" rel=\ "nofollow\">Twitter for Android<\/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":2656789554,"id_str":"2656789554","name":"Augustine Neto T","screen_name":"NetoTumwebaze","location":"At The Heart Of Africa","description":"Human Resources Officer - MTN Rwanda","url":"http:\/\/t.co\/zzdpXkfiue","entities":{"url":{"urls":[{"url":"http:\/\/t.co\/zzdpXkfiue","expanded_url":"http:\/\/www.mtn.co.rw","display_url":"mtn.co.rw","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":153,"friends_count":148,"listed_count":13,"created_at":"Fri Jul 18 14:03:38 +0000 2014","favourites_count":15,"utc_offset":10800,"time_zone":"Kyiv","geo_enabled":false,"verified":false,"statuses_count":3843,"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:\/\/pbs.twimg.com\/profile_images\/729685855565185024\/KcmSmNA6_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/729685855565185024\/KcmSmNA6_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/2656789554\/1418826532","profile_link_color":"89C9FA","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":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweeted_status":{"created_at":"Sun Jul 03 12:00:08 +0000 2016","id":749573436637261824,"id_str":"749573436637261824","text":"Loving and forgiving as God loves and forgives. This is a programme of life that can know no interruptions or exceptions.","truncated":false,"entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[]},"metadata":{"iso_language_code":"en","result_type":"recent"},"source":"<a href=\"https:\/\/about.twitter.com\/products\/tweetdeck\" rel=\"nofollow\">TweetDeck<\/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":500704345,"id_str":"500704345","name":"Pope Francis","screen_name":"Pontifex","location":"Vatican City","description":"Welcome to the official Twitter page of His Holiness Pope Francis","url":"http:\/\/t.co\/MlfhXffVrl","entities":{"url":{"urls":[{"url":"http:\/\/t.co\/MlfhXffVrl","expanded_url":"http:\/\/www.news.va","display_url":"news.va","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":9506393,"friends_count":8,"listed_count":24637,"created_at":"Thu Feb 23 11:38:07 +0000 2012","favourites_count":0,"utc_offset":7200,"time_zone":"Rome","geo_enabled":false,"verified":true,"statuses_count":879,"lang":"it","contributors_enabled":false,"is_translator":false,"is_translation_enabled":true,"profile_background_color":"FFFFFF","profile_background_image_url":"http:\/\/pbs.twimg.com\/profile_background_images\/857999332\/52f4b5a0278e5a44ed595ef3a031a709.jpeg","profile_background_image_url_https":"https:\/\/pbs.twimg.com\/profile_background_images\/857999332\/52f4b5a0278e5a44ed595ef3a031a709.jpeg","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/507818066814590976\/KNG-IkT9_normal.jpeg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/507818066814590976\/KNG-IkT9_normal.jpeg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/500704345\/1409908226","profile_link_color":"0084B4","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":2679,"favorite_count":5015,"favorited":false,"retweeted":false,"lang":"en"},"is_quote_status":false,"retweet_count":2679,"favorite_count":0,"favorited":false,"retweeted":false,"lang":"en"}],"search_metadata":{"completed_in":0.032,"max_id":749589344554459137,"max_id_str":"749589344554459137","query":"life","refresh_url":"?since_id=749589344554459137&q=life&include_entities=1","count":2,"since_id":0,"since_id_str":"0"}}
私はなぜそれがだ、$ .getJSONが非同期であることを知っていますvar x = $ .getJson ...しかし、myjsonがまだ変更されていない場合はどうすれば、URLからオブジェクトにアクセスできますか? –
myjsonのコンテンツをどのように、どこで確認していますか? このjsonで何をしたいかは、この関数で行う必要があります(またはこの関数から別の関数を呼び出す) – eclideria
ところでjsonはコードサンプルにはありません – eclideria