def deserialize(data):
if isinstance(data, IOBase):
try:
data.seek(0)
except UnsupportedOperation:
pass
if hasattr(data, 'readall'):
data = data.readall()
else:
data = data.read()
if isinstance(data, bytes):
data = str(data, encoding='utf-8')
if isinstance(data, str):
try:
data = json.loads(data, object_hook=collections.OrderedDict)
except json.JSONDecodeError as e:
data = yaml.load(data)
return data
评论列表
文章目录