我正在从Web服务中提取数据,数据格式为JSON.我正在为Google Sheet编写一个Google Apps脚本,它将为我填充数据.我的问题是,我似乎无法把它解析出来.

做:

var dataset = myJSONtext;
Browser.msgbox(dataset.item[0].key); 

errors out, saying:

item[0] is not defined.

我应该用什么方法来做这件事?

推荐答案

Apps script is (pretty much) just Javascript; plain-old JSON.parse is your best option for parsing JSON into an object representation.

You can also use JSON.stringify to serialize an object into a string representation.

Json相关问答推荐

JOLT拉平数组

JSON字符串处理注入引号

对面的行/列进行排序时可能出现错误

在Golang中从 struct 手动创建JSON对象

在Vega中如何通过滑块改变条形图的宽度

数据到jsonObject到数据到 struct 是可能的吗?

VBA-JSON 嵌套集合解析为 Excel

通过一个序列化器更新多个模型数据

如何使用 Serde 使用顶级数组反序列化 JSON?

一起使用 Argparse 和 Json

Java的JSON字符串整洁/格式化程序

如何使用 Jackson 重命名 JSON 序列化中的根键

将 CoffeeScript 项目转换为 JavaScript(不缩小)?

alert Json 对象

as_json 没有在关联上调用 as_json

有没有办法在 angular.json 中扩展配置?

JSON 模式 - 如果对象*不*包含特定属性则有效

从 Json 对象 Android 中获取字符串值

如何将 mysqli 结果转换为 JSON?

如何在本地存储中存储对象数组?