serialization#
- litestar.serialization.default_deserializer(target_type: Any, value: Any, type_decoders: TypeDecodersSequence | None = None) Any #
Transform values non-natively supported by
msgspec
- litestar.serialization.decode_json(value: str | bytes, target_type: type[T] | EmptyType = _EmptyEnum.EMPTY, type_decoders: TypeDecodersSequence | None = None, strict: bool = True) Any #
Decode a JSON string/bytes into an object.
- Parameters:
- Returns:
An object
- Raises:
SerializationException – If error decoding
value
.
- litestar.serialization.decode_msgpack(value: bytes, target_type: type[T] | EmptyType = _EmptyEnum.EMPTY, type_decoders: TypeDecodersSequence | None = None, strict: bool = True) Any #
Decode a MessagePack string/bytes into an object.
- Parameters:
- Returns:
An object
- Raises:
SerializationException – If error decoding
value
.
- litestar.serialization.default_serializer(value: Any, type_encoders: Mapping[Any, Callable[[Any], Any]] | None = None) Any #
Transform values non-natively supported by
msgspec
- litestar.serialization.encode_json(value: Any, serializer: Callable[[Any], Any] | None = None) bytes #
Encode a value into JSON.
- Parameters:
- Returns:
JSON as bytes
- Raises:
SerializationException – If error encoding
obj
.
- litestar.serialization.encode_msgpack(value: ~typing.Any, serializer: ~typing.Callable[[~typing.Any], ~typing.Any] | None = <function default_serializer>) bytes #
Encode a value into MessagePack.
- Parameters:
- Returns:
MessagePack as bytes
- Raises:
SerializationException – If error encoding
obj
.
- litestar.serialization.get_serializer(type_encoders: TypeEncodersMap | None = None) Serializer #
Get the serializer for the given type encoders.