- Forward


JSON Schema
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Review
Back SMYC Forward
  • JSON:
    • A syntax for describing hierarchical data
  • A Shortcoming:
    • A document can be syntactically correct but not contain the correct elements
Objectives
Back SMYC Forward
  • Impose Structure:
    • For validation, documentation and interaction control
  • Syntax:
    • Use JSON
Some Common Keywords and Allowed Values
Back SMYC Forward
  • "title"
    • A string
  • "type"
    • "null", "boolean", "object", "array", "number", or "string"
  • "required"
    • An array
  • "properties"
    • An object
  • "items"
    • A schema or array of schemas
An Example
Back SMYC Forward

A Schema for a Simple Person

jsonexamples/schema/person.jsonschema
 
Some Other Keywords
Back SMYC Forward
  • For Numbers:
    • maximum, minimum, multipleOf
  • For Strings:
    • maxLength, minLength, pattern
  • For Arrays:
    • items, maxItems, minItems, uniqueItems, contains
  • For Objects:
    • maxProperties, minProperties
There's Always More to Learn
Back -