JSON Interview Questions


Never miss a post!

Sign up for our newsletter and get FREE Development Trends delivered directly to your inbox.

You can unsubscribe any time. Terms & Conditions.

In this article, you can find the most frequently asked questions related to JSON.  

What is JSON?

JSON is an acronym for JavaScript Object Notation, which acts as a connector between the two endpoints of an application. In javascript and server side technologies, it is one of the simplest and fastest data exchange format based on key-value pairs after the traditional XML format, thus gives more advantage in terms of speed and performance. It is a platform independent and lightweight text-based format, which makes it more readable to the developers.

What do you use JSON?

JSON is used to pass the data or information from one endpoint to another endpoint over the network. You can serialize and deserialize the data for the transmission of data. The main use of JSON format is to send the information from client to server or vice versa.

Who invented JSON and what is the scripting language JSON is based on?

Douglas Crockford is called as a father of JSON and it is based on ECMAScript.

What are the Languages that supports JSON?

Nearly all the programming languages support built in JSON libraries, which includes c, C#, C++, Perl, Python, Java, PHP, Ruby etc.

What are the Platforms that supports JSON?

JSON is cross-platform and can be used with any browser without any parser.

What are the Data Types that are supported by JSON?

JSON supports typically all the primitive data types, which includes integers, strings, booleans and null. You can also send or receive data in structured data types i.e. arrays and objects.

What is JSON Object?

A JSON object can have a set of name and value pairs. It starts with the left brace “{“ and ends with the right brace “}”.  In JSON object, the colon operator follows the name “:”, and the set of name and value pairs are separated by the comma operator “,”.

Why must one use JSON over XML?

There are multiple reasons why JSON is recommended to use over XML

  • It is a light-weighted structure format that makes it faster and lighter than XML data format
  • JSON objects are typed whereas XML data is typeless
  • You can pass multiple JSON types like Number, Array, Boolean and String, whereas XML data can be passed as a plain string
  • Javascript can easily convert the JSON object in JavaScript language whereas am XML cannot do it
  • You can access the value of a name of JSON object by using the dot operator in javascript, hence no parser is required whereas XML does not support that

How do you convert a JSON text into an object?

You can use the function “eval” to convert any JSON text into an object.

What is the role of the function stringify() in JSON?

The function JSON.stringify() converts an object into a JSON text and after that it saves that JSON text in a string.

What is the MIME and File Type of JSON files?

You can store the JSON files with the extension “.json”. The MIME type for the JSON text is “application/json”.

What is JSONP?

JSONP is an abbreviation of JSON with padding. It is a technique used in JSON to bypass the cross-domain policies of modern web browsers. In other words, you can say that JSONP is an alternate way to handle the restrictions of browser to send a JSON response from the clients with different domains.

What are the limitations of JSON?

JSON is the most widely used data exchanger format but at the same time, it also has its own set of limitations, which are listed below:

  • JSON text gets complexed if there are several nested and hierarchical objects in it
  • JSON is not suitable for very complex large data
  • JSON cannot support the multimedia formats such as images or rich text format
  • JSON does not support the comments in the transmission

What are the syntax rules in JSON?

You need to follow the following rules for the structure of the JSON:

  • JSON Object has a data in key-value pair. The left side represents the key and the data on the right side represents the value, which are separated by a colon operator “:”
  • In JSON, every set of key-value pair is separated from the other pair by a comma operator “,”
  • The braces define JSON objects. The Left curly brace “{“ depicts the start of an object and the right curly brace “}” depicts the end of an object.
  • The square brackets “[ ]” are used to send or receive data in an array

What is Newtonsoft in .NET Framework?

JSON.NET or Newtonsoft is one of the most widely used libraries used in the .NET framework. It handles the conversion of .NET objects into JSON objects or vice versa.

  • You can parse and manipulate JSON data using its internal framework classes such as JArray, JValue, JObject, etc.
  • It has XPath that provides an easier solution for querying JSON objects
  • It has JSON serializer that helps in serializing and deserializing JSON text
  • It has a simple syntax that makes it easy to use
  • It supports the conversion from XML to JSON or vice versa.
  • It is free and open-source framework
  • It has the ability to use the specified JsonConverter to serialize or deserialize the JSON text

How do you serialize an object by using Newtonsoft or JSON.NET?

You can serialize the .NET object using the following code:

// Initialize the student object with the predefined data
Student student = new Student();
student.Name = "Student A ";
student.BirthDate = new DateTime(2010, 12, 01);
student.Gender  = "Male";
student.Courses = new string[] { "Business Communication", "Fundamentals of Programming", "Data Structures " };

// using JsonConvert library
string serializedStudentText = JsonConvert.SerializeObject(student);
//  "Name" : "Student A ",
//  "BirthDate" : "2020-12-01 T00:00:00",
//  "Gender"  : "Male";
//  "Courses": [
//    " Business Communication ",
//    " Fundamentals of Programming ",
//    " Data Structures "
//  ]

// Using JsonConvert to deserialize the JSON text
Student deserializedStudent = JsonConvert.DeserializeObject(serializedStudentText);



Our website uses cookies that help it to function, allow us to analyze how you interact with it, and help us to improve its performance. By using our website you agree by our Terms and Conditions and Privacy Policy.