MediumπŸ‘€ 3-5 yearsπŸ‘€ 8-15 years 1 min read

JSON Schema β€” Interview Questions

Asked inAmazonMicrosoftDeloitteAccenture
#json#json schema#validation#contract#openapi
Report issue

⚑ Short Answer

JSON Schema is a standard, itself written in JSON, that describes the expected structure of JSON data β€” types, required properties, formats, ranges, enums, and nested shapes. It's used to validate payloads, document and enforce API contracts, generate code/forms, and catch bad data automatically instead of with hand-written checks.

β˜•Coffee Chat Question

Concept Made Simple

β€œWhat is JSON Schema and why is it useful?”

🧠Mind Map Answer

Remember It Faster

What→JSON that describes JSON
Declares→type, required, format, min/max, enum
Uses→validation, docs, contracts, codegen
Powers→OpenAPI request/response schemas

⌨️Hands-on Keyboard

Learn by Doing

json
{
  "type": "object",
  "required": ["name", "email"],
  "properties": {
    "name":  { "type": "string", "minLength": 1 },
    "email": { "type": "string", "format": "email" },
    "age":   { "type": "integer", "minimum": 0 }
  },
  "additionalProperties": false
}

πŸ”₯What If?

Think Beyond the Expected

What does "additionalProperties": false do, and why does it matter?

It rejects any property not listed in the schema. That's useful for security and strictness β€” it blocks unexpected/extra fields (helping prevent mass assignment and typos), so the payload must match the contract exactly. Leaving it true (the default) lets clients send arbitrary extra keys, which the validator will silently allow.

πŸ˜‚Real World

JSON Schema underpins OpenAPI/Swagger: request and response bodies are described with it, driving validation, interactive docs, mocking, and client SDK generation from one source of truth.

🎯Interviewer's Expectation

Keywords they're listening for:

βœ“ JSON describing JSONβœ“ type/required/format/constraintsβœ“ validation & contractsβœ“ additionalPropertiesβœ“ backs OpenAPI

⚠️Common Mistakes

  • βœ—Confusing JSON Schema with a JSON sample
  • βœ—Leaving additionalProperties open when strictness is needed
  • βœ—Duplicating schema logic in code instead of reusing it

βœ…Best Practices

  • βœ“Keep one schema as the source of truth
  • βœ“Use additionalProperties:false for strict inputs
  • βœ“Generate docs/clients from the schema

πŸ”Follow-up Questions

  • 1How does JSON Schema relate to OpenAPI?
  • 2What does additionalProperties control?
  • 3How do you validate against a schema at runtime?

🧩Related Technologies

OpenAPI/SwaggerAjvcodegencontracts

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: Schema (JSON)
Interview question: "What is JSON Schema and why is it useful?"

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?

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.

Related Questions