Top 10 JSON Interview Questions & Answer

Top 10 JSON Interview Questions & Answer
IT & Software

1. What is JSON?

JSON is the abbreviation of JavaScript Object Notation. It is one of the simplest data interchange formats, independent of programming language and platform. Its lightweight text-based structure makes it easily readable. It is derived from JavaScript for presenting simple data in the form of key-value pairs.

It is often used for serialization and transmission of data between network connections. It is mostly used for data transmission between a web application and the server thereby making it a popular alternative to the XML format.

 

2. How many data types are there in JSON?

There are six types of data types in JSON -

  1. Number
  2. String
  3. Boolean
  4. Array
  5. Object
  6. Null

 

3. What is meant by JSON objects?

An object is defined as a set of key-value pairs. A JSON starts with a left brace “{“ and ends with another right brace “}”. Every key is followed by a colon “:” and the key-value pairs are separated from each other by using a comma “,”. So, basically, the JSON object is a collection of keys along with their values arranged in a pre-specified JSON format.

 

4. What is the difference between XML and JSON?

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

 

5. 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.

 

6. What are the uses of JSON?

JSON is mainly used for data interchange between the two systems.

  • JSON is prominently used for the transmission of serialized data over a network connection between two systems.
  • APIs and web services use JSON to format and transfer data.
  • JSON can be used in combination with most modern programming languages.
  • JSON can be used with JavaScript applications such as browser plugins and websites.
  • JSON can be used to read data from the web server and display data on the web pages.

 

7. Mention what is JSONP?

JSONP stands for JSON with padding. It is a method used to bypass the cross-domain policies in web browsers. In other words, JSONP is the simple way to deal with browser restrictions when sending JSON responses from different domains from the client.

 

8. Mention what is the difference between JSON and JSONP?

  • JSON: JSON is a simple data format used for communication medium between different systems
  • JSONP: It is a methodology for using that format with cross domain ajax requests while not being affected by same origin policy issue.

 

9. What is the difference between JSON parse and JSON Stringy?

JSON.stringify() is to create a JSON string out of an object/array. They are the inverse of each other. JSON.stringify() serializes a JS object into a JSON string, whereas JSON.parse() will deserialize a JSON string into a JS object.

 

10. What are the limitations of JSONP?

JSONP is used to bypass the same-origin policy of web browsers. It may seem like a perfect way to get around the restriction but it has its own set of limitations as well. They are:

  • As all the JSONP calls are made by including a [removed] tag, the request made is confined only to the GET method.
  • It cannot be used for POST or PUT requests.
  • It can be used only for read-only services and APIs.

  • To Share this Blog, Choose your plateform


Write your Testimonial

Your review is very precious for us.


Rating: