With array notation such as the following:
$.each(data.feed.entry, function(i, item)
{
var id = item['id']['$t'];
});
I can retrieve the id field from a Youtube JSON feed as this string:
tag:youtube.com,2008:video:W5XpXU8TBoo
corresponding to this JSON:
entry: [
*
-
{
o
-
id: {
+ $t: "tag:youtube.com,2008:video:W5XpXU8TBoo"
}
When I try to use $.parseJSON to retrieve the video value, it says this is not valid JSON:
$.each(data.feed.entry, function(i, item)
{
var id = item['id']['$t'];
var video = $.parseJSON(item['id']['$t']).video;
});
Is there another way to get the video value (i.e.: W5XpXU8TBoo) from this JSON element?
You can grab the video ID elsewhere in the returned object a bit simpler, like this:
You can test it out here.