2

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?

Community
  • 1
  • 1
Steven R. Loomis
  • 4,370
  • 25
  • 37

1 Answers1

1

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.

Steven R. Loomis
  • 4,370
  • 25
  • 37
  • 1
    It's 2017 and this is still a common bug across a different browsers, usually when viewing JSON responses in the browser. *sad face* – Iain Collins Nov 12 '17 at 22:47