Friday 22 December 2017

http headers - What is the correct JSON content type?

itemprop="text">

I've been messing around with href="http://en.wikipedia.org/wiki/JSON" rel="noreferrer">JSON for some
time, just pushing it out as text and it hasn't hurt anybody (that I know of), but I'd
like to start doing things properly.



I have seen
so many purported "standards" for the JSON content
type:



application/json
application/x-javascript
text/javascript

text/x-javascript
text/x-json


But
which one is correct, or best? I gather that there are security and browser support
issues varying between them.



I know there's a
similar question, href="https://stackoverflow.com/questions/404470/what-mime-type-if-json-is-being-returned-by-a-rest-api">What
MIME type if JSON is being returned by a REST API?
, but I'd like a
slightly more targeted answer.


class="post-text" itemprop="text">
class="normal">Answer



For JSON
text:




application/json





The MIME media type for JSON text is
application/json. The default
encoding is UTF-8. (Source: rel="noreferrer">RFC
4627
).




For
JSONP
(runnable javascript) with
callback:





application/javascript





Here
are some blog posts that were mentioned in the comments that are
relevant.




No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...