我正在从Web服务中提取数据,数据格式为JSON.我正在为Google Sheet编写一个Google Apps脚本,它将为我填充数据.我的问题是,我似乎无法把它解析出来.
做:
var dataset = myJSONtext;
Browser.msgbox(dataset.item[0].key);
errors out, saying:
item[0] is not defined.
我应该用什么方法来做这件事?
我正在从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.