Jquery GetJson - 如何阅读回复?
我总是遇到同样的问题,我很难阅读 json 帖子的回复。
例如
$.getJSON('http://gdata.youtube.com/feeds/api/users/live/subscriptions?alt=json', function(data) {
$.each(data.feed.entry, function(i, item) {
console.log(item.feed.link.i); // did not work
});
});
回复
{"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$yt":"http://gdata.youtube.com/schemas/2007","id":{"$t":"http://gdata.youtube.com/feeds/api/users/live/subscriptions"},"updated":{"$t":"2011-03-04T08:31:20.148Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#subscription"}],"title":{"$t":"Subscriptions of live","type":"text"},"logo":{"$t":"http://www.youtube.com/img/pic_youtubelogo_123x63.gif"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/users/live"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/profil ....
有时我需要一个小时才能得到它 -.- ...
你怎么读这个?有什么好的想法吗?
提前致谢!
彼得
i have always the same problem, it is hard for me to read the reply from a json post.
For example
$.getJSON('http://gdata.youtube.com/feeds/api/users/live/subscriptions?alt=json', function(data) {
$.each(data.feed.entry, function(i, item) {
console.log(item.feed.link.i); // did not work
});
});
The Reply
{"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$yt":"http://gdata.youtube.com/schemas/2007","id":{"$t":"http://gdata.youtube.com/feeds/api/users/live/subscriptions"},"updated":{"$t":"2011-03-04T08:31:20.148Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#subscription"}],"title":{"$t":"Subscriptions of live","type":"text"},"logo":{"$t":"http://www.youtube.com/img/pic_youtubelogo_123x63.gif"},"link":[{"rel":"related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/users/live"},{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/profil ....
Sometimes i need an hour to get it -.- ...
How do you read this? Any nice ideas?
Thanks in advance!
Peter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我在没有
feed
的情况下运行您粘贴到我的 Firebug 控制台中的代码时,我看到了这个对象模型:,
feed
不是item
的子项,这就是您收到错误的原因。试试这个
When I ran the code you pasted in my Firebug console without the
feed
I saw this object model:So as you can see
feed
is not a child ofitem
, and that's why you were getting an error.Try this instead