使用 reduce 创建的意外输出 json
Unexpected output using reduce to create json
我正在使用应用程序脚本。我有一组对象 'sendableRows',我想将其转为 json 和电子邮件。对象看起来像:
[{Phone Number=14444444444, Eagerness=High, Index=4816.0, completed=, Lot Size=0.74, Power or water=, campaign=, absoluteRow=84.0}]
我的代码:
const json = sendableRows.reduce(row => JSON.stringify(row), "")
Logger.log(json);
MailApp.sendEmail({
to: 'xxxx@gmail.com',
subject: todayString,
htmlBody: json
});
不幸的是 'json' 被输出为:
[20-07-26 20:07:55:244 EDT] "\"\\"\\\\"\\\\"\\"\""
我做错了什么?
尝试
const json = JSON.stringify(sendableRows);
我正在使用应用程序脚本。我有一组对象 'sendableRows',我想将其转为 json 和电子邮件。对象看起来像:
[{Phone Number=14444444444, Eagerness=High, Index=4816.0, completed=, Lot Size=0.74, Power or water=, campaign=, absoluteRow=84.0}]
我的代码:
const json = sendableRows.reduce(row => JSON.stringify(row), "")
Logger.log(json);
MailApp.sendEmail({
to: 'xxxx@gmail.com',
subject: todayString,
htmlBody: json
});
不幸的是 'json' 被输出为:
[20-07-26 20:07:55:244 EDT] "\"\\"\\\\"\\\\"\\"\""
我做错了什么?
尝试
const json = JSON.stringify(sendableRows);