What Is JSON?
JSON stands for JavaScript Object Notation. Despite the "JavaScript" in the name, it's used in virtually every programming language. It's a lightweight way to store and transport data.
Think of it like a digital form โ structured data that both humans and machines can read.
JSON Syntax Rules
JSON has just a few rules:
A Simple Example
{
"name": "Himanshu",
"age": 28,
"isActive": true,
"skills": ["JavaScript", "Python", "Design"],
"address": {
"city": "Mumbai",
"country": "India"
}
}
JSON Data Types
| Type | Example |
|---|---|
| String | "hello world" |
| Number | 42 or 3.14 |
| Boolean | true or false |
| Array | [1, 2, 3] |
| Object | {"key": "value"} |
| Null | null |
Where You'll Encounter JSON
- APIs: When you fetch data from the internet (weather, maps, payment), it almost always comes back as JSON
- Config files: package.json in Node.js, settings.json in VS Code
- Databases: MongoDB, Firebase, and other NoSQL databases store data in JSON-like formats
- Local Storage: Browsers store web app data as JSON strings
Conclusion
JSON is one of those things that seems intimidating at first but becomes completely natural after a few encounters. Once you recognize the pattern, you'll see it everywhere โ and know exactly how to read and write it.