It seems that the JSON default encoding is UTF-8 and Spring MVC returns application/json; charset=utf-8
by default, which is hard to change.
JSON has to be correctly interpreted by the browser to be used appropriately. text/plain was typically used for JSON, but according to IANA, the official MIME type for JSON is application/json .
Content-type: application/json; charset=utf-8 designates the content to be in JSON format, encoded in the UTF-8 character encoding. Designating the encoding is somewhat redundant for JSON, since the default (only?) encoding for JSON is UTF-8.
JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.
The MIME media type for JSON text is application/json. The default encoding is UTF-8.
According to RFC 4627
JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.
It goes on to describe how the different UTF-* encoding are to be detecting, suggesting that no other encodings are supported.
"SHALL" represents an absolute requirement here (see RFC 2119).
And there really is no reason to use a non-UTF encoding with JSON (as anything that can handle JSON can definitely handle UTF-8).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With