File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ # encoding=utf-8
2
+
3
+ import argparse
4
+ import json
5
+
6
+ from jsonschema import validate
7
+
8
+ def main ():
9
+ parser = argparse .ArgumentParser (description = 'JSON Schema validator' )
10
+ parser .add_argument ('schema' , help = 'filename of the JSON Schema' )
11
+ parser .add_argument ('document' , help = 'filename of the JSON document to validate' )
12
+ args = parser .parse_args ()
13
+
14
+ schema = json .load (open (args .schema , 'r' ))
15
+ document = json .load (open (args .document , 'r' ))
16
+
17
+ validate (document , schema )
18
+ # validate raises if the document is invalid, and will show a Traceback to
19
+ # the user. If the document is valid, show a congratulating message.
20
+ print ("√ JSON document is valid." )
21
+
22
+ if __name__ == '__main__' :
23
+ main ()
Original file line number Diff line number Diff line change 36
36
license = "MIT" ,
37
37
long_description = long_description ,
38
38
url = "http://github.com/Julian/jsonschema" ,
39
+ entry_points = {
40
+ 'console_scripts' : ['jsonschema = jsonschema.cli:main' ]
41
+ }
39
42
)
You can’t perform that action at this time.
0 commit comments