Last active
September 26, 2016 21:54
-
-
Save hkasera/2175f7f2ccdbd9be26758e4429096d94 to your computer and use it in GitHub Desktop.
A python script to validate json data
This file contains hidden or 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
import sys | |
import json | |
myfile = sys.stdin | |
if myfile: | |
content = myfile.readlines() | |
for line in content: | |
try: | |
json.loads(line) | |
except Exception as e: | |
print "Invalid JSON" | |
exit() | |
myfile.close() | |
print "Valid JSON" | |
exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment