JSON Schema Document

Posted by on November 7, 2012

JSON Schema = A JSON Media Type for Describing the Structure and Meaning of JSON Documents

A standard which provides a coherent schema by which to validate a JSON data against.

JSON (JavaScript Object Notation) Schema defines the media type “application/schema json”, a JSON based format for defining the structure of JSON data, providing a contract for what JSON data is required for a given application and how to interact with it.

JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data.

Having a JSON Schema Document  is something very useful, because right now, is a mess when you try to consume JSON data or publish an API to clients.

Why ? Because you don’t know the correct structure,types and all possibilities of a JSON Document.

I mean, having a JSON like this:


  1. “address”:{
  2. “streetAddress”: “21 2nd Street”,
  3. “city”:”New York”
  4. },
  5. “phoneNumber”:
  6. [
  7. {
  8. “type”:”home”,
  9. “number”:”212 555-1234”
  10. }
  11. ] 13.}

Seems correct right ? Yeah! Sure!

But, you don’t know:

  • Required/mandatory items: so you dont know whats is missing.
  • Item types: The value received will be a String, Integer,Float,Double,Decimal,Currenty,etc ? will be another Item ?
  • Item size/length: The value will be 5 chars max? 3 minimum?
  • Item structure: This item will be a complex one, having nested structures?
  • Items data constraint/format: Item just accept 5 chars but for a specify pattern, or specific values from a list(constants), will be a string but just accepting data in Date format like dd/MM/yyyy
  • Item Arrays: How many elements ? just 1?  max 5? min 2? 
  • etc :D

Do you understand what i mean ?


Read more about JSON Schema at : 

Tip: JSON Schema means for JSON data what XML Schema (XSD) means for XML data.

_ _