JSON Interview Questions and Answers

Explain what is the data type supported by JSON?

The data types supported by JSON includes

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

Explain what is the role of JSON.stringfy()?

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

Define how to parse JSON in JQuery?

To parse JSON JQuery, we will see this code

var json = ‘{“name”: J2EEbrain”, “Description “: “Learn Java, Play Framework, HTML 5 etc. Tutorials}
obj = $.parseJSON(json);
//alert(obj.name);

What do you mean by JSON files?

  • The MIME type for JSON text is “application/json”
  • JSON file type for JSON files is “.json”

What do you understand by JSON-RPC-Java?

The JSON-RPC-Java is an implementation of the JSON-RPC protocol.

What are the features of JSON-RPC-Java?

There are following features of JSON-RPC-Java is:

  • JSON provides asynchronous communications
  • Transparently maps Java objects to JavaScript objects.
  • The JSON is lightweight protocol similar to XML-RPC although much faster
  • The leverages J2EE security model with session specific exporting of objects
  • JSON support browsers Internet Explorer, Mozilla, Firefox, Safari, and Opera.

Explain what is the JSON Parser?

The JSON Parser is used to parse the JSON data into object to use its value. The JSON can be also parser by PHP, JavaScript and jQuery.

Mention what is JSON-RPC?

The Remote Procedure calls protocol to use of JSON. The JSON-RPC is similar to XML-RPC only difference which use JSON instead of XML.

Mention how to receive JSON Data at the client Side?

Here is given some method to receive JSON data at the client side:

  • The JSON data is received as a string
  • Calling the eval() function will generate a JSON object in JavaScript code
var JSONdata = eval(req.responseText);
var name = JSONdata.name;
var address = JSONdata.addresses[3];
var streetname = JSONdata.address[3].street;

Once you have JSON object, you can use. The notation to access its properties

Explain how to generate and send JSON Data at the Client Side?

Here is given following technique to generate and send data at the client side:

  • Create JSON JavaScript object
  • Use \*POST\” HTTP method in the open method of the XMLHttpRequest object
  • Pass JSON JavaScript object in the send method of XMLHttpRequest object
var carAsJSON = JSON.stringify(car);
var url = \”JSONExample?timeStamp=\” +new Date().getTime(); createXMLHttpRequest();
xmlHttp.open(\”POST\”, url, true);
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.setRequestHeader(\”Content-Type\”, \” application/x-www-from-urlencoded\”);
xmlHttp.send(carAsJSON);