Created
May 2, 2017 21:00
-
-
Save arttuladhar/56ac510d08219256edb15e38537c5e32 to your computer and use it in GitHub Desktop.
Checks Valid JSON in a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
import os | |
import json | |
script_dir = '.' | |
valid_json = 0 | |
invalid_json = 0 | |
for root, dirs, files in os.walk(script_dir): | |
for file in files: | |
if file.endswith(".json"): | |
with open(file) as f: | |
try: | |
out = json.load(f) | |
print "Valid JSON ", file | |
valid_json = valid_json + 1 | |
except: | |
print "Invalid JSON ", file | |
invalid_json = invalid_json + 1 | |
pass | |
print "Valid JSON - ", valid_json | |
print "Invalid JSON - ", invalid_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment