Skip to main content

load_str_bytes

Loads and deserializes data from a string or bytes object using a specified protocol, such as JSON or pickle, based on the provided content type or protocol argument.

def load_str_bytes(
b: str | bytes,
content_type: str | None = None,
encoding: str = 'utf8',
proto: Protocol | None = None,
allow_pickle: bool = False,
json_loads: Callable[[str], Any] = json.loads
) - > Any

load_str_bytes is deprecated.

Parameters

NameTypeDescription
b`strbytes`
content_type`strNone` = None
encodingstr = 'utf8'The character encoding used to decode byte input when processing JSON data.
proto`ProtocolNone` = None
allow_picklebool = FalseA security flag that must be set to True to enable unpickling of data.
json_loadsCallable[[str], Any] = json.loadsThe specific JSON loading function used to parse string data.

Returns

TypeDescription
AnyThe deserialized object parsed from the input string or bytes using the specified protocol.