JSON使用哪种内容类型标头? " application/json; charset = utf-8"或"application/json"? [英] What content type header to use for JSON? "application/json; charset=utf-8 " or "application/json"?

查看:495
本文介绍了JSON使用哪种内容类型标头? " application/json; charset = utf-8"或"application/json"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎JSON默认编码为UTF-8,Spring MVC默认返回application/json; charset=utf-8,这很难更改.

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.

推荐答案

根据 RFC 4627

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

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

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

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

此处的"SHALL"表示绝对要求(请参见 RFC 2119 ).

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

确实没有理由将非UTF编码与JSON一起使用(因为任何可以处理JSON的东西都可以绝对处理UTF-8).

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使用哪种内容类型标头? " application/json; charset = utf-8"或"application/json"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆