I have a string in Python, I want to know if it is valid JSON.
json.loads(mystring)
will raise an error if the string is not JSON but I don't want to catch an exception.
I want something like this, but it doesn't work:
if type(mysrting) == dict:
myStrAfterLoading = json.loads(mystring)
else:
print "invalid json passed"
Do I have to catch that ValueError to see if my string is JSON?