4
我正在創建logMessage的對象。將javascript對象轉換爲json對象
logMessage = function (msg, severity, vendorId, userName, actionPerformed, priority, traceId, dataSent) {
this.message = msg;
this.severity = severity;
this.vendorId = vendorId;
this.userName = userName;
this.actionPerformed = actionPerformed;
this.priority = priority;
this.traceId = traceId;
this.dataSent = dataSent;
};
var msg = new logMessage(err, "High", "none", qry.username, "Error on login call: /req/login", "high", "", qry);
Utility.writeToLoggly(msg);
err ,qry
是json對象;如何將msg對象轉換爲json對象? 我正在發送msg
對象到loggly
進行日誌管理。如果我能將正確格式的json對象發送到loggly
,那將是非常好的。
'JSON.stringify(MSG)' – Isaac 2014-11-05 21:58:12
注:按照慣例JS 「類」 開始一個大寫字母。 – Alnitak 2014-11-05 21:58:49
p.s.谷歌搜索「JavaScript的JSON輸出」平凡生產幾個頁面的正確答案。 – Alnitak 2014-11-05 22:04:33