简体   繁体   English

谷歌表格连接到 Json

[英]Google Sheets Concatenation to Json

I'm concatenating a set of data into single cells, making it look like a json.我将一组数据连接到单个单元格中,使其看起来像 json。 I want to actually turn that into a json file.我想把它变成一个 json 文件。 In this link I've prepared a sample data set (note that there are two sheets, one with the data and one with the concatenations). 在此链接中,我准备了一个示例数据集(请注意,有两张表,一张带有数据,一张带有连接)。

Basically, I have this three cells and I want to turn each of them into a different json file.基本上,我有这三个单元格,我想将它们中的每一个转换为不同的 json 文件。 在此处输入图像描述

I've tried some add-ons such as ExportSheetData , but I didn't manage to make the file look like what I wanted it to look.我已经尝试了一些附加组件,例如ExportSheetData ,但我没有设法使文件看起来像我想要的那样。

What would be the best way to make this json exportation from google sheets?从谷歌表格中导出 json 的最佳方法是什么? Could I make that using a script or I would need to make it manually (copy into a txt file and throw in a txt-to-json converter in the web)?我可以使用脚本来实现,还是需要手动实现(复制到 txt 文件中并在网络中放入 txt-to-json 转换器)?

function onOpen() {
  const ui = SpreadsheetApp.getUi();
  
  ui.createMenu('foo')
  .addItem('export cell', 'exportJson')
  .addToUi();
}  

function exportJson() {
  const filename = Browser.inputBox('enter filename');
  if (!filename) return;
  
  const jsonStr = SpreadsheetApp.getActiveSpreadsheet().getActiveCell().getDisplayValue();
  DriveApp.createFile(filename, jsonStr);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM