JSON Interview Questions

Advertisements

Prev Tutorial Next Tutorial

JSON Interview Questions

json interview questions

JSON Interview Question for Freshers

What is JSON ?

JSON JavaScript Object Notation is language independent, lightweight data-interchange format, "self-describing" and easy to understand. Json mainly use JavaScript syntax but it format in only text. just like XML.

Full form of JSON ?

JSON stand for JavaScript Object Notation.

Who is the Father of JSON ?

Douglas Crockford is the Creator or Father of JSON.

What is the file extension of JSON ?

The JSON filename extension is .json.

Why use JSON ?

JSON is simpler and easier than XML. In place of XML we use JSON.

Gove Important Features of JSON

  • It is light weight standard for exchange information
  • It is independent of language
  • It is independent of Hosting Server
  • Human Readable
  • Easy to Encode
  • Easy to Decode
  • Used in Mobile application

Which Browser Support JSON ?

In simple word it support by all new web browser and it's latest version. JSON support is included in newer browsers and in the newest ECMAScript (JavaScript) standard.

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

Where JSON is used

It is used to transfer the information between two application. Information can also be exchanged between two different application which is running on different OR same server. It is used in Web Application, Mobile Application (IOS, Android, Iphone, window Phone)

How many data types are there in JSON ?

There are six types of data types in JSON, all are given below;

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

What is the use of JSON.stringify() function ?

JSON.stringify() function is used to convert a JavaScript value(Object) into a JSON string.

What is the purpose of JSON.parse() function ?

This function is used to convert JSON string into a JavaScript object.

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.

What is MIME type for JSON data ?

MIME type is application/json.

What are advantage of JSON ?

  • It is easy to understand and use
  • It is alternative of XML.
  • It is is language independent, it means you can you JSON with any language.
  • It is a lightweight data-interchange format.

Explain Uses of JSON ?

A common use of JSON is to read data from a web server, and display the data in a web page.

How to denote Objects in JSON.

Example

{"firstName":"Komal", "lastName":"Pandit"}

Give syntax for JSON Arrays

Example

"employees":[
{"firstName":"Komal", "lastName":"Pandit"},
{"firstName":"Gaurav", "lastName":"Rawat"},
{"firstName":"Hitesh", "lastName":"Kumar"}
]

Differences between JSON and XML

JSONXML
JSON stands for JavaScript Object Notation.XML stands for eXtensible Markup Language.
It is simple to read and write.Compare to JSON XML is less simple.
It is data-oriented.XML is document-oriented.
It is less secured than XML.It is more secured.
JSON doesn't use end tagXML have end tag.
JSON is shorterXML is larger than JSON.
JSON is quicker to read and writeXML is not.
JSON can use arraysXML do not have an array.

Similarities between JSON and XML

  • Both are simple and open.
  • Both are language-independent.
  • Both are self describing (human readable)
  • Both are hierarchical (values within values)
  • JSON and XML can be parsed and used by lots of programming languages
  • JSON and XML can be fetched with an XMLHttpRequest
  • JSON and XML supports unicode. So internationalization is supported by JSON and XML both.

How to receive JSON Data at the Client Side ?

Syntax

var json = '{"name":"Sitesbay","Description":"Free Online Tutorial"}'
obj = $.parseJSON(json)

What are online tool for Validate JSON data ?

http://jsonlint.com/
http://www.freeformatter.com/json-validator.html

How to Validate json in php ?

Syntax

 
$json = '{"name":"Sitesbay","Description":"Free Online Tutorial"}';
$obj = json_decode($json);
if(is_null($obj)) {
 die('Invalid JSON');
}

How to Validate json in javascript ?

Syntax

function isValidJson(jsonData) 
{
    try 
{
  JSON.parse(jsonData);
  return true;
 } catch (e) 
{
  return false;
   }
}
var json = '{"name":"Sitesbay","Description":"Free Online Tutorial"}'
isValidJson(json);

How to Validate json in jQuery ?

Syntax

 function isValidJson(jsonData) 
 {
    try 
	{
        $.parseJSON(jsonData);
        return true;
    } catch (e) 
	{
        return false;
    }
}
var json = '{"name":"Sitesbay","Description":"Free Online Tutorial"}'
isValidJson(json);

How Convert json object to json string in jquery ?

Syntax

var json = '{"name":"Sitesbay","Description":"Free Online Tutorial"}'
JSON.stringify(json)

How to convert json object to json string in javaScript ?

Syntax

var json = '{"name":"Sitesbay","Description":"Free Online Tutorial"}'
JSON.stringify(json)

How to receive JSON Data at the Client Side ?

Syntax

var json = '{"name":"Sitesbay","Description":"Free Online Tutorial"}'
obj = $.parseJSON(json)

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements