Question:
For a while, I've been sending back JSON responses as plain text: plain/text
, however I'd like to finally be able to send the correct Content-Type
header.
Here are some of the suggested "standards" for JSON MIME:
application/json
application/x-javascript
text/javascript
text/x-javascript
text/x-json
However, which one is the correct one, or just the best one regarding security/customer support (browsers, etc.)?
Translation of the question "What is the correct JSON content type?"
Answer:
For JSON
:
According to the
IANA
registration and RFC 4627 :application/json
encoded inUTF-8
.
For JSONP
:
application/javascript
is also inUTF-8
.
When JSON creator Douglas Crawford was asked why not text/json
, he replied that it's not a JS script, but it's not text either, so application/*
rather than text/*
.