Spring escapes Emoji's on json-marshalling #29819
Labels
for: external-project
Needs a fix in external project
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: invalid
An issue that we don't feel is valid
Affects: Spring 6.0.3
Emojis are converted to Unicode escape sequences
When returning objects out of
@RestController
, all UTF-8 characters from the object's fields are interpreted correctly, but emojis are devoured from "👾" to "\uD83D\uDC7E".Minimal Reproducible Example
curl -G https://start.spring.io/starter.zip -d dependencies=web -d javaVersion=11 -d type=maven-project -o demo.zip
.\src\main\java\com\example\demo\rest\MainRest.java
:curl "http://localhost:8080/greeting0"
curl "http://localhost:8080/greeting1"
Expected output:
Actual output:
This is Spring Boot, but same behaviour can be reproduced in bare Spring MVC with this setting:
and with
produces="text/plain;charset=UTF-8"
in@GetMapping("/greeting1")
.Jackson-databind works fine not only in the example above (when called directly), but in standalone application with no other dependencies as well. So I assume it's something with Spring MVC, not with Jackson or Boot.
The text was updated successfully, but these errors were encountered: