【问题标题】:Getting Google Spradsheet data in JSON format以 JSON 格式获取 Google 电子表格数据
【发布时间】:2016-01-30 10:05:47
【问题描述】:
我正在尝试以 JSON 格式获取 google 电子表格内容,但 id 似乎无法使用以下方式工作。
我正在使用以下 URL 发送 HTTP 请求。您可以将其复制到 URL 以查看结果。
https://spreadsheets.google.com/feeds/list/1Sp18_fOs8SSP_fwB54lv7IoL42uDaioZM1LTRD4rL8o/od6/public/values?alt=json
【问题讨论】:
标签:
json
http
google-sheets
【解决方案1】:
这很好用:
<!DOCTYPE>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<head>
</head>
<body>
<ul id="nav">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
<div class="results"></div>
<script type="text/javascript">
// ID of the Google Spreadsheet
var spreadsheetID = "1Sp18_fOs8SSP_fwB54lv7IoL42uDaioZM1LTRD4rL8o";
// Make sure it is public or set to Anyone with link can view
var url = "https://spreadsheets.google.com/feeds/list/" + spreadsheetID + "/od6/public/values?alt=json";
$.getJSON(url, function(data) {
var entry = data.feed.entry;
$(entry).each(function(){
for (var prop in this){alert(this[prop]);}
// Column names are name, age, etc.
$('.results').prepend('<h2>'+this.gsx$name.$t+'</h2><p>'+this.gsx$age.$t+'</p>');
});
});
</script>
</body>
</html>