Interface Json.Schema

  • Enclosing class:

    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 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:

    • - a very well-written tutorial covering the whole standard
    • - online book, tutorial (Python/Ruby based)

    Borislav Iordanov
    • Method Detail

      • 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.

        document - The input document.
        {"ok":true} or {"ok":false, errors:["msg1", "msg2", ...]}
      • toJson

        Json toJson()

        Return the JSON representation of the schema.