OXIESEC PANEL
- Current Dir:
/
/
opt
/
alt
/
python37
/
lib
/
python3.7
/
site-packages
/
jsons
/
deserializers
Server IP: 2a02:4780:11:1084:0:327f:3464:10
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
03/16/2023 12:57:19 PM
rwxr-xr-x
📄
__init__.py
197 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📁
__pycache__
-
03/16/2023 12:57:19 PM
rwxr-xr-x
📄
default_complex.py
1.17 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_date.py
556 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_datetime.py
881 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_decimal.py
586 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_defaultdict.py
980 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_dict.py
3.02 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_enum.py
1.24 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_iterable.py
1.16 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_list.py
2.41 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_mapping.py
947 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_nonetype.py
626 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_object.py
7.83 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_path.py
411 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_primitive.py
802 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_string.py
973 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_time.py
556 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_timedelta.py
463 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_timezone.py
535 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_tuple.py
3.45 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_union.py
1.26 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_uuid.py
535 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
default_zone_info.py
379 bytes
03/16/2023 12:57:19 PM
rw-r--r--
Editing: default_union.py
Close
from typing import Union from jsons._common_impl import get_class_name from jsons._compatibility_impl import get_union_params from jsons._load_impl import load from jsons.exceptions import JsonsError, DeserializationError def default_union_deserializer(obj: object, cls: Union, **kwargs) -> object: """ Deserialize an object to any matching type of the given union. The first successful deserialization is returned. :param obj: The object that needs deserializing. :param cls: The Union type with a generic (e.g. Union[str, int]). :param kwargs: Any keyword arguments that are passed through the deserialization process. :return: An object of the first type of the Union that could be deserialized successfully. """ for sub_type in get_union_params(cls): try: return load(obj, sub_type, **kwargs) except JsonsError: pass # Try the next one. else: args_msg = ', '.join([get_class_name(cls_) for cls_ in get_union_params(cls)]) err_msg = ('Could not match the object of type "{}" to any type of ' 'the Union: {}'.format(type(obj).__name__, args_msg)) raise DeserializationError(err_msg, obj, cls)