JSON Interview Questions

JSON Interview Questions | Freshers & Experienced

  • Sharad Jaiswal
  • 28th Jun, 2021
  • 392 Followers

Practice Best JSON Interview Questions and Answers

Q1. What is JSON?

JSON stands for JavaScript Object Notation which is a data storage and communication format based on key-value pair of JavaScript object literals. It is derived from the JavaScript programming language for representing simple data structures and associative arrays, called objects. JSON is a minimal, readable format for structuring data commonly used for transmitting data in web applications.

Q2. Enlist few advantages of using JSONs?

The advantages of using JSONs are as follows:

  • JSON syntax is very easy to use.
  • JSON has a more compact style than XML.
  • The XML software parsing process can take a long time.
  • The JSON structure is straightforward and readable.
  • Structure Matches the Data.
  • JSON doesn't require much effort to make it all browser compatible. 

 

Q3. Who is known as the father of JSON?

Douglas Crockford is known as the father of JSON. He is an American computer programmer and entrepreneur who is involved in the development of the JavaScript language and JavaScript Object Notation or JSON.

Q4. What extension is used to save JSON file?

The extension that is used to save JSON files is .json.

Q5. Enlist data types available in JSON?

The data types available in JSON are as follows:

  • string.
  • number.
  • boolean.
  • null.
  • object.
  • array.

 

 

Q6. What two main structures used to compose JSON?

The two main structures used to compose JSON are keys and values. It can be explained as:

Key: A key is always a string enclosed in quotation marks. 

Value: A value can be a string, number, boolean expression, array, or object.

 

Q7. How do you decode a JSON string?

You can decode a JSON string with the help of json_decode() function. json_decode() function iis an inbuilt function in PHP that can converts a JSON encoded string into a PHP variable. Syntax: json_decode( $json, $assoc = FALSE, $depth = 512, $options = 0 )

Q8. What is the default value of a constructor's prototype?

The constructor property returns a reference to the Object constructor function that created the instance object. There is no default value of a constructor's prototype.

Q9. List some benefits of JSON over XML?

Some of the benefits of JSON over XML are as follows:

  • JSON has a more compact style than XML
  •  The XML software parsing process can take a long time than JSON.
  • The JSON structure is straightforward and readable.
  • SON uses a map data structure rather than XML's tree.

Q10. What is MIME type for JSON data?

MIME-type stands for A multipurpose internet mail extension that is an internet standard that describes the contents of internet files based on their natures and formats. In general, the text/plain was typically used for JSON, but according to IANA, the official MIME type for JSON is application/JSON.

Q11. What is JSON Validator?

A JSON Validator is used to validates a JSON string against RFC 4627 that is the application/json media type for JSON and against the JavaScript language specification. A JSON Validator can be configured to be lenient or strict.

Q12. What is JSON Schema?

In JSON, a JSON Schema is a grammar language for defining the structure, content, and semantics of JSON objects, that lets you specify metadata about what an object's properties mean and what values are valid for those properties. It is a specification for JSON-based format for defining the structure of JSON data.

Q13. What is JSON-RPC? List some Features of JSON-RPC-Java.

JSON-RPC is a call protocol that uses JSON for encoding messages. It is a simple and easy protocol just like XML-RPC. It supports multiple calling and notifications. In short, JSON-RPC is the method of sending a request to someone and receiving the response from another side.

Q14. What is BSON?

BSON stands for Binary JSON which is used by MongoDB. It is basically a superset of JSON with some more data types, most importantly binary byte array, and uses more space as compared to JSON and it allows you to effectively skip the records that you’re not fascinated with when perusing it.

Q15. How to convert an Object into JSON?

You can convert a Java object into a JSON object with the help of the GSON library. You can perform it by following the given steps:

  • Create a Maven project.
  • Add GSON dependency in an XML file.
  • Create Plain Old Java Object to convert into JSON.
  • Create a Java class to convert the Java object to JSON.

 

Q16. What does $.parseJSON() do ?

In JSON the parse() method parses a JSON string, constructing the JavaScript value or object described by the string. The $.parseJSON() parses a string containing JSON and returns the de-serialized object. Web module only.

The use of JSON is growing rapidly due to its light-weight and compact feature. Along with this, sharing is too fast because it uses an array to store the data and also you can share any size of data such as videos, images, etc. This is a brief introduction to JSON. If you want to know its advantages, disadvantages, and features, then visit our JSON online interview questions. This will help you to understand the basic concepts of JSON and enable you to crack any interviews. Check and start today!

Which is better?

JSON

XML

JSON stands for JavaScript Object Notation XML stands for extensible Markup Language. JSON has a more compact style than XML, and it is more readable. XML is less simple, therefore, not easy to read
JSON is much lightweight, so it can make significant improvements in RESTful APIs working with complex systems. XML is not much lightweight.
JSON uses less data, thus, increases the parsing speed. XML software takes more time in parsing due to the DOM manipulation libraries.
JSON uses a map data structure XML uses a tree structure JSON is data-oriented. XML is document-oriented.
JSON doesn't provide display capabilities. XML provides display capabilities because it is a markup language.
JSON is less secured than XML due to the possibility of hacking. XML is more secure.
JSON supports limited data types such as text and number data types. XML support many data types such as images, charts, graphs, texts, etc. JSON supports an array. XML doesn’t support array.

Advantage of JSON:

  • Small and light-weighted syntax: In many languages, the syntax is quite difficult to remember which wastes the developer’s time. But, in JSON this problem is solved, here the syntax is very easy to use. Its syntax is very small and lightweight; therefore, it executes the queries very rapidly.
  • JSON on the server side: It is quite obvious that fast response on the server side fascinates the developers to use that language. Similar, in the case of JSON, server-side parsing is fast enough that developers choose JSON for server-side programming. It is the strongest point of JSON that makes it popular among users.
  • Browser compatibility: When the developer designs the application, it is inevitable to write code differently for different browsers. This makes the burden on the developers. But you don't need to worry while programming in JSON. JSON provides a wide range of browsers that are compatible with different operating systems. Also, the developer requires just a little effort to make the application compatible with all browsers.
  • Data Transfer: You can share any size of data such as audios, videos, or larger files with JSON. It is the topmost tool for sharing the data. This is possible because JSON saves the data in an array format which is easier to transfer. This is the reason, why JSON is given a preference for the file format of web APIs and web development.
  • Easy to read: The structure of JSON is quite easy to understand. It doesn’t matter which language you are using, with JSON you can easily do the mapping with domain objects.
  • Conversion: Since, JavaScript has the built-in function to translate the JSON format string into a native JavaScript object so, it is quite easy to convert.

Disadvantages of JSON:

  • Error handling: The major drawback of JSON is no error handling for JSON calls. It fully depends on dynamic script insertion. If it inserted, then it works and you get calls and responses perfectly. But if it is not inserted, then it will fail silently and you will not know about that. For instance, if there is an error on the server-side, you will not able to recognize that such as 404 error. You can't restart or cancel the request as you don't know about the error. You just wait for a timeout.
  • Hacking: It is dangerous if JSON is used with untrusted browsers or services. As JSON service returns a response covered in a function call which is executed by a browser. But, if this browser is untrusted, then the response can be hacked. This makes the hosting application insecure about attacks.

About Author :

  • Author of JSON Interview Questions

    Sharad Jaiswal

    My name is Sharad Jaiswal, and I am the founder of Conax web Solutions. My tech stacks are PHP, NodeJS, Angular, React. I love to write technical articles and programming blogs.

Leave A Comment :

Valid name is required.

Valid name is required.

Valid email id is required.