RawDeserializer Class

Inheritance
RawDeserializer

Constructor

RawDeserializer()

Methods

deserialize_from_http_generics

Deserialize from HTTP response.

Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type"

deserialize_from_text

Decode data according to content-type.

Accept a stream of data as well, but will be load at once in memory for now.

If no content-type, will return the string version (not bytes, not stream)

on_response

Extract data from the body of a REST response object.

This will load the entire payload in memory.

Will follow Content-Type to parse. We assume everything is UTF8 (BOM acceptable).

deserialize_from_http_generics

Deserialize from HTTP response.

Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type"

deserialize_from_http_generics(body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any

Parameters

cls
Required
body_bytes
Required
headers
Required

deserialize_from_text

Decode data according to content-type.

Accept a stream of data as well, but will be load at once in memory for now.

If no content-type, will return the string version (not bytes, not stream)

deserialize_from_text(data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any

Parameters

data
str or bytes or <xref:IO>
Required

Input, could be bytes or stream (will be decoded with UTF8) or text

content_type
str
Required

The content type.

content_type
default value: None

on_response

Extract data from the body of a REST response object.

This will load the entire payload in memory.

Will follow Content-Type to parse. We assume everything is UTF8 (BOM acceptable).

on_response(request: Request, response: Response, **kwargs: Any) -> None

Parameters

raw_data
Required

Data to be processed.

content_type
Required

How to parse if raw_data is a string/bytes.

Exceptions

JSONDecodeError

If JSON is requested and parsing is impossible.

If bytes is not UTF8

If bytes is not valid XML

Attributes

CONTEXT_NAME

CONTEXT_NAME = 'deserialized_data'

JSON_REGEXP

JSON_REGEXP = re.compile('^(application|text)/([a-z+.]+\\+)?json$')