Interface Json.Schema
- Enclosing class:
Json
Represents JSON schema - a specific data format that a JSON entity must follow. The idea of a JSON schema is very similar to XML. Its main purpose is validating input.
More information about the various JSON schema specifications can be found at http://json-schema.org. JSON Schema is an IETF draft (v4 currently) and our implementation follows this set of specifications. A JSON schema is specified as a JSON object that contains keywords defined by the specification. Here are a few introductory materials:
- http://jsonary.com/documentation/json-schema/ - a very well-written tutorial covering the whole standard
- http://spacetelescope.github.io/understanding-json-schema/ - online book, tutorial (Python/Ruby based)
- Author:
- Borislav Iordanov
-
Method Summary
-
Method Details
-
validate
Validate a JSON document according to this schema. The validations attempts to proceed even in the face of errors. The return value is always a
Json.object
containing the boolean propertyok
. Whenok
istrue
, the return object contains nothing else. When it isfalse
, the return object contains a propertyerrors
which is an array of error messages for all detected schema violations.- Parameters:
document
- The input document.- Returns:
{"ok":true}
or{"ok":false, errors:["msg1", "msg2", ...]}
-
toJson
Json toJson()Return the JSON representation of the schema.
-