Top JSON Interview Questions and Answer

There are given interview questions with answers on 20+ topics such as PHP, CodeIgniter, Laravel, OOP'S, SQL, PostGreSQL, Javascript, JQuery, Python etc. Each topic contains at least 25 interview questions with answers.

JSON is a faster and more accessible data exchange format. JSON (JavaScript Object Notation) is a platform and language-independent data format. JSON is a wire protocol that specifies a data format for data exchange/communication between processes/applications.



A collection of name/value pairs is referred to as an object. An object in JSON starts with a left brace and ends with a right brace. A colon follows each name, and the name/value pairs are separated by a comma (comma). 



There are six types of data types in JSON -

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



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



JSON is a data format. It could be classified as a language, but not a programming language. Its relationship to JavaScript is that it shares its syntax (more or less) with a subset of JavaScript literals.



  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.



MIME type is application/json.



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.



To convert JSON text into an object “json.parse()” function is used.



JSON.stringify() converts an object into a JSON text and saves that JSON text in a string.



var json = '{"name": "Guru 99", "Description ": "Learn PHP Interactively with PHP Beginner Tutorials"}'

obj = $.parseJSON(json);

//alert(obj.name);



JSON files have  the ".json" file extension. "application/json" is the MIME type for JSON text.



JSON is used in multiple ways:

  • JSON is used when creating JavaScript applications, such as browser extensions and websites.
  • JSON is a serialisation and transmission standard for structured data across a network connection.
  • Web services and APIs use the JSON format to deliver public data.



Drawbacks of json are

  • It does not contain type definition
  • It lacks some sort of DTD



There are several similarities that can be found between JSON and XML. They are:

  • Both JSON and XML are used to transfer data between different systems.
  • Both JSON and XML have a simple structure and are readable by humans.
  • Both are independent of programming language.
  • Both JSON and XML support nested or hierarchical structures.
  • Both of these can be parsed easily through several programming.
  • Both these structures have support for Unicode.



Support for JSON is included in almost all the new versions of the browsers. Internet Explorer, Chrome, Safari, Mozilla Firefox, etc. all support JSON format.



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.



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



Uses of JSON includes

  • When writing application based on JavaScript it uses JSON, which includes browser extension and websites
  • JSON is used for transmitting and serializing structured data over network connection
  • JSON is mainly used to transfer data between server and web application
  • Web service and API’s use JSON format to provide public data
  • JSON can be used with modern programming language



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.



  • To Share this Link, Choose your plateform