为什么内容类型标头用于json? “应用程序/ JSON; charset = utf-8“或”application / json“?

时间:2021-05-21 20:28:02

looks like the json default encoding is UTF-8 Spring mvc returns "application/json; charset=utf-8 " by default and pretty hard to change it.

看起来像json默认编码是UTF-8 Spring mvc默认返回“application / json; charset = utf-8”并且很难改变它。

1 个解决方案

#1


19  

According to RFC 4627

根据RFC 4627

JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.

JSON文本应以Unicode编码。默认编码为UTF-8。

It goes on to describe how the different UTF-* encoding are to be detecting, suggesting that no other encodings are supported.

它继续描述了如何检测不同的UTF- *编码,这表明不支持其他编码。

"SHALL" represents an absolute requirement here (see RFC 2119).

“SHALL”代表了绝对要求(参见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).

并且没有理由使用带有JSON的非UTF编码(因为任何可以处理JSON的东西都可以处理UTF-8)。

#1


19  

According to RFC 4627

根据RFC 4627

JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.

JSON文本应以Unicode编码。默认编码为UTF-8。

It goes on to describe how the different UTF-* encoding are to be detecting, suggesting that no other encodings are supported.

它继续描述了如何检测不同的UTF- *编码,这表明不支持其他编码。

"SHALL" represents an absolute requirement here (see RFC 2119).

“SHALL”代表了绝对要求(参见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).

并且没有理由使用带有JSON的非UTF编码(因为任何可以处理JSON的东西都可以处理UTF-8)。