Validate JSON object using a Schema Definition

There's a new library, json-gate, that does the trick. (Full disclosure: I am the author.)

It is similar to JSV and others, but it has several advantages:

  • It is fast*.
  • It produces human-friendly, detailed error messages - for both you and your customers.
  • Friendly, extensive documentation. Not only of the library but of JSON schema as well!
  • The schema is pre-validated. This allows you, the developer, to know right away if your schema definition is malformed. And it makes things run a little faster.

* It is not fast so much as JSV is incredibly slow. My test shows JSV to be 30 (!) times slower than json-gate. This result is consistent with Robert Schultz's tests, which compare JSV against other libraries.


There are few libraries, which validate data against JSON Schema....

  • Amanda
  • Revalidator
  • JSV
  • Schema.js

There's a working draft of a JSON schema. You could also take a look at Cerny.

Tags:

Json