Skip to content

Instantly share code, notes, and snippets.

@hkasera
Last active September 26, 2016 21:54
Show Gist options
  • Save hkasera/2175f7f2ccdbd9be26758e4429096d94 to your computer and use it in GitHub Desktop.
Save hkasera/2175f7f2ccdbd9be26758e4429096d94 to your computer and use it in GitHub Desktop.
A python script to validate json data
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