【发布时间】:2019-01-27 06:03:12
【问题描述】:
我将一个 json 对象/字符串(两者都尝试过)放入 SQS 队列 - 我试图将其作为有效负载发布到 lambda 函数中,当 SQS 中有一个新项目时触发该函数。
我的问题是 json 在另一端出现,在我拥有的每个 "、json 对象或字符串中添加了额外的 \(反斜杠)。
这是我添加到 SQS 的部分 json 作为纯字符串(这是要求)如何在另一端出现的示例:
"{\"properties\":{\"colorIconValue\":\"Other\",\"description\":\"According to media reports on Saturday, 26 January,
虽然文本进入队列时看起来像这样:
{"properties": {"colorIconValue": "Other","description": "International media r
将 json 添加到队列的代码来自 AWS 蓝图:
console.log("plain text" + incident_report);
var params = {
MessageBody: incident_report,
QueueUrl: QUEUE_URL
};
//write to SQS
sqs.sendMessage(params, function(err,data){
if(err) {
console.log('error:',"Fail Send Message" + err);
context.done('error', "ERROR Put SQS"); // ERROR with message
}else{
//console.log('data:',data.MessageId);
context.done(null,''); // SUCCESS
}
});
我尝试将有效负载添加为 JSON 对象和 JSON.stringfy(),但我得到了相同的结果...稍后无法发布(http 帖子)。
【问题讨论】:
标签: javascript node.js json string amazon-sqs