【发布时间】:2017-12-24 23:19:57
【问题描述】:
我一直在试图弄清楚如何将 JSON 中的数据从 cryptocompare api 获取到 google 电子表格。这是我的代码:
function gather(symbol, array) {
for (i in array.AggregatedData) {
return array[i];
}
return 0;
}
function chc(symbol, key, rand) {
var url = "https://www.cryptocompare.com/api/data/coinsnapshot/?fsym="+ symbol +"&tsym=USD";
var response = UrlFetchApp.fetch(url);
var text = response.getContentText();
var obj_array = JSON.parse(text);
var obj = gather(obj_array);
var value = obj[key];
return parseFloat(value);
}
我收到一个错误,无法读取未定义的 AggregatedData 属性。
这是数据在 api 上的显示方式 JSON output
【问题讨论】:
标签: json google-sheets-api cryptoapi