我的要求是将JSON数据从服务(A)发送到另一个服务(B),在这种情况下,我正在使用Spring Boot RestTemplate以JSON发送表情符号。如果我从A向B发送请求,则服务B中的消息将显示为带有问号(?)而不是表情符号的文本。
发送此JSON数据
{
"from": "1233222225",
"to": "8585855858",
"message": "Hello A, hope you are doing 23012020 😗"
}
在服务B中显示为
{
"from": "1233222225",
"to": "8585855858",
"message": "Hello A, hope you are doing 23012020 ?"
}
任何人都可以帮助解决此问题吗?
尝试使用此解决方案。它对我有用
发送JSON数据时,请确保标题中的内容类型应为“ application / json; charset = UTF-8”。默认情况下,它将采用“ application / json”。
HttpHeaders headers = new HttpHeaders();
headers.setContentType("application/json;charset=UTF-8");
您需要以以下编码发送表情符号:
String ballEmoji = "\u26BD";
或您可以在下面使用:
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
<version>3.2.0</version>
</dependency>
EmojiParser.parseToUnicode(":smiley: some text");