class documentation

class TaggedJSONSerializer:

View In Hierarchy

Serializer that uses a tag system to compactly represent objects that are not JSON types. Passed as the intermediate serializer to itsdangerous.Serializer.

The following extra types are supported:

  • dict
  • tuple
  • bytes
  • ~markupsafe.Markup
  • ~uuid.UUID
  • ~datetime.datetime
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 default​_tags Undocumented
Method __init__ Undocumented
Class Variable __slots__ Undocumented
Instance Variable order Undocumented
Instance Variable tags Undocumented
def dumps(self, value):
Tag the value and dump it to a compact JSON string.
Parameters
value:t.AnyUndocumented
Returns
strUndocumented
def loads(self, value):
Load data from a JSON string and deserialized any tagged objects.
Parameters
value:strUndocumented
Returns
t.AnyUndocumented
def register(self, tag_class, force=False, index=None):
Register a new tag with this serializer.
Parameters
tag​_class:t.Type[JSONTag]tag class to register. Will be instantiated with this serializer instance.
force:booloverwrite an existing tag. If false (default), a KeyError is raised.
index:t.Optional[int]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.
Raises
KeyErrorif the tag key is already registered and force is not true.
def tag(self, value):
Convert a value to a tagged representation if necessary.
Parameters
value:t.AnyUndocumented
Returns
t.Dict[str, t.Any]Undocumented
def untag(self, value):
Convert a tagged representation back to the original type.
Parameters
value:t.Dict[str, t.Any]Undocumented
Returns
t.AnyUndocumented
default_tags =

Undocumented

def __init__(self):

Undocumented

__slots__: tuple[str, ...] =

Undocumented

order: t.List[JSONTag] =

Undocumented

tags: t.Dict[str, JSONTag] =

Undocumented