JSON Interview Questions & Answers

5) Why must one use JSON over XML?

  • It is faster and lighter than XML as on the wire data format
  • XML data is typeless while JSON objects are typed
  • JSON types: Number, Array, Boolean, String
  • JSON types: Number, Array, Boolean, String
  • Fetching values is as simple as reading from an object property in your JavaScript code.

6). Mention what is JSON-RPC and JSON Parser?

  • JSON RPC:It is a simple remote procedure call protocol same as XML-RPC although it uses the lightweight JSON format instead of XML
  • JSON Parser:JSON parser is used to parse the JSON data into objects to use its value. It can be parsed by javaScript, PHP and jQuery.

7). Mention what is the file extension of JSON?

File extension of JSON is .json

8). Mention which function is used to convert a JSON text into an object?

To convert JSON text into an object “eval” function is used.


JSON Interview Questions & Answers

  1. Mention what is JSON?

JSON is a simple data exchange format.  JSON means JavaScript Object Notation; it is language and platform independent.
2.  Explain what is JSON objects?

An object can be defined as an unordered set of name/value pairs.  An object in JSON starts with {left brace} and finish or ends with {right brace}.  Every name is followed by: (colon) and the name/value pairs are parted by, (comma).

3.  Explain how to transform JSON text to a JavaScript object?

One of the common use of JSON is to collect JSON data from a web server as a file or HTTP request, and convert the JSON data to a JavaScript, ant then it avails the data in a web page.

4. Mention what is the rule for JSON syntax rules? Give an example of JSON object?

JSON syntax is a set of the JavaScript object notation syntax.

  • Data is in name/value pairs
  • Data is separated by comma
  • Curly brackets hold objects
  • Square bracket holds arrays

JSON with Ajax

AJAX is Asynchronous JavaScript and XML, which is used on the client side as a group of interrelated web development techniques, in order to create asynchronous web applications. According to the AJAX model, web applications can send and retrieve data from a server asynchronously without interfering with the display and the behavior of the existing page.

Many developers use JSON to pass AJAX updates between the client and the server. Websites updating live sports scores can be considered as an example of AJAX. If these scores have to be updated on the website, then they must be stored on the server so that the webpage can retrieve the score when it is required. This is where we can make use of JSON formatted data.

Any data that is updated using AJAX can be stored using the JSON format on the web server. AJAX is used so that javascript can retrieve these JSON files when necessary, parse them, and perform one of the following operations −

  • Store the parsed values in the variables for further processing before displaying them on the webpage.
  • It directly assigns the data to the DOM elements in the webpage, so that they are displayed on the website.

–    Example

The following code shows JSON with AJAX. Save it as ajax.htm file. Here the loading function loadJSON() is used asynchronously to upload JSON data.



<metacontent=”text/html; charset = ISO-8859-1″http-equiv=”content-type”>

function loadJSON(){

var data_file=”http://www.tutorialspoint.com/json/data.json&#8221;;

var http_request =newXMLHttpRequest();


// Opera 8.0+, Firefox, Chrome, Safari

http_request =newXMLHttpRequest();


// Internet Explorer Browsers{


http_request =newActiveXObject(“Microsoft.XMLHTTP”);


// Something went wrong

alert(“Your browser broke!”);






http_request.onreadystatechange =function(){

if(http_request.readyState ==4){

// Javascript function JSON.parse to parse JSON data

var jsonObj = JSON.parse(http_request.responseText);


// jsonObj variable now contains the data structure and can

// be accessed as jsonObj.name and jsonObj.country.

document.getElementById(“Name”).innerHTML = jsonObj.name;

document.getElementById(“Country”).innerHTML = jsonObj.country;



http_request.open(“GET”, data_file,true);



<title>tutorialspoint.com JSON</title>




<h1>Cricketer Details</h1>