简体   繁体   中英

Why content type header to use for json? “application/json; charset=utf-8 ” or “application/json”?

看起来像json默认编码是UTF-8 Spring mvc默认返回“application / json; charset = 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM