【发布时间】:2015-07-24 10:36:57
【问题描述】:
我尝试在 Google App Script 中连接两个 JSON 对象,但它总是给我以下错误:
TypeError: Funktion concat in Objekt [object Object] nicht gefunden (Zeile 53, Datei "")
这个问题有什么解决方案?我猜 concat() 函数不是 Google App Script API 的一部分。
我正在尝试做的事情: 从各种电子邮件中读取 Schema.org JSON,并尝试将这些数据保存在 .json 文件中。
代码:
function extractFromGmail(subject,jsonName) {
subject = "json";
jsonName = "testjson";
var rawData = "";
var threads = GmailApp.search('subject:' + subject);
Logger.log("thread length: " + threads.length);
var json;
for(var i = 0; i < threads.length; i++) {
var messages = threads[i].getMessages();
var message = messages[0];
rawData += message.getRawContent();
// Logger.log("rawData from e-mail: " + rawData);
if(rawData.search('itemscope') > -1) {
if(json === null) json = this.extractMicrodata(rawData, jsonName);
else json.concat(this.extractMicrodata(rawData, jsonName));
}
if(rawData.search("json") > -1) {
if(json === undefined) {
Logger.log("undef");
json = this.extractJSON(rawData, jsonName);
}
else {
json = JSON.stringify(json);
Logger.log(typeof json);
json = JSON.parse(json);
Logger.log(typeof json); //this part is to test that it's a json-obj
var result = this.extractJSON(rawData, jsonName)
json = json.concat(result);
}
}
Logger.log(JSON.stringify(json));
}
【问题讨论】:
-
调试它。记录 json 内容
标签: javascript json google-apps-script