What is the correct contentType for JSON?


I see that you can use several but I do not understand their differences or when I should use one or the other, for example:

asked by Gemasoft 26.01.2016 в 18:04

3 answers


According to section 11 of the RFC7159: The JavaScript Object Notation (JSON) Data Interchange Format is correct is application/json :

11.  IANA Considerations

   The MIME media type for JSON text is application/json.

   Type name:  application

   Subtype name:  json

In the case of the others the uses are the following:

  • text/javascript It's obsolete, do not use it
  • text/x-javascript It was an experimental content-type, neither should it be used.
  • text/x-json Also experimental. Do not use it
  • % Experimental% co like the others with prefix application/x-javascript . Do not use it

It is also worth mentioning that an alternative that is not mentioned is x- . This content-type must be used for JavaScript not to be confused with JSON .

answered by 26.01.2016 / 18:06

As far as I know, if you are going to transmit JSON through an HTTP service, you should use the content type application/json and it is supported by the official standard internet protocol RFC 4627

answered by 26.01.2016 в 18:09

For JSON pure% you should use application/json and for the case of JSONP you should use application/javascript

answered by 26.01.2016 в 18:07