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

前端 未结 2 723
忘了有多久
忘了有多久 2020-12-14 19:23

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.

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 20:08

    Returning a charset parameter on application/json is incorrect, as that media type does not define a charset parametert. See https://greenbytes.de/tech/webdav/rfc8259.html#rfc.section.11, last sentence:

    Note: No "charset" parameter is defined for this registration. Adding one really has no effect on compliant recipients.

提交回复
热议问题