Reputation: 49
I'm trying to access the following JSON content using JQuery.
http://pipes.yahoo.com/pipes/pipe.run?_id=14756b1d828eae9693f6ef235de879cc&_render=json
I can access the title and description fine by using:
var item_html = '<li><a href="'+item.link+'">'+item.title+'</a></li>'+item.description+'';
but I'm having trouble accessing content:encoded: because of a syntax error when I try:
var item_html = '<li><a href="'+item.link+'">'+item.title+'</a></li>'+item.content:encoded+'';
I'm sure there's a simple solution but I can't get my had around it. I've tried putting quotes in as that makes the most sense to me but haven't been able to get it to work.
Thanks in advance.
Upvotes: 1
Views: 515
Reputation: 8321
you can't use special token like :
directly but you can access your data using ['PropertyName']
so change your code to be like this;
var item_html = '<li><a href="'+item.link+'">'+item.title+'</a></li>'+item['content:encoded']+'';
Here is demo to see how to access your data
Upvotes: 2
Reputation: 318232
You can't use dot notation with special characters, you'll have to use bracket notation for that:
change
item.content:encoded
to
item['content:encoded']
Also note that you can't have textnodes in an UL outside the LI's:
'....</a></li>'+item.content:encoded+'';
Upvotes: 0