tags:

views:

15

answers:

1

Hi, how can i get the auhtor name from this getJSON

http://gdata.youtube.com/feeds/api/videos/tPYtsDPXtOY/comments?alt=json-in-script&callback=jsonp1282584741426&max-results=10

$.getJSON('http://gdata.youtube.com/feeds/api/videos/tPYtsDPXtOY/comments?alt=json-in-script&callback=jsonp1282584741426&max-results=10', function(data) {

 $.each(data.feed.entry, function(i, item) {                
    var title = item['content']['$t']; // work
    var author = item['author']['$t']; // dont work         
    $('body').append('['+author+'] <br /> '+title+'<hr/>');
  });

});

Thanks in advance! Peter

A: 

After looking at the response JSON, it seems you can change

var author = item['author']['$t']; // dont work

to

var author = item['author'][0]['name']['$t'];

I'm not sure if you can have more than one author though.

David
It works :) ... Thank you very much!
Peter
Just a note: this would have been a great use of Firebug. You could have written console.log(item) in the loop to get a breakdown of the properties on each item. Then you could have drilled down and found the answer.http://getfirebug.com/ in case you're not using it.
Steve Hansell