Search

4/08/2009

JSON Schema

JSON Schema Proposal

JSON Schema is a specification for a JSON-based format for defining the structure of JSON data. JSON Schema provides a contract for what JSON data is required for a given application and how it can be modified, much like what XML Schema provides for XML. JSON Schema is intended to provide validation, documentation, and interaction control of JSON data. JSON Schema is based on the concepts from XML Schema, RelaxNG, and Kwalify, but is intended to be JSON-based, so that JSON data in the form of a schema can be used to validate JSON data, the same serialization/deserialization tools can be used for the schema and data, and it can be self descriptive.

SitePen Blog » JSON Schema in Dojo

dojo.require("dojox.json.schema");
schema = {
type:"object",
properties:{
name:{type:"string"},
age:{type:"number"}
}
};
instance = {
name:"Kris",
age:31
};
results = dojox.json.schema.validate(instance, schema);

沒有留言: