2
votes

So I see the A: What is the correct JSON content type? - application/json as well as Why content type header to use for json? "application/json; charset=utf-8 " or "application/json"? and What does "Content-type: application/json; charset=utf-8" really mean?

As noted there, RFC 7159 says that the default encoding for JSON is utf-8 and notes that:

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

However, in reality, some browsers at least (Safari and Firefox) seem to apply "auto-detect" to the JSON data unless a charset parameter is added (see this ticket filed against me and also the related SO question linked above). I haven't tested XMLHTTPRequest implementations so I can't say either way. I assume they handle application/json properly.

So I think my question is slightly different - for display in the browser, is the charset required because these browsers' built-in JSON display is not actually RFC compliant?

1

1 Answers

1
votes

There is a Firefox bug on this: "Don't honor charset when viewing JSON" #741776 says that XHR ignores charset and that docview shold also.