【发布时间】:2019-02-16 20:15:56
【问题描述】:
我们使用名为 gsjson 的便捷 JSON 模块将 Google 表格数据转换为 JSON。我需要以 TXT 格式获取作为 URL 列表列出的工作表。
我尝试更改扩展名,但它只是输出为 JSON 格式。如何将其转换为纯文本列表(不包括标题),逐行列出 URL?
// Create JSON file from Google Sheet and place in tmp
gsjson({
spreadsheetId: sheetid ,
credentials: 'mycreds.json'
})
.then(function(result) {
result = JSON.stringify(result);
fs.writeFile("/tmp/" + company +".json", result, 'utf-8', function (err) {
if (err) console.log('Google Sheet written to tmp JSON - FAILED'); // an error occurred
else console.log('Google Sheet written to tmp JSON - SUCCESS'); // successful response
});
当前 JSON 输出
[{"url":"https://example.com"},{"url":"https://examples.com"}]
所需的 TXT 输出
https://example.com
https://examples.com
【问题讨论】:
标签: javascript html json node.js aws-lambda