首页 > 解决方案 > Google Scripts JSON 问题 - 总新手老师试图帮助学生

问题描述

抱歉 - 我不知道 JSON 是如何工作的。我是一名教师,正在尝试在我的 Google 幻灯片中添加翻译工具,以帮助母语不是英语的学生。

我使用了这个:https ://developers.google.com/gsuite/add-ons/editors/slides/quickstart/translate - 我认为没关系,因为它来自 G Suite 开发者插件作为示例编辑器插件之一.

然后我在保存脚本时遇到了一个问题,并试图从这里解决它:https ://developers.google.com/apps-script/concepts/scopes 。

当我进入属性下的范围时,它给了我这些:

脚本所需的 2 个 OAuth 范围:

https://www.googleapis.com/auth/presentations.currentonly https://www.googleapis.com/auth/script.container.ui

所以我进入了appsscript.json,它已经在那里了:

{
  "timeZone": "Australia/Sydney",
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8"
}

然后我将其添加到底部:

{
  ...
  "oauthScopes": [
    "https://www.googleapis.com/auth/presentations.currentonly",
    "https://www.googleapis.com/auth/script.container.ui"
  ],
  ...
}

但是当我保存它时,我得到了这个:

Unexpected character ('.' (code 46)): was expecting double-quote to start field name at [Source: (String)"{ "timeZone": "Australia/Sydney", "dependencies": { }, "exceptionLogging": "STACKDRIVER", "runtimeVersion": "V8" } { ... "oauthScopes": [ "https://www.googleapis.com/auth/presentations.currentonly", "https://www.googleapis.com/auth/script.container.ui" ], ... } "; line: 10, column: 4]

我试过谷歌搜索并使用 JSON Validator,但除了代码明显存在问题之外,我没有任何线索。

如果您能提供帮助,我将非常感谢您帮助我的学生。

干杯

乔恩

标签: jsongoogle-apps-scriptgoogle-oauthgoogle-slides

解决方案


我认为您的问题是由于您在 JSON 对象中拥有嵌套数组的方式。

查看有关 JSON 的此链接,您还将看到有关数组的部分。

https://www.w3schools.com/js/js_json_objects.asp


推荐阅读