What is the correct MIME type?

Posted on

Question :

In order to allow data to be exchanged between the server and the browser, a number of means are usually adopted, for example when returning an existing dataset in the database using JSON .

There are these here:

  • application / json
  • application / x-javascript
  • text / javascript
  • text / x-javascript
  • text / x-json

It turns out that I do not use any of them to work with data output of type JSON , usually using text/plain , which is for simple type returns.

What is the correct MIME Type for JSON ?


Answer :

In general all of these will work, but the most semantic is application/json as RFC . Using the correct one, it makes it easier for all consumers to work properly – assuming that it is following the RFC.

There are situations where it can present problems, so do not discard the others. Each has a problem with some browser or some other application:)


Leave a Reply

Your email address will not be published. Required fields are marked *