Although not widely accepted (yet?), There is a draft standard for the JSON scheme . I just study it myself, but you can write a circuit for your two-dimensional array (wrapped inside an object) as follows:
{ "description":"Two dimensional array of numbers", "type":"object", "properties":{ "two-d-array":{ "description":"columns", "type":"array", "items":{ "description":"rows", "type":"array", "items": { "description":"values", "type":"number", "minimum":-1, "maximum":Number.MAX_VALUE } } } } }
or simply:
{ "type":"array", "items":{ "type":"array", "items": { "type":"number", "minimum":-1, "maximum":Number.MAX_VALUE } } }
There is no CoffeeScript implementation that I know of, but there is a list of several JavaScript validators here . I play with what the authors of the specs (quite simply) json-schema wrote, and I like it well enough, calling it from CoffeeScript.
Larry maccherone
source share