def safe_loads(arg):
 try:
  loaded = json.loads(arg)
 except (TypeError, ValueError):
  loaded = arg
 return loaded

def safe_loads ( arg ) : try : loaded = json . loads ( arg ) except ( TypeError , ValueError ) : loaded = arg return loaded
this is a wrapper around loads that returns the parsed value instead of raising a value error .