日期:2014-05-16 浏览次数:20347 次
var json = {"id95":{"fav":"2","aid":"95","feed":[{"username":"test","msg":"sdfasdf","aid":"95"},{"username":"\u5929\u6daf","msg":"\u55ef,\u8fd9\u4e9b\u56fe\u7247\u90fd\u5f88\u4e0d\u9519!","aid":"95"},{"username":"admin","msg":"dsfsadfsdf","aid":"95"}]},"id89":{"fav":"1","aid":"89","feed":null}}; $.each(json.id95.feed, function(i,item) { alert(item.username); });
------解决方案--------------------
var articles = '{"id95":{"fav":"2","aid":"95","feed":[{"username":"test","msg":"sdfasdf","aid":"95"},{"username":"\u5929\u6daf","msg":"\u55ef,\u8fd9\u4e9b\u56fe\u7247\u90fd\u5f88\u4e0d\u9519!","aid":"95"},{"username":"admin","msg":"dsfsadfsdf","aid":"95"}]},"id89":{"fav":"1","aid":"89","feed":null}}'; articles = eval('('+ articles +')'); $.each(articles, function(key, value) { alert('id' + ':' + key + '\n' + 'fav' + ':' + value.fav + '\naid:' + value.aid); });