判断字符串是否合法的json格式。
可用于API接口返回数据的判断。
import json def is_json(myjson): try: json.loads(myjson) except ValueError: return False return True