我想使用jquery解析这个json,每个都有一个循环。我只看过json示例,它包含在数组中,并带有标题,例如结果。我如何解析json如下...?
$.each(json.results, function() { console.log(this['title']); });
[{"title":"About Us","url_title":"about_us","entry_id":"155","channel_id":"2","author_id":"1","status":"open","entry_date":"1287508538","edit_date":"20101209122240","expiration_date":"0","about_body":"We are the greatest.","about_image":"","about_staff_title":"Joe","about_extended":"More about us.","color":"d12626"},{"title":"Contact Us","url_title":"contact_us","entry_id":"223","channel_id":"2","author_id":"1","status":"open","entry_date":"1291918929","edit_date":"20101209122310","expiration_date":"0","about_body":"Email us.","about_image":"","about_staff_title":"Bob","about_extended":"","color":"080480"}]
答案 0 :(得分:3)
$.each(json, function() { console.log(this.title); });
答案 1 :(得分:1)
不应该只是$.each(json, function() ... )
吗?您的JSON是一个数组,没有包装器,因此只需将其直接传递给$.each()
。