JSON Interview Questions and Answers

Mention how to receive JSON Data at the Server Side?

First of all read the JSON data as a String type and create JSONobject java object from the string 

String json =readJSONStringFromRequestBody (request);
//Use the JSON-Java including library to create a JSON object in Java JSONObject = null;
try{
jsonObject = new JSONObject(json);
}
catch(ParseException e){
}

Why is JSON so popular?

Because the JSON light weight standard for exchange information

  • JSON is independent of language
  • It is independent of Hosting Server
  • It is easy for human readable
  • It is easy to Encode and Decode
  • Mostly used in Mobile application

How many Browser Support in JSON?

JSON support is included in newer browsers and in the newest ECMAScript (JavaScript)

Standard. There are:

  • Internet Explorer 8
  • Opera 10
  • Chrome
  • Safari
  • Firefox (Mozilla) 3.5

Mention how to create JSON from PHP array?

$array = array('name'=>'J2EE Tutorial','Description'=>'www.J2eebrain.com');
echo json_encode($array);

Mention where is use JSON?

JSON is used for converting information between two applications. Any information can be also being converted between two different applications which are running on different or same server. JSON is also used in Mobile Application and Web Application such as IOS, Android, iPhone, window phone).

What is Syntax of JSON?

Some basic syntax of JSON is.

JSON CODE

{
“students” : [
{ “firstName”:”Meraj” , “lastName”:”Ansari” },
{ “firstName”:”Deepak” , “lastName”:”Gupta” },
{ “firstName”:”Himanshi” , “lastName”:”Singh” },
{ “firstName”:”Ankita” , “lastName”:”Tiwari” },
]
}

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

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