
A Haskell implementation of the current JSON Schema specification (Draft 4).
NOTE: You CANNOT use untrusted JSON data to make schemas. Schemas with circular references can cause infinite loops. See the issue list for more info.
Example
See here.
Tests
Run all tests:
stack test
Run only local tests:
stack test hjsonschema:local
Run remote tests (makes GETs to json-schema.org, also temporarily starts an HTTP server on port 1234):
stack test hjsonschema:remote
Details
Goals
-
Be a correct and fast implementation of the spec.
-
Be a useful reference for implementers in other languages. Haskell's high level nature, expressive type system and referential transparency suit this purpose well.
Good Parts
-
Passes all the tests in the language agnostic test suite.
-
Very modular, which should make it easy to support future versions of the specification.
Bad Parts
- Uses the pcre-heavy regular expression library for the "pattern" validator. It should use a library based on the ECMA 262 regex dialect, which the spec requires.
Notes
-
JSON-Schema-Test-Suiteis vendored from commit # aabcb3427745ade7a0b4d49ff016ad7eda8b898b here. -
src/draft4.jsonis from commit # cc8ec81ce0abe2385ebd6c2a6f2d6deb646f874a here.
Credits
TJ Weigel created the logo.
Tim Baumann wrote aeson-schema, on which hjsonschema's test code and its implementation of SchemaGraph were based.
Julian Berman maintains the fantastic language agnostic test suite.