JSON - Overview


JSON or JavaScript Object Notation is a lightweight text-based open standard designed for human-readable data interchange. Conventions used by JSON are known to programmers, which include C, C++, Java, Python, Perl, etc.

  • JSON stands for JavaScript Object Notation.

  • The format was specified by Douglas Crockford.

  • It was designed for human-readable data interchange.

  • It has been extended from the JavaScript scripting language.

  • The filename extension is .json.

  • JSON Internet Media type is application/json.

  • The Uniform Type Identifier is public.json.

Uses of JSON

  • It is used while writing JavaScript based applications that includes browser extensions and websites.

  • JSON format is used for serializing and transmitting structured data over network connection.

  • It is primarily used to transmit data between a server and web applications.

  • Web services and APIs use JSON format to provide public data.

  • It can be used with modern programming languages.

Characteristics of JSON

  • JSON is easy to read and write.
  • It is a lightweight text-based interchange format.
  • JSON is language independent.

Simple Example in JSON

The following example shows how to use JSON to store information related to books based on their topic and edition.

   "book": [
         "language": "Java",
         "edition": "third",
         "author": "Herbert Schildt"
         "language": "C++",
         "edition": "second",
         "author": "E.Balagurusamy"

After understanding the above program, we will try another example. Let's save the below code as json.htm

      <title>JSON example</title>
      <script language = "javascript" >
         var object1 = { "language" : "Java", "author"  : "herbert schildt" };
         document.write("<h1>JSON with JavaScript example</h1>");
         document.write("<h3>Language = " + object1.language+"</h3>");  
         document.write("<h3>Author = " + object1.author+"</h3>");   

         var object2 = { "language" : "C++", "author"  : "E-Balagurusamy" };
         document.write("<h3>Language = " + object2.language+"</h3>");  
         document.write("<h3>Author = " + object2.author+"</h3>");   
         document.write("<hr />");
         document.write(object2.language + " programming language can be studied " + "from book written by " + object2.author);
         document.write("<hr />");

Now let's try to open json.htm using IE or any other javascript enabled browser that produces the following result −

json example demo

You can refer to JSON Objects chapter for more information on JSON objects.

Useful Video Courses


AJAX API JSON Connect to JSON data using AJAX webpage

20 Lectures 1 hours

Laurence Svekis


Apps Script Web App FUN API and JSON Data Spreadsheet

16 Lectures 1 hours

Laurence Svekis


Google Sheets as JSON data source for JavaScript

10 Lectures 1 hours

Laurence Svekis


Web API - JavaScript Fetch getting JSON data Fun with APIs

23 Lectures 2.5 hours

Laurence Svekis


Learn JSON and JSON Schema for Absolute Beginners

9 Lectures 48 mins

Nilay Mehta