def _decode(self, o):
if isinstance(o, dict):
if len(o) == 1:
if "$escape" in o:
return self._decode_escaped(o['$escape'])
if "$date" in o:
return datetime.fromtimestamp(o["$date"] / 1000.0, timezone.utc)
if "$binary" in o:
return b64decode(o['$binary'])
if len(o) == 2 and "$type" in o and "$value" in o:
try:
reviver = self.custom_type_hooks[o['$type']]
except KeyError:
raise UnknownTypeError(o["$type"])
return reviver(o["$value"])
if self.object_pairs_hook is not None:
return self.object_pairs_hook((k, self._decode(v)) for k, v in o.items())
return {k: self._decode(v) for k, v in o.items()}
if isinstance(o, (list, tuple)):
return [self._decode(v) for v in o]
return o
__init__.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录