970_90

Tuesday, 19 August 2014

Json Interview Questions And Answers For Freshers

Json Interview Questions And Answers For Freshers

Question: What is full Form JSON?
Answer: JavaScript Object Notation.


Question: What is JSON?
Answer: It is text-based standard design for interchange the information Between two or more different application. It is also very light as compare to XML and human readable.


Question: Who created the JSON?
Answer: Douglas Crockford


Question: Who is Father of JSON?
Answer: Douglas Crockford


Question: Why It is so popular?
Answer:
  1. It is light weight standard for exchange information
  2. It is independent of language
  3. It is independent of Hosting Server
  4. Human Readable
  5. Easy to Encode
  6. Easy to Decode
  7. Used in Mobile application



Question: Where JSON is used?
Answer: 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)


Question: What is file extension of JSON?
Answer: .json


Question: Why Use JSON over XML?
Answer: 

  1. It is light weight standard for exchange information.
  2. Human readable
  3. Easy to parse in PHP as well as in javaScript.
  4. Due to light weight It is fast.
  5. Question: Explain JSON Structures?
  6. Answer: It as an object, structure, or associative array where we stored data an ordered list.
  7. Each value have an key
  8. once key may have an further object
  9. Its lightweight that's why used in android application
  10. A JSON object begins with { and ends with } (braces)
  11. Each name is followed by : (colon) and the name/value pairs are separated by , (comma)


Question: Which Browser Support JSON?
Answer: 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



Question: What is JSON Parser?
Answer:JSON Parser is used to parse the JSON data into object to use its value. JSON can be parse by javaScript, jQuery and PHP.


Question: What is JSON-RPC?
Answer: Remote Procedure call protocol with use of JSON. It is similar to XML-RPC only difference, It use JSON instead of XML.

Question: What is JSON-RPC-Java?
Answer: JSON-RPC-Java is a Java implementation of the JSON-RPC protocol.


Question: How to create json from php array?
Answer:
$array = array('name'=>'PHP Tutorial','Description'=>'Web technology experts notes');
echo json_encode($array);


Question: How to get PHP array from json Object?
Answer:
$object='{"name":"PHP Tutorial","Description":"Expert in web technology"}';
$array = json_decode($object);


Question: How to parse JSON in JavaScript?
Answer:
var json = '{"name":"PHP Tutorial","Description":"Web technology experts notes"}'
    var obj = JSON.parse(json);
    //alert(obj.name);


Question: How to create JSON Object from JavaScript?
Answer:
var obj = {};
    obj['name']='php-tutorial-php.blogspot.in'; //string
    obj['age'] = 32;  // integer.
    obj['marks']= [80,70,60,50,60,80]; //array


Question: How to parse JSON in jQuery?
Answer:
var json = '{"name":"PHP Tutorial","Description":"Web technology experts notes"}'
    obj = $.parseJSON(json);
    //alert(obj.name);


Question: How to Validate json in php?
Answer:
$json = '{"name":"PHP Tutorial","Description":"Web technology experts notes"}';
$obj = json_decode($json);
if(is_null($obj)) {
 die('Invalid JSON');
}


Question: How to Validate json in javascript?
Answer:
function isValidJson(jsonData) {
    try {
        JSON.parse(jsonData);
        return true;
    } catch (e) {
        return false;
    }
}
var json = '{"name":"PHP Tutorial","Description":"Web technology experts notes"}'
isValidJson(json);


Question: How to Validate json in jQuery?
Answer:
 function isValidJson(jsonData) {
    try {
        $.parseJSON(jsonData);
        return true;
    } catch (e) {
        return false;
    }
}
var json = '{"name":"PHP Tutorial","Description":"Web technology experts notes"}'
isValidJson(json);


Question: How Convert json object to json string in jquery?
Answer:
var json = '{"name":"PHP Tutorial","Description":"Web technology experts notes"}'
JSON.stringify(json)


Question: How to convert json object to json string in javaScript?
Answer:
var json = '{"name":"PHP Tutorial","Description":"Web technology experts notes"}'
JSON.stringify(json)


Question: How to receive JSON Data at the Client Side?
Answer:
var json = '{"name":"PHP Tutorial","Description":"Web technology experts notes"}'
obj = $.parseJSON(json)


Question: How to get JSON response in Ajax?
Answer:
$.ajax({
  dataType: "json",
  url: '/ajax/url',
  data: 'name=php-tutorial-php',
  success: function(data){
  //data
  }
});


Question: What are online tool for Validate JSON data?
Answer:
http://jsonlint.com/
http://www.freeformatter.com/json-validator.html


Question: What are JSON online tool for Formatter & Validator?
Answer: http://jsonlint.com/
http://www.freeformatter.com/json-validator.html
http://jsonviewer.stack.hu/
http://json.parser.online.fr/


3 comments:

  1. Q: Can I add comment a JSON file?

    ReplyDelete
  2. no you can't add comment inside a json file.

    some other json online tools:

    JSON Beautifier
    JSON Minifier
    JSON Validator
    JSON To CSV Converter
    JSON To XML Converter
    JSON To YAML Converter

    hope this helps a bit.

    ReplyDelete
  3. its very helpfull, keep going on...

    ReplyDelete