JSON (JavaScript Object Notation) is a lightweight data format used to store and exchange data between a client and a server.
It is the most common format for APIs and web services.
JSON represents data as:
Key–value pairs
Arrays and objects
Text-based and language-independent format
Example:
| JSON | JavaScript Object |
|---|---|
| Data format | Programming object |
| Uses double quotes | Quotes optional |
| No functions | Can contain functions |
✔ null, 2 formats JSON neatly
Typical API flow:
Client sends JSON request
Server parses JSON body
Server processes data
Server responds with JSON
Read data
Update fields
Add new entries
Delete entries
Example:
Always validate incoming JSON
Use res.json() instead of res.send()
Format JSON for readability
Handle parsing errors properly
REST APIs
Configuration files
Data exchange between services
Frontend–backend communication
JSON is the standard data format for web apps
Easily parsed and generated in Node.js
Express provides built-in JSON handling
Essential for API development
Take quizzes related to this topic and see where you stand!
Start Quiz Now