JSON (JavaScript Object Notation) is a lightweight, text-based format used to store and exchange data. It’s one of the most common formats in APIs, web apps, and configuration files.
JSON is just structured text that represents data using:
• objects (key–value pairs)
• arrays (lists)
It’s easy for humans to read and for machines to parse.
Basic JSON example
{
"name": "Alice",
"age": 30,
"isStudent": false,
"skills": ["C#", "SQL", "JavaScript"]
}
Core building blocks of JSON
1. Object
{
"key": "value"
}
2. Array
["apple", "banana", "orange"]
3. Data types
• String → "text"
• Number → 123, 3.14
• Boolean → true, false
• Null → null
• Object → { }
• Array → [ ]
Why we use JSON?
• Easy to read and write
• Language-independent
• Perfect for APIs (client ↔ server communication)
• Lightweight compared to XML
• Widely supported everywhere
When to use JSON?
Use it when:
• Building REST APIs
• Sending data between frontend and backend
• Storing configuration files
• Working with web services
• Data interchange between systems
When NOT ideal?
• Very large datasets (binary formats like Avro are better)
• High-performance systems needing compact binary formats
• Complex schema evolution requirements
Advantages
• Human-readable
• Simple syntax
• Widely supported
• Easy debugging
• Flexible structure
Disadvantages
• Larger size than binary formats
• No built-in schema (unless using external tools)
• Slower parsing compared to compact formats
• Less strict typing
Alternatives
1. XML
• More verbose, supports schemas (XSD)
2. Apache Avro
• Compact, schema-based, better for big data
3. Protocol Buffers
• Very fast, strongly typed
4. YAML
• More human-friendly, used in configs