def decode(self, o):
"""
Decode the contents of the given JSON dictionary as an object used by Web Sight.
:param o: The JSON dictionary to process.
:return: The contents of the given JSON dictionary deserialized into an object.
"""
from lib.arin.response import BaseArinResponse
from ..geolocation import IpGeolocation
if "__class_type" not in o:
raise UnsupportedDeserializationError("No class type specified in JSON dictionary: %s" % o)
class_type = o["__class_type"]
deserialization_class = get_class_from_import_string(class_type)
if deserialization_class == PreparedRequest:
return self.__deserialize_requests_prepared_request(o)
elif deserialization_class == Response:
return self.__deserialize_requests_response(o)
elif issubclass(deserialization_class, BaseArinResponse):
return self.__deserialize_arin_response(o)
elif deserialization_class == IpGeolocation:
return self.__deserialize_ip_geolocation(o)
else:
raise UnsupportedDeserializationError(
"Class %s does not have a deserialization method."
% deserialization_class
)
评论列表
文章目录