谷歌电子表格导出为json文件,如何格式化

google spreadsheet export into json file, how to format?

本文关键字:格式化 文件 json 电子表格 谷歌      更新时间:2023-09-26

我正在学习教程,这些教程可以帮助将我的谷歌电子表格提取到json文件中http://blog.pamelafox.org/2013/06/exporting-google-spreadsheet-as-json.html。但我在谷歌的一些电子表格单元格中有一个对象列表。我的一个电子表格是这样的:屏幕截图http://www.tianyuwu.com/wp-content/uploads/2014/09/Screen-Shot-2014-09-22-at-11.46.00-PM.png.

我的专长是制作这样的json文件。

{
        "features": "*articles'n*archive'n*video'n*search'n*social",
        "data": "*news feeds'n*oroeco team",
        "content": "* blog posts'n* analysis'n* screen shots",
    }

但我期待的是像这个

  {
            "features": "articles","archive","video", "search", "social",
            "data": "news feeds","oroeco team",
            "content": "* blog posts","analysis", "screen shots",
        }

转换最有效的方法是什么?

如果您正在使用JavaScript,请尝试以下操作:

json_original = {
    "features" : "*articles'n*archive'n*video'n*search'n*social",
    "data" : "*news feeds'n*oroeco team",
    "content" : "* blog posts'n* analysis'n* screen shots",
}
json_formated = {}
for (var p in json_original) {
    json_formated[p] = json_original[p].replace(''n', '').split('*').map(function(x) { return x.trim(); }).filter(function(x) {return x != ''; });
}