import json
def decode(data, default={}):
try:
return json.loads(data)
except ValueError:
return default
foo = decode("bad")
foo['stuff'] = 5
bar = decode("very bad")
bar["meep"] = 1
print("foo", foo)
print("bar", bar)
To embed this project on your website, copy the following code and paste it into your website's HTML: