Orderly JSON

Posted on 13 Jan 2010. in links javascript

Orderly JSON is to JSON schema what RelaxNG is to XML Schema. This orderly:

    object {
        string name;
        string description?;
        string homepage /^http:/;
        integer {1500,3000} invented;
    }*;

… describes this JSON:

    {
        "name": "orderly",
        "description": "A schema language for JSON",
        "homepage": "http://orderly-json.org",
        "invented": 2009
    }

… and compiles into JSON schema:

    {
        "type": "object",
        "properties": {
            "name": {
                "type": "string"
            },
            "description": {
                "type": "string",
                "optional": true
            },
            "homepage": {
                "type": "string",
                "pattern": "^http:"
            },
            "invented": {
                "type": "integer",
                "minimum": 1500,
                "maximum": 3000
            }
        },
        "additionalProperties": true
    }