YQL 查询中的 JSON 嵌套对象输出问题
我正在尝试使用此函数通过 yahoo 查询语言从 Foursquare 提取数据。我可以获得结果,但是无法获得嵌套的主要类别对象结果。它给了我[对象对象]。如果我尝试将它用作变量,则函数会因无法识别的对象而失败。我是新手,可能这是一个愚蠢的问题,但我怎样才能得到这个结果......
function fsqpoints(o)
{
var venues = o.query.results.venues.group.venue;
var output = '';
for(var i=0,j=venues.length;i<j;i++) {
var cur = venues[i]
var id = cur.id;
var path = cur.primarycategory;
var address = cur.address;
var name = cur.name;
output += "<h3><a href='http://foursquare.com/venue/" + id + "'>"+name+"</a></h3>" + address + "," + path + "<hr/>"; }
document.getElementById('results').innerHTML = output;
I am trying to use this function to pull data from Foursquare through yahoo query lang. I can get results but, i can't get the nested primarycategory objects results. It gives me [object object]. If i try to use it as a variable, then function fails with a unidentified object. I am a newbie, may be this is a stupid question but how can i get this results too...
function fsqpoints(o)
{
var venues = o.query.results.venues.group.venue;
var output = '';
for(var i=0,j=venues.length;i<j;i++) {
var cur = venues[i]
var id = cur.id;
var path = cur.primarycategory;
var address = cur.address;
var name = cur.name;
output += "<h3><a href='http://foursquare.com/venue/" + id + "'>"+name+"</a></h3>" + address + "," + path + "<hr/>"; }
document.getElementById('results').innerHTML = output;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试 name.text().toString() 而不是仅仅“name”。这同样适用于所有其他节点。
Try name.text().toString() instead of just "name". The same applies to all other nodes.