+91 90691 39140 | +1 253 214 3115 | info@hub4tech.com | hub4tech

Top 10 Most Common JSON Interview Questions

Sat, 2017-08-05 16:22
JSON Interview Questions

Are you preparing for JSON job interview and wondering what questions you might be asked? In this blog we have hand-picked the questions you are likely to be asked in JSON job interview and provided to-the-point answers to each one of them so as to help you prepare better for JSON job interviews.

Always keep in the mind that, only academic knowledge is not enough to crack an interview. Employers expects from the candidate to have practical knowledge and hands-on experience as well. This JSON Interview Questions designed by industry expert will help you to gain practical knowledge of JSON.

JSON Interview Questions and Answers

  1. What is JSON?
  2. Answer: JSON full form is JavaScript Object Notation. JSON is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript programming language for representing simple data structures and associative arrays, called objects. And JSON is language-independent, with parsers available for virtually every programming language. Uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python,php
    The JSON format is often used for serializing and transmitting structured data over a network connection. When third party data interchane(REST Services) then JSON may used there LIKE SHOP .It is primarily used to transmit data between a server and web application, serving as an alternative to XML.

  1. Who is the Father or creater of JSON ?
  2. Answer: Douglas Crockford called as the Father of JSON

  1. What is the file extension of JSON?
  2. Answer: The JSON filename extension is .json.

  1. Why use JSON over XML?
  2. Answer:
    Lighter and faster than XML as on-the-wire data format

    • JSON objects are typed while XML data is typeless
    • JSON types: string, number, array, boolean,
    • XML data are all string
    • Native data form for JavaScript code
    • Data is readily accessible as JSON objects in your JavaScript
    • code vs. XML data needed to be parsed and assigned to variables through tedious DOM APIs
    • Retrieving values is as easy as reading from an object property in your JavaScript code
  1. Explain JSON Structures.
  2. Answer:
    A collection of name/value pairs

    • In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array
    • An ordered list of values
    • In most languages, this is realized as an array, vector, list, or sequence
    • These are universal data structures supported
    • A JSON object is an unordered set of name/value pairs
    • A JSON object begins with { (left brace) and ends with } (right brace)
    • Each name is followed by : (colon) and the name/value pairs are separated by , (comma)
  1. What is the Security and JSON Parser?
  2. Answer:
    Security and JSON Parser to understand by below examples
    // Include http://www.json.org/json.js
    var myObject = myJSONtext.parseJSON();

    • eval() can compile and execute any JavaScript program, so there can be security issues (cross-site scripting)

    Use eval() when the source can be trusted

    • When security is a concern - the source cannot be trusted -, it is better to use a JSON parser

    A JSON parser will only recognize JSON text and so is much safer
    Object to Text Conversion
    var myJSONText = myObject.toJSONString();

    • You can convert JSON object into JSON text
    • JSON does not support cyclic data structure

    Do not give cyclical structures to the JSON stringifier

  1. What are the JSON Tools for Java Developer?
  2. Answer:
    Some of JSON tools for java developer is

    • Parser:Parse JSON text files and convert these to a Java model
    • Renderer:Render a Java representation into text
    • Serializer:Serialize plain POJO clusters to a JSON representation
    • Validator:Validate the contents of a JSON file using a JSON schema
    • JSONObject Java Class
    • A JSONObject is an unordered collection of name/value pairs
    • The put methods adds a name/value pair to an object
    • The texts produced by the toString methods strictly conform to the JSON syntax rules
    • myString = new JSONObject().put(\"JSON\", \"Hello, World!\").toString();

    // myString is {\"JSON\": \"Hello, World\"}

  1. How to Generate or Send JSON Data at the Server Side?
  2. Answer:

    • Create JSON Java object
    • Add name and value pairs using put method
    • Convert it to String type using toString method and send it to the client with content-type as \"text/xml\" or \"text/plain\"

    myString = new JSONObject().put(\"JSON\", \"Hello, World!\").toString();
    // myString is {\"JSON\": \"Hello, World\"}

  1. How to receive JSON Data at the Client Side?
  2. Answer:

    • JSON data is received as a string
    • Calling eval() will generate JSON object in JavaScript code

    var JSONdata = eval(req.responseText);

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

    var name = JSONdata.name;
    var address = JSONdata.addresses[3];
    var streetname = JSONdata.addresses[3].street;

  1. How to Generate/Send JSON Data at the Client Side?
  2. Answer:

    • 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-form-urlencoded\");

Use Full Link for JSON Training and Certification

Copyright ©2015 Hub4Tech.com, All Rights Reserved. Hub4Tech™ is registered trademark of Hub4tech Portal Services Pvt. Ltd.
All trademarks and logos appearing on this website are the property of their respective owners.