---
title: "Introduction to JSON"  
description: "JSON is smaller than XML, and faster and easier to parse. JSON (an acronym for JavaScript Object Notation) is a lightweight text-based open standard d"  
author: "Anonymous User"  
published: 2012-05-04  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/304/introduction-to-json  
category: "json"  
tags: ["json"]  
reading_time: 2 minutes  

---

# Introduction to JSON

JSON is smaller than XML, and faster and easier to parse. JSON (an acronym for JavaScript Object Notation) is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript [programming language](https://www.mindstick.com/articles/329035/5-most-in-demand-programming-languages-to-consider-for-your-app-development-in-2022) for representing simple [data structures](https://www.mindstick.com/blog/301312/data-structures-and-their-applications) and associative arrays, called objects. JSON is syntax for storing and exchanging text information.\

JSON is a text format that is completely language [independent](https://answers.mindstick.com/qa/98599/what-is-the-longest-river-in-the-commonwealth-of-independent-states) but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

##### JSON is built on two structures:

· A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, [hash table](https://www.mindstick.com/forum/157906/what-is-the-difference-between-a-hash-table-and-an-array-when-would-you-use-one-over-the-other), keyed list, or [associative array](https://www.mindstick.com/forum/606/length-of-javascript-object-ie-associative-array).

· An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

JSON is not only a syndication format (e.g. an [alternative](https://www.mindstick.com/forum/2324/what-is-the-alternative-to-the-mvc) to XML); it is a language-independent data interchange format.

##### Why JSON?

For AJAX [applications](https://www.mindstick.com/articles/12847/how-to-choose-the-right-ethernet-cable-for-industrial-applications), JSON is faster and easier than XML.

##### Using XML:

##### · Fetch an XML document

##### · Use the XML DOM to loop through the document

##### · Extract values and store in variables

##### \
Using JSON:

##### · Fetch a JSON string

##### · eval() the JSON string

##### JSON Syntax Rule:

##### JSON syntax is a subset of the JavaScript object notation syntax.

##### · Data is in name/value pairs

##### · Data is separated by comma

##### · Curly brackets holds objects

##### · Square brackets holds arrays

Example: In this example, simply I have created [JSON object](https://www.mindstick.com/forum/699/how-to-parse-into-json-object-using-json-parse-in-node-js) and store some values after then set these values into proper names.

```
<html> <head>                <title>JSON Object Creation Demo</title> </head> <body> <h2>JSON Object Creation in JavaScript</h2> <p> Name: <span id="jname"></span><br /> Age: <span id="jage"></span><br /> Address: <span id="jstreet"></span><br /> Phone: <span id="jphone"></span><br /> </p> <script type="text/javascript">                      var JsonObject= {                                                                "name":    "Arun Kumar Singh",                                                                "street":    "Kothapaarcha",                                                                "age":    22,                                                                "phone":  "000 1234567"                                                };                                                document.getElementById("jname").innerHTML=JsonObject.name                                                document.getElementById("jage").innerHTML=JsonObject.age                                                document.getElementById("jstreet").innerHTML=JsonObject.street                                                document.getElementById("jphone").innerHTML=JsonObject.phone                </script> </body></html>
```

Now save this file in html format and open it with [web browser](https://www.mindstick.com/blog/301688/best-web-browsers-for-2023).

![Introduction to JSON](https://www.mindstick.com/blogs/e3566fd7-920d-414f-9e52-cbb69038947e/images/02bb16b0-e65f-4a46-a2ba-0c8f72b23e5c.jpg)

---

Original Source: https://www.mindstick.com/blog/304/introduction-to-json

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
