Interview Questions and Answers on JSON (JavaScript Object Notation)

Q1.  What is JSON ?

Ans. JSON is "JavaScript Object Notation", primarily used for client-server or server-server communication. Its a much lighter and readable alternative to XML. JSON is language independent and is easily parse-able in all programming languages.

Q2.  What is the role of JSON.stringify ?

Ans. JSON.stringify() turns an object into a JSON text and stores that JSON text in a string. 

So If we stringfy above notation , it will become


Q3.  Which function is used to convert a JSON text into an object ?

Ans. eval

Q4.  Which data types are supported by JSON ?

  • Number
  • String
  • Boolean
  • Array
  • Object
  • null

Q5.  What are the benefits of JSON over XML ?

  • Lighter and faster than XML as on-the-wire data format
  • Object Representation - Information is presented in object notations and hence better understandable. Easy to parse and conversion to objects for information consumption.
  • Support multiple data types - JSON supports string, number, array, boolean whereas XML data are all string.

Q6.  Which markup languages can be used in restful web services ? 

Ans. XML and JSON ( Javascript Object Notation ).