json.loads function and error handling
import json
def isJson(value):
try:
json.loads(value)
except ValueError:
return False
return True
print(isJson('{"name":"John"}'))
print(isJson('{0,1,3}'))
import json
def isJson(value):
try:
json.loads(value)
except ValueError:
return False
return True
print(isJson('{"name":"John"}'))
print(isJson('{0,1,3}'))
Leave a Comment
Cancel reply