MyNixOS website logo
Description

Slimmed down json schema language and validator.

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"
      }
  }
]
Metadata

Version

0.1.0.0

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows