问题
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}]
my code:
const json = sendableRows.reduce(row => JSON.stringify(row), "")
Logger.log(json);
MailApp.sendEmail({
to: 'xxxx@gmail.com',
subject: todayString,
htmlBody: json
});
unfortunately 'json' is being output as:
[20-07-26 20:07:55:244 EDT] "\"\\\"\\\\\\\"\\\\\\\"\\\"\""
What am I doing wrong?
回答1:
Try
const json = JSON.stringify(sendableRows);
来源:https://stackoverflow.com/questions/63107142/unexpected-output-using-reduce-to-create-json