ESSAY / NOTE

python判断是不是json数据,防止报错跳出

def is_json(myjson):
try:
json_object = json.loads(myjson)
except ValueError, e:
return False
return True

if is_json(response.text) and len(response.text) > 50:
jsonobj = json.loads(response.text)