class documentation

class TaggedJSONSerializer: (source)

View In Hierarchy

Serializer that uses a tag system to compactly represent objects that are not JSON types. Passed as the intermediate serializer to :class:`itsdangerous.Serializer`. The following extra types are supported: * :class:`dict` * :class:`tuple` * :class:`bytes` * :class:`~markupsafe.Markup` * :class:`~uuid.UUID` * :class:`~datetime.datetime`

Method __init__ Undocumented
Method dumps Tag the value and dump it to a compact JSON string.
Method loads Load data from a JSON string and deserialized any tagged objects.
Method register Register a new tag with this serializer.
Method tag Convert a value to a tagged representation if necessary.
Method untag Convert a tagged representation back to the original type.
Class Variable __slots__ Undocumented
Class Variable default_tags Undocumented
Instance Variable order Undocumented
Instance Variable tags Undocumented
def __init__(self): (source)

Undocumented

def dumps(self, value: t.Any) -> str: (source)

Tag the value and dump it to a compact JSON string.

def loads(self, value: str) -> t.Any: (source)

Load data from a JSON string and deserialized any tagged objects.

def register(self, tag_class: t.Type[JSONTag], force: bool = False, index: t.Optional[int] = None): (source)

Register a new tag with this serializer. :param tag_class: tag class to register. Will be instantiated with this serializer instance. :param force: overwrite an existing tag. If false (default), a :exc:`KeyError` is raised. :param index: index to insert the new tag in the tag order. Useful when the new tag is a special case of an existing tag. If ``None`` (default), the tag is appended to the end of the order. :raise KeyError: if the tag key is already registered and ``force`` is not true.

def tag(self, value: t.Any) -> t.Dict[str, t.Any]: (source)

Convert a value to a tagged representation if necessary.

def untag(self, value: t.Dict[str, t.Any]) -> t.Any: (source)

Convert a tagged representation back to the original type.

__slots__: tuple[str, ...] = (source)

Undocumented

default_tags = (source)

Undocumented

Undocumented

Undocumented