JSON in REST APIs — Interview Questions
Reviewed by Gurusankar M.
Short Answer
In REST, JSON is the standard body format for both requests and responses. Clients send data as a JSON body with Content-Type: application/json (and Accept: application/json to ask for JSON back); the server parses it, does the work, and returns a JSON body plus the right status code. It's the common language between client and server.
On this page
Concept Made Simple
Coffee Chat Question
“How is JSON used in REST APIs?”
Remember It Faster
Mind Map Answer
- Request body
- JSON for POST/PUT/PATCH
- Response body
- JSON result or error
- Content-Type
- application/json (what you send)
- Accept
- application/json (what you want back)
Learn by Doing
Hands-on Keyboard
POST /api/users HTTP/1.1
Content-Type: application/json
Accept: application/json
{ "name": "Guru", "email": "guru@example.com" }
HTTP/1.1 201 Created
Content-Type: application/json
{ "id": 101, "name": "Guru" }Think Beyond the Expected
What If?
What happens if you POST JSON without a Content-Type: application/json header?
The server may not know to parse the body as JSON — many frameworks only run the JSON body parser when Content-Type is application/json, so req.body ends up empty or a raw string. Always set the header; a mismatched or missing Content-Type is a very common 'why is my body undefined?' bug.
Real World
This is the backbone of virtually every web/mobile app: the client GETs JSON to render, POSTs JSON forms, and the server returns JSON. The Content-Type/Accept headers are what make the exchange unambiguous.
Interviewer's Expectation
Keywords they're listening for:
- JSON request & response bodies
- Content-Type: application/json
- Accept header
- server parses & returns JSON
- status code + body
Common Mistakes
- Omitting Content-Type: application/json
- Ignoring the Accept header
- Returning 200 for an error with an error body
Best Practices
- Always set Content-Type and Accept
- Return correct status codes with JSON bodies
- Keep request/response shapes documented
Follow-up Questions
- What's the difference between request and response JSON?
- Which status codes pair with JSON error bodies?
- How does content negotiation work?
Continue Learning with AI
Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.
Plain-language foundations
I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner. Topic: REST APIs (JSON) Interview question: "How is JSON used in REST APIs?" Please: 1. Explain the core idea in simple, plain language, using an everyday analogy. 2. Define any technical terms you use. 3. Walk through one small, concrete example. 4. Finish with a single sentence I can easily remember. Keep the tone friendly and assume I'm new to this topic.
Was this answer helpful?
Affiliate links
Tools for Your Developer Workspace
Equipment for a comfortable, productive setup.
As an Amazon Associate I earn from qualifying purchases.
- MonitorView on Amazon : BenQ EW2790U 27-inch Monitor (opens in a new tab)
BenQ EW2790U 27-inch Monitor
- LaptopView on Amazon : Acer Aspire One Laptop (opens in a new tab)
Acer Aspire One Laptop
- Office ChairView on Amazon : Wakefit Gravita Ergonomic Office Chair (opens in a new tab)
Wakefit Gravita Ergonomic Office Chair