In this article, we look at the correct mime types for JSON and JSONP as defined in the official IANA media types list.
JSON Mime Type
RFC 4627 specifies that the correct mime-type for JSON is:
- If you wish to support IE7 (or below), using
application/jsonmight not work as expected because Internet Explorer will associate
application/jsonto an application installed on the client-side and will show a "Save As" disalog box. In that case, the solution might be to use the mime-type
- As a precaution, you should avoid serving json with the content-type
text/htmlas it can be a potential security risk.
JSONP Mime Type
Variants in the Wild:
Be aware of variants in the wild, which are either obsolete or non-standard and are discouraged for use. Some notable examples are:
Serving media with an incorrect mime-type can potentially lead to unwanted behavior and/or security risks.
Hope you found this post useful. It was published (and was last revised ). Please show your love and support by sharing this post.