从 YQL 生成的 JSON 数组中获取第 n 行
我正在使用 YQL 获取并显示 Google 电子表格中的数据,如下所示:
我想显示多个查询的复合 YQL 查询的结果,并在单独的无序列表中显示结果。
我的复合查询是 这里。 小提琴在这里: http://jsfiddle.net/svh2r/1/
我的问题是,我必须对这条线做什么才能让它占据某一行?
$.each(data.query.results.results.row, function (i, item) {
我以为会这样,
data.query.results.results.row[1]
但那行不通。
I'm using YQL to get and display data from a Google spreadsheet, like this:
I'd like to display results from a composite YQL query of multiple queries, and show the results in separate unordered lists.
My composite query is here.
and a fiddle is here: http://jsfiddle.net/svh2r/1/
My question is, what do I have to do to this line in order to get it to take a certain row?
$.each(data.query.results.results.row, function (i, item) {
I thought it would be
data.query.results.results.row[1]
but that doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
data.query.results.results
是一个数组,其中包含来自单独查询的每个结果集。您可以通过data.query.results.results[n]
单独访问它们,其中n
是0
、1
或2
(对应于您的三个查询)。要循环第二个查询的结果(结果数组中的偏移量
1
),您可以这样做:使用两个
$.each
可能(也可能没有)有用循环遍历所有结果中的所有行。以下是示例代码的改编版本,经过修改以构建三个列表 - http://jsfiddle.net/XfBsj/
data.query.results.results
is an array containing each of the result sets from the separate queries. You can access them individually viadata.query.results.results[n]
wheren
is0
,1
or2
(corresponding with your three queries).To loop over the results from the second query (offset
1
in the results array) you could do:It may (or might not) be useful to use two
$.each
loops to loop over all of the rows from all of the results.Here is an adaptation of your example code, altered to build three lists — http://jsfiddle.net/XfBsj/