Google Docs 电子表格转 JSON [英] Google Docs Spreadsheet to JSON

查看:42
本文介绍了Google Docs 电子表格转 JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过很多关于这方面的文章,但它们似乎已经过时,例如,Google Docs 电子表格网址都没有关键参数.我也读过这个:来自谷歌电子表格的 JSON 数据

然后我读这个来访问数据https://developers.google.com/gdata/samples/spreadsheet_sample

我的电子表格存在于:https://docs.google.com/spreadsheets/d/1SKI68FuVlz7FWHB7KBuVsOlLz6I/编辑#gid=0

我已经尝试使用此代码,我认为我的密钥或语法有问题,请指导修复.

<script src="http://spreadsheets.google.com/feeds/feed/1SKI5773_68HiSve1fsz7fr4gotjFWHB7KBuVsOlLz6I/worksheet/public/basic?alt=json-in-script&callback=importGSS"><<</脚本><script type="text/javascript">函数 importGSS(json) {console.log('完成');}

解决方案

script 标记中的 src 属性是无效链接(您可以自己查看通过 直接查看您的链接在浏览器中).

URL 的 feed/key/worksheet 部分具有正确的 key 但错误的 feedworksheet>.

在 URL 中,将feed"替换为cells"(每个单元格的单独值)或list"(单独的每行的值).

同时,将worksheet"替换为od6"(表示最左边的或默认的工作表 - 请参阅这篇博文 用于访问其他工作表).

如果您直接在浏览器中查看这个新网址,可以看到它返回了一个有意义的值.

您的最终脚本标签可能如下所示:

<script src="https://spreadsheets.google.com/feeds/list/1SKI5773_68HiSve1fsz7fr4gotjFWHB7KBuVsOlLz6I/od6/public/values?alt=json-in-script&callback=importGSS"><<</脚本>

有关详细信息,您可以在 Google Developers 网站上查看示例>

I've seen numerous articles on this but they seem outdated, for instance none of the Google Docs Spreadsheet urls has key parameter. I read this as well: JSON data from google spreadsheet

Then I read this to access data https://developers.google.com/gdata/samples/spreadsheet_sample

My spreadsheet exists at: https://docs.google.com/spreadsheets/d/1SKI5773_68HiSve1fsz7fr4gotjFWHB7KBuVsOlLz6I/edit#gid=0

I've tried using this code, I think I have a problem with the key or syntax, please guide to fix.

<script src="http://spreadsheets.google.com/feeds/feed/1SKI5773_68HiSve1fsz7fr4gotjFWHB7KBuVsOlLz6I/worksheet/public/basic?alt=json-in-script&callback=importGSS"></script>

<script type="text/javascript">

    function importGSS(json) {
        console.log('finished');
    }
</script>

解决方案

The src attribute in your script tag is an invalid link (and you can see this for yourself by viewing your link directly in a browser).

The feed/key/worksheet section of the URL has the right key but the wrong feed and worksheet.

In the URL, replace "feed" with either "cells" (separate value for each cell) or "list" (separate value for each row).

At the same time, replace "worksheet" with "od6" (indicating the leftmost, or default, sheet - see this blog post for accessing other sheets).

If you view this new URL directly in a browser, you can see that it returns a meaningful value.

Your final script tag might look like this:

<script src="https://spreadsheets.google.com/feeds/list/1SKI5773_68HiSve1fsz7fr4gotjFWHB7KBuVsOlLz6I/od6/public/values?alt=json-in-script&callback=importGSS"></script>

For more info, you can see an example on the Google Developers site

这篇关于Google Docs 电子表格转 JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆