more generic validate-json.py
This commit is contained in:
parent
af1fc945e2
commit
a0ddd1f15b
|
@ -1,7 +1,28 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import json
|
||||
import argparse
|
||||
|
||||
with open ('config/panfwservices1.txt', 'r') as f:
|
||||
# Parse all arguments
|
||||
parser = argparse.ArgumentParser(description="Push JSON connfig to AlkirAPI")
|
||||
parser.add_argument("-f", "--file", type=str, help="location of the JSON connector files")
|
||||
parser.add_argument("-p", "--pretty", help="make the JSON pretty!", action="store_true")
|
||||
if len(sys.argv)==1:
|
||||
parser.print_help(sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
args = parser.parse_args()
|
||||
json_file = args.file
|
||||
|
||||
except argparse.ArgumentError as e:
|
||||
print(str(e))
|
||||
sys.exit()
|
||||
|
||||
with open (json_file, 'r') as f:
|
||||
body = json.load(f)
|
||||
print(body)
|
||||
if args.pretty:
|
||||
print(json.dumps(body, indent=4))
|
||||
else:
|
||||
print(body)
|
||||
|
|
Loading…
Reference in New Issue