Introduction to JSON
JSON stands for JavaScript Object Notation. It is a simple, text-based format used to store and share data between systems. Even though the name says "JavaScript," JSON is not limited to JavaScript — it works with almost every programming language including Python, Java, PHP, C#, and more.
Think of JSON as a universal language for data. When two different applications want to talk to each other and share information, they often use JSON as the common format.
Why is JSON Important?
In today's world, apps and websites constantly exchange data. For example, when a weather app shows the current temperature, it fetches that data from a server. That data is usually sent and received in JSON format. JSON has become the most popular data format for APIs (Application Programming Interfaces) because it is:
- Easy to read — even a non-programmer can understand it at a glance
- Lightweight — it uses minimal characters, so data travels fast over the internet
- Language-independent — any programming language can read and write JSON
- Easy to parse — computers can quickly convert JSON data into usable objects
A Real-Life Analogy
Imagine filling out a form at a hospital. The form has fields like Name, Age, Blood Group, and Address. JSON works in a very similar way — it stores data in labeled fields called key-value pairs. The label is the key and the information filled in is the value.
What Does JSON Look Like?
Here is a simple example of JSON data representing a student:
{
"name": "Ravi Kumar",
"age": 21,
"course": "Computer Science",
"isEnrolled": true
}In this example:
"name"is the key and"Ravi Kumar"is its value"age"is the key and21is its value"isEnrolled"is the key andtrueis its value
Where is JSON Used?
JSON is used in a wide range of real-world applications:
- Web APIs — when a website fetches data from a server (like login details, product lists, news feeds)
- Configuration files — many software tools store their settings in JSON files (like
package.jsonin Node.js) - Mobile apps — apps communicate with backend servers using JSON
- Databases — databases like MongoDB store data in a JSON-like format
- Data exchange — when two different systems (built in different languages) need to share information
JSON File Extension
A JSON file is saved with the .json extension. For example: student.json, config.json, or data.json. These files are plain text files and can be opened in any text editor.
Key Points to Remember
- JSON is a text-based data format
- It was originally derived from JavaScript but works with all languages
- Data is stored in key-value pairs
- JSON files use the
.jsonextension - It is the most commonly used format for web APIs today
- JSON is both human-readable and machine-readable
Summary
JSON is a simple, clean, and widely accepted way to represent and exchange data. Whether data is being sent from a server to a browser, or from one app to another, JSON serves as the reliable bridge. Understanding JSON is the first step towards working with web APIs, modern web development, and data-driven applications.
