1 # -*- coding: utf-8 -*-
5 from jsonschema import validate, ValidationError, SchemaError
6 from simplejson import load
9 class JsonValidatorLibrary(object):
15 def validate(schema_path, json_path):
16 logging.info("Schema path: " + schema_path)
17 logging.info("JSON path: " + json_path)
21 schema = load(open(schema_path, 'r'))
22 data = load(open(json_path, 'r'))
23 except (IOError, ValueError, OSError) as e:
24 logging.error(e.message)
28 validate(data, schema)
29 except (ValidationError, SchemaError) as e:
30 logging.error(e.message)
33 # logger.log("JSON validation successful")
34 print("JSON validation successful")
38 if __name__ == '__main__':
39 lib = JsonValidatorLibrary()
40 # sys.exit(JsonValidatorLibrary().validate(sys.argv[1], sys.argv[2]))