AWS SNS 如何在消息中添加换行符 [英] AWS SNS how to add line breaks in message

查看:48
本文介绍了AWS SNS 如何在消息中添加换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 CLI 以 json 格式发送 SNS 消息.

I'm trying to send SNS messages via CLI in json format.

aws sns publish --cli-input-json "{"TopicArn":"xxx","Message":"first line
 second line","Subject":"Empty subject"}"

但是 不起作用." " 或 " " 都不是.我认为该字符串已被 SNS 转义,因此 不起作用.有谁知道如何发送2行消息?(发送2条消息不是一种选择)感谢您的建议!

But the doesn't work. Neither is " " or " ". I think the string is escaped by SNS so doesn't work. Does anyone know how to send a message of 2 lines?(Sending 2 messages is not an option) Appreciate your advice!

推荐答案

我认为 \n 实际上是您要寻找的.我刚刚通过 AWS SNS 向我的设备发送推送通知来测试它.

I think \n is actually what you are looking for. I've just tested it by sending push notifications to my device through AWS SNS.

所以你的消息应该是这样的:

So your message should look like this:

aws sns publish --cli-input-json "{"TopicArn":"xxx","Message":"first line\nsecond line","Subject":"Empty subject"}"

注意,换行符后不要留空格,否则新行会以该空格开头.

Note, you should not leave the white space after the line break symbol, otherwise, your new line would start with that space.

这篇关于AWS SNS 如何在消息中添加换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆