我卡住了。看起来这应该有效,但事实并非如此。
我正在尝试访问对象的键值,但它不起作用。我以前做过这个,并且在堆栈溢出和其他地方阅读了很多东西,但它仍然不起作用。
这是我的代码:
var validate = UrlFetchApp.fetch(url, options);
Logger.log('validate = ' + validate);
Logger.log("validate['response'] = " + validate["response"]);
Logger.log('validate.response = ' + validate.response);
Logger.log("validate.['done'] = " + validate["done"]);
Logger.log("validate.done = " + validate.done);
var validateObj = JSON.stringify(JSON.parse(validate));
Logger.log("validateObj = " + validateObj);
Logger.log("validateObj.response = " + validateObj.response);
Logger.log("validateObj.done = " + validateObj.done);
这是日志:
validate = {
"done": true,
"response": {
"@type": "type.googleapis.com/google.apps.script.v1.ExecutionResponse",
"result": "Invalid Full Name. Please enter a valid Full Name."
}
}
validate['response'] = undefined
validate.response = undefined
validate.['done'] = undefined
validate.done = undefined
validateObj = {"done":true,"response":{"@type":"type.googleapis.com/google.apps.script.v1.ExecutionResponse","result":"Invalid Full Name. Please enter a valid Full Name."}}
validateObj.response = undefined
validateObj.done = undefined
使用括号表示法时,我也尝试过使用单引号和双引号。
谁能帮我看看错误?
HUX布斯
相关分类