Custom JSON Response

class MsgSpecJSONResponse(content: Any, status_code: int = 200, headers: Mapping[str, str] | None = None, media_type: str = 'application/json', background: BackgroundTask | None = None)[source]

Bases: Response

High-performance JSON response using msgspec for serialization.

render(content: Any) bytes[source]

Serialize the content using the msgspec encoder.

Parameters:

content – The data to serialize.

Returns:

Serialized JSON content as bytes.

Return type:

bytes