mantelo.internal.serializers#
Classes#
Abstract base class for all serializers. |
|
A serializer for JSON data. |
Module Contents#
- class mantelo.internal.serializers.BaseSerializer#
Bases:
abc.ABCAbstract base class for all serializers.
- property content_type: str | None#
Default content-type for this serializer.
- property supported_content_types: list[str]#
- Abstractmethod:
Get all the content types this serializer can handle.
- Returns:
A list of supported content types.
- Return type:
list
- matches_content_type(content_type: str) bool#
Check if the given content type is supported by this serializer.
- Parameters:
content_type – The content type to match.
- Returns:
True if the content type is supported, False otherwise.
- abstractmethod loads(data: str) dict#
Deserialize a string into a dictionary.
- Parameters:
data – The string to deserialize.
- Returns:
The deserialized dictionary.
- Return type:
dict
- abstractmethod dumps(data: dict) str#
Serialize a dictionary into a string.
- Parameters:
data – The dictionary to serialize.
- Returns:
The serialized string.
- Return type:
str
- class mantelo.internal.serializers.JsonSerializer#
Bases:
BaseSerializerA serializer for JSON data.
- property supported_content_types: list[str]#
Get all the content types this serializer can handle.
- Returns:
A list of supported content types.
- Return type:
list
- loads(data: str) dict#
Deserialize a string into a dictionary.
- Parameters:
data – The string to deserialize.
- Returns:
The deserialized dictionary.
- Return type:
dict
- dumps(data: dict) str#
Serialize a dictionary into a string.
- Parameters:
data – The dictionary to serialize.
- Returns:
The serialized string.
- Return type:
str