使用reduce创建json的意外输出 [英] Unexpected output using reduce to create json
本文介绍了使用reduce创建json的意外输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理应用程序脚本.我有一组对象sendableRows",我想将它们转换为 json 和电子邮件.一个对象看起来像:
I'm working with apps script. I have an array of objects 'sendableRows' that I would like to turn to json and email. an object looks like:
[{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'被输出为:
unfortunately 'json' is being output as:
[20-07-26 20:07:55:244 EDT] "\"\\\"\\\\\\\"\\\\\\\"\\\"\""
我做错了什么?
推荐答案
尝试
const json = JSON.stringify(sendableRows);
这篇关于使用reduce创建json的意外输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文