{
    “Talk” :
      “JSON Validation
      using JSON Schema and
      Jackson”,

    “by” : “Stephane Rondal”
}
stephane.rondal@arexo.be
@stephanerondal
JSON
JSON
 • Very present in Web 2.0 and mobile apps
JSON
 • Very present in Web 2.0 and mobile apps
 • With REST, typically serves as the data exchange format
JSON
 • Very present in Web 2.0 and mobile apps
 • With REST, typically serves as the data exchange format
 • Sometimes even derived automatically from POJOs
JSON
 • Very present in Web 2.0 and mobile apps
 • With REST, typically serves as the data exchange format
 • Sometimes even derived automatically from POJOs
 • Part of the interface between client and server
JSON
 • Very present in Web 2.0 and mobile apps
 • With REST, typically serves as the data exchange format
 • Sometimes even derived automatically from POJOs
 • Part of the interface between client and server
 • Stability / Backward-compatibility??
JSON
 • Very present in Web 2.0 and mobile apps
 • With REST, typically serves as the data exchange format
 • Sometimes even derived automatically from POJOs
 • Part of the interface between client and server
 • Stability / Backward-compatibility??
JSON Schema
JSON Schema


Represents the structure of a JSON document
Much like XML Schema does for XML documents
n’t r un
         a it, do
 X ML ?W          t!
          ay   ye
       aw
Much like XML Schema does for XML documents
Keeping the simple and
lightweight aspects of JSON we
          have all come to love
JSON Schema
JSON Schema
 • A schema is a JSON document
JSON Schema
 • A schema is a JSON document
 • Specifies
   •   Properties
       •Type (simple, complex)
       •Required/Optional
       •Simple constraints
   •   And more...
{

   "description": "An Address following the convention ...",

   "type":"object",

   "properties": {

   
 "post-office-box": { "type": "string" },

   
 "extended-address": { "type": "string" },

   
 "street-address": { "type": "string" },

   
 "locality":{ "type": "string", "required": true },

   
 "region": { "type": "string", "required": true },

   
 "postal-code": { "type": "string" },

   
 "country-name": { "type": "string", "required": true}

   },

   "dependencies": {

   
 "post-office-box": "street-address",

   
 "extended-address": "street-address"

   }
}
An IETF draft standard (3rd version)
Why
   use
  JSON
Schema ?
Documentation
Automation
Code / UI Generation
Or Why Not ?
Demo
References
 • www.json.org
 • json-schema.org
 • tools.ietf.org/html/draft-zyp-json-schema-03
 • github.com/fge/json-schema-validator
Q&A

Devoxx - JSON Validation using JSON Schema and Jackson

  • 1.
    { “Talk” : “JSON Validation using JSON Schema and Jackson”, “by” : “Stephane Rondal” }
  • 2.
  • 3.
  • 4.
    JSON • Verypresent in Web 2.0 and mobile apps
  • 5.
    JSON • Verypresent in Web 2.0 and mobile apps • With REST, typically serves as the data exchange format
  • 6.
    JSON • Verypresent in Web 2.0 and mobile apps • With REST, typically serves as the data exchange format • Sometimes even derived automatically from POJOs
  • 7.
    JSON • Verypresent in Web 2.0 and mobile apps • With REST, typically serves as the data exchange format • Sometimes even derived automatically from POJOs • Part of the interface between client and server
  • 8.
    JSON • Verypresent in Web 2.0 and mobile apps • With REST, typically serves as the data exchange format • Sometimes even derived automatically from POJOs • Part of the interface between client and server • Stability / Backward-compatibility??
  • 9.
    JSON • Verypresent in Web 2.0 and mobile apps • With REST, typically serves as the data exchange format • Sometimes even derived automatically from POJOs • Part of the interface between client and server • Stability / Backward-compatibility??
  • 10.
  • 11.
    JSON Schema Represents thestructure of a JSON document
  • 12.
    Much like XMLSchema does for XML documents
  • 13.
    n’t r un a it, do X ML ?W t! ay ye aw Much like XML Schema does for XML documents
  • 14.
    Keeping the simpleand lightweight aspects of JSON we have all come to love
  • 15.
  • 16.
    JSON Schema •A schema is a JSON document
  • 17.
    JSON Schema •A schema is a JSON document • Specifies • Properties •Type (simple, complex) •Required/Optional •Simple constraints • And more...
  • 18.
    { "description": "An Address following the convention ...", "type":"object", "properties": { "post-office-box": { "type": "string" }, "extended-address": { "type": "string" }, "street-address": { "type": "string" }, "locality":{ "type": "string", "required": true }, "region": { "type": "string", "required": true }, "postal-code": { "type": "string" }, "country-name": { "type": "string", "required": true} }, "dependencies": { "post-office-box": "street-address", "extended-address": "street-address" } }
  • 19.
    An IETF draftstandard (3rd version)
  • 20.
    Why use JSON Schema ?
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
    References • www.json.org • json-schema.org • tools.ietf.org/html/draft-zyp-json-schema-03 • github.com/fge/json-schema-validator
  • 28.