JSON Interview Questions & Answers

Now, a days majority of APIs use JSON as a format of data exchange. It has become necessary for an interviewee to prepare for JSON interview questions. Practice the below interview questions to ace your interview easily. If you want to learn more about JSON, then visit JSON Tutorial

1) What is the full form of JSON?

JSON stands for JavaScript Object Notation.

2) What is the definition of JSON?

It is a text-based format and designed for the exchange of data between two different systems. It is lightweight data-interchange format as compare to XML. It uses JavaScript syntax. JSON data can be read and use by any programming language.

3) What is JSON used for?

JSON is used for communication between server side technologies and mobile app or website.

4) What is the file extension of JSON?

The file extension of JSON is .json.

5) What is the rule for writing JSON?

  • JSON is the collection of key and value pair separated by the comma.
  • Key and value are separated by the colon (:).
  • Square brackets are used to store JSON array.
  • Curly brackets are used to hold JSON objects.

6) How many data types are there in JSON?

There are six types of data types in JSON -

  • Number
  • String
  • Boolean
  • Array
  • Object
  • Null

7) JSON vs. XML?

  • XML requires XML parser to parse it. JSON is parsed with the help of JavaScript functions.
  • XML is heavy and verbose. JSON is short and lightweight.
  • File extension of XML data is .xml. File extension of JSON data is .json.
  • XML is document based. JSON is data based.
  • JSON is simple to read, write and understand. XML is less simple to read, write and understand.
  • Array is supported by JSON. Array is not supported by XML.
  • JSON stands for JavaScript Object Notation. XML stands for Extensible Markup Language.

8) What is MIME type for JSON data?

MIME type is application/json.

9) Which functions are used for encoding and decoding JSON in PHP?

For encoding, json_encode() function is used. This function takes PHP value like array as input and returns JSON representation of it. For decoding, json_decode() function is used. This function takes JSON string as input and returns associative array.

10) What is the use of JSON.stringify() function?

JSON.stringify() function is used to convert a JavaScript value(Object) into a JSON string.

11) What is the purpose of JSON.parse() function?

This function is used to convert JSON string into a JavaScript object.