将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(JSON.stringify(msg));
你可以使用JSON.stringify()函数,所以只需添加到你的代码中:
Utility.writeToLoggly(JSON.stringify(msg));
链接地址: http://www.djcxy.com/p/8089.html