deserializers

This module contains default deserializers. You can override the deserialization process of a particular type as follows:

jsons.set_deserializer(custom_deserializer, SomeClass)

Module Contents

Functions

default_datetime_deserializer(obj,_,**__) Deserialize a string with an RFC3339 pattern to a datetime instance.
default_list_deserializer(obj,cls,**kwargs) Deserialize a list by deserializing all items of that list.
default_tuple_deserializer(obj,cls,**kwargs) Deserialize a (JSON) list into a tuple by deserializing all items of that
default_dict_deserializer(obj,_,key_transformer=None,**kwargs) Deserialize a dict by deserializing all instances of that dict.
default_enum_deserializer(obj,cls,use_enum_name=True,**__) Deserialize an enum value to an enum instance. The serialized value must
default_string_deserializer(obj,_=None,**kwargs) Deserialize a string. If the given obj can be parsed to a date, a
default_primitive_deserializer(obj,_=None,**__) Deserialize a primitive: it simply returns the given primitive.
default_object_deserializer(obj,cls,key_transformer=None,**kwargs) Deserialize obj into an instance of type cls. If obj contains keys
default_datetime_deserializer(obj, _, **__)

Deserialize a string with an RFC3339 pattern to a datetime instance. :param obj: :param _: not used. :param __: not used. :return: a datetime.datetime instance.

default_list_deserializer(obj, cls, **kwargs)

Deserialize a list by deserializing all items of that list. :param obj: the list that needs deserializing. :param cls: the type with a generic (e.g. List[str]). :param kwargs: any keyword arguments. :return: a deserialized list instance.

default_tuple_deserializer(obj, cls, **kwargs)

Deserialize a (JSON) list into a tuple by deserializing all items of that list. :param obj: the list that needs deserializing. :param cls: the type with a generic (e.g. Tuple[str, int]). :param kwargs: any keyword arguments. :return: a deserialized tuple instance.

default_dict_deserializer(obj, _, key_transformer=None, **kwargs)

Deserialize a dict by deserializing all instances of that dict. :param obj: the dict that needs deserializing. :param key_transformer: a function that transforms the keys to a different style (e.g. PascalCase). :param cls: not used. :param kwargs: any keyword arguments. :return: a deserialized dict instance.

default_enum_deserializer(obj, cls, use_enum_name=True, **__)

Deserialize an enum value to an enum instance. The serialized value must can be the name of the enum element or the value; dependent on use_enum_name. :param obj: the serialized enum. :param cls: the enum class. :param use_enum_name: determines whether the name or the value of an enum element should be used. :param __: not used. :return: the corresponding enum element instance.

default_string_deserializer(obj, _=None, **kwargs)

Deserialize a string. If the given obj can be parsed to a date, a datetime instance is returned. :param obj: the string that is to be deserialized. :param _: not used. :param kwargs: any keyword arguments. :return: the deserialized obj.

default_primitive_deserializer(obj, _=None, **__)

Deserialize a primitive: it simply returns the given primitive. :param obj: the value that is to be deserialized. :param _: not used. :param __: not used. :return: obj.

default_object_deserializer(obj, cls, key_transformer=None, **kwargs)

Deserialize obj into an instance of type cls. If obj contains keys with a certain case style (e.g. camelCase) that do not match the style of cls (e.g. snake_case), a key_transformer should be used (e.g. KEY_TRANSFORMER_SNAKECASE). :param obj: a serialized instance of cls. :param cls: the type to which obj should be deserialized. :param key_transformer: a function that transforms the keys in order to match the attribute names of cls. :param kwargs: any keyword arguments that may be passed to the deserializers. :return: an instance of type cls.