Example #1
0
def main(jsonFile, orderlyFile):
  orderlydoc = open(orderlyFile).read();
  jsondoc = open(jsonFile).read();

  try:
    orderlyjson.validate(json.loads(jsondoc), orderlydoc);
    print "OK";
    return 0;

  except Exception as exc:
    print "Validation FAILED";
    print exc;
    return -1;
Example #2
0
def test():
    example_orderly = """
    object {
        string name;
        string description?;
        string homepage /^http:/;
        integer {1500,3000} invented;
    }*;
    """
    example_json = """
    {
        "name": "orderly",
        "description": "A schema language for JSON",
        "homepage": "http://orderly-json.org",
        "invented": 2009
    }
    """
    example_json = json.loads(example_json)
    schema = parse(example_orderly)
    validate(example_json, schema)