Friday, 20 March 2015

What is the Correct content-type of JSON and JSONP?

What is the Correct content-type of JSON and JSONP?


Question: What is the Correct content-type of JSON?
  • application/json
  • application/javascript
  • application/x-javascript
  • text/javascript
  • text/x-javascript
  • text/x-json

Answer:
application/json

JSON is a domain-specific language (DSL) and a data format is independent of JavaScript it have its own MIME type i.e. application/json.

Example of JSON:
{ "Name": "Web Technology", "Website": "http://www.web-technology-experts-notes.in" }

Content-Type: application/json




Question: What is the Correct  content-type of JSONP?
  • application/json
  • application/x-javascript
  • application/javascript
  • text/javascript
  • text/x-javascript
  • text/x-json
Answer:
application/javascript

JSONP is JSON with padding. Response is JSON data but with a function call wrapped around it.

Example of JSONP:
functioncallExample({ "Name": "Web Technology", "Website": "http://www.web-technology-experts-notes.in" });

Content-Type: application/javascript