"text": "Introducing the Twitter Certified Products Program:
"retweet_count": 121,
"in_reply_to_status_id_str": null,
"id": 240859602684612608,
"geo": null,
"retweeted": false,
"possibly_sensitive": false,
"in_reply_to_user_id": null,
"place": null,
"user": {
"profile_sidebar_fill_color": "DDEEF6",
"profile_sidebar_border_color": "C0DEED",
"profile_background_tile": false,
"name": "Twitter API",
"profile_image_url": "http://a0.twimg.com/profile_images/2284...
"created_at": "Wed May 23 06:01:13 +0000 2007",
"location": "San Francisco, CA",
"follow_request_sent": false,
"profile_link_color": "0084B4",
"is_translator": false,
"id_str": "6253282",
"entities": {
"url": {
"urls": [
{
"expanded_url": null,
"url": "",
"indices": [
0,
22
]
}
]
},
"description": {
"urls": [
]
}
},
jQuery的我想一些參數進行排序,但給我[對象對象]與否不確定
success: function(data) {
var result = JSON.parse(data); $.each(result, function (i, val) {
document.write(val.text+" "+val.retweet_count+"
");
});
確保'data'是一個包含數組的字符串。 'console.log'並記錄'typeof'。 – ilyaigpetrov
這就是爲什麼{\「created_at \」:\「Sun Mar 19 22:40:16 +00002017 \」,\「entities \」:{\「hashtags \」:[{\「text \」:\ 「GraciasBravoPueblo \」,\ 「指數\」:[25,44]}],\ 「符號\」:[],\ 「user_mentions \」:[],\ 「網址\」{\ 「URL \」:\ 「HTTPS:\\\/\\\/t.co \\\/Q3xYg8k0vG \」,\ 「expanded_url \」:\「HTTPS:\\\/\\\/www.periscope.tv \\\/W \\\/a52u0DMwODk2N3wxbFBKcVpucGt6UHhiRDU_d9NnWueV1e9n7I7dzqVY2dNH8EG7gJlSLWlsWDA = \」 \ 「DISPLAY_URL \」:\ 「periscope.tv \\\ /瓦特\\\/a52u0DMwODk2 \\ U2026 \」,\ 「指數\」:[45,68]}]} },並且我想要訪問\「entities \」:{\「hashtags \」:[{\「text \」:\「Thanks \」,using $ .each –
確保您調用'$ .each'數組,而不是一個對象。例如:'var result = JSON.parse('{「hashtags」:[{「text」:「FOOBAR」}]}'); result.hashtags.forEach(函數(VAL){執行console.log(VAL);})' – ilyaigpetrov