quick-schema: Slimmed down json schema language and validator

[ data, json, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Dependencies aeson, base (>=4.8 && <4.9), hashable, scientific, text, unordered-containers, vector [details]
License MIT
Copyright (c) 2015 Ben Weitzman
Author Ben Weitzman
Maintainer benweitzman@gmail.com
Category Data, JSON
Home page https://github.com/benweitzman/quick-schema
Bug tracker https://github.com/benweitzman/quick-schema/issues
Source repo head: git clone https://github.com/benweitzman/quick-schema.git
Uploaded by benweitzman at 2015-11-03T03:35:26Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 984 total (2 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for quick-schema-0.1.0.0

[back to package description]

quick-schema

Slimmed down json schema language and validator

Build Status Coverage Status

quick-schema defines a format for describe a restricted set of JSON document structures. It is represented in JSON and has the added benefit that a JSON document can be it's own be it's own schema.

quick-schema infers the structure of a JSON document by looking at the types of an example document. Consider the document

{
  "age": 25,
  "name": "Ben"
}

When interpreted with quick-schema, this document describes a schema that expects a top level object with two keys, one named age that should have a number value and one named name that should have a text value. The actual values of the keys are used only to determine the type and to give an example of intended use, but do not have a specific meaning here.

[
  {
    "age": 25,
    "name": "Ben"
  },
  {
    "street": "Prospect Street",
    "number": 54,
    "city": "Cambridge"
  }
]

Multiple values in lists in quick-schema give the possibility for having different subvalues. Every item in the value list must match one of the of the schemas in the schema list.

Optional values are specific by adding a ? to the end of a key, and exact values are specified by adding a =.

For example, we could encode a tagged union type:

[
  {
    "type=": "Person",
    "data":
      {
        "age": 25,
        "name": "Ben"
      }
  },
  {
    "type=": "Address",
    "data":
      {
        "street": "Prospect Street",
        "number": 54,
        "city": "Cambridge"
      }
  }
]