Interface Json.Schema

Enclosing class:
Json

public static interface Json.Schema

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

    Modifier and Type
    Method
    Description
    Return the JSON representation of the schema.
    validate(Json document)
    Validate a JSON document according to this schema.
  • Method Details

    • validate

      Json validate(Json document)

      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 property ok. When ok is true, the return object contains nothing else. When it is false, the return object contains a property errors 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.