将JSON数据导入Google电子表格 [英] Import JSON data into Google Spreadsheet
问题描述
我从Web服务中拉取数据,并将其格式化为JSON。我正在为谷歌电子表格写一个谷歌应用脚本,为我填充数据。我的问题是,我似乎无法解析出它。
I am pulling data down from a webservice and it is formated as JSON. I am writing a google apps script for google spreadsheet that will populate the data for me. my problem is, I can't seem to get it to parse out.
在做:
doing:
var dataset = myJSONtext;
Browser.msgbox(dataset.item[0].key);
出错,表示没有定义项目[0]。
errors out, saying item[0] is not defined.
有没有内置的方法可以让我做到这一点?
Is there some built in way I should be doing this?
任何帮助都是可以理解的。
Any help would be apreciated.
推荐答案
Apps脚本(非常)只是Javascript;古老的 JSON .parse
是将JSON解析为对象表示的最佳选择。
Apps script is (pretty much) just Javascript; plain-old JSON.parse
is your best option for parsing JSON into an object representation.
您也可以使用 JSON.stringify
将对象序列化为字符串表示形式。
You can also use JSON.stringify
to serialize an object into a string representation.
这篇关于将JSON数据导入Google电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!