Request JSON vs Response JSON β Interview Questions
β‘ Short Answer
Request JSON is the payload the client sends (the input the user controls); response JSON is what the server returns (the result). Their shapes usually differ: a request shouldn't include server-generated fields (id, createdAt, computed totals), and a response often adds them plus metadata. Modeling them as separate DTOs keeps inputs safe and outputs rich.
βCoffee Chat Question
Concept Made Simple
βWhat is the difference between request JSON and response JSON?β
π§ Mind Map Answer
Remember It Faster
β¨οΈHands-on Keyboard
Learn by Doing
// Request (create a user) β no id/createdAt
{ "name": "Guru", "email": "guru@example.com" }
// Response β server-generated fields added
{ "id": 101, "name": "Guru", "email": "guru@example.com",
"createdAt": "2026-08-01T09:00:00Z" }π₯What If?
Think Beyond the Expected
Why shouldn't the client be allowed to send fields like id, role, or isAdmin in the request?
Because inputs are attacker-controllable. If the server blindly binds request JSON onto its entity ('mass assignment'), a user could set isAdmin=true or overwrite someone else's id. Use a request DTO with an explicit allow-list of fields, and let the server own generated/privileged fields.
πReal World
Separate request/response DTOs are standard in Spring, NestJS, etc. β the request DTO validates and allow-lists user input; the response DTO shapes output (hiding internals like password hashes). Conflating them causes mass-assignment vulnerabilities.
π―Interviewer's Expectation
Keywords they're listening for:
β οΈCommon Mistakes
- βBinding request JSON directly onto entities
- βLetting clients set privileged fields
- βLeaking internal fields in responses
β Best Practices
- βUse separate, allow-listed request DTOs
- βShape responses to hide internals
- βValidate every request payload
πFollow-up Questions
- 1What is a mass-assignment vulnerability?
- 2Why hide fields like password hashes in responses?
- 3How do request/response schemas appear in OpenAPI?
π§©Related Technologies
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: "What is the difference between request JSON and response JSON?" 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?
β Featured Products
Support our platform by exploring our recommended products.
As an Amazon affiliate, purchases through these links may earn us a small commission β at no extra cost to you. It helps keep Full Stack Interview Guru free.