Home / Class/ UJSONResponse Class — fastapi Architecture

UJSONResponse Class — fastapi Architecture

Architecture documentation for the UJSONResponse class in responses.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  a8fbd6e3_8bef_2a08_d7f5_9da4c2a41523["UJSONResponse"]
  967b6712_70e2_f5fa_f671_7c149857a445["responses.py"]
  a8fbd6e3_8bef_2a08_d7f5_9da4c2a41523 -->|defined in| 967b6712_70e2_f5fa_f671_7c149857a445
  1c4dcd3e_2196_ddb0_873c_81a342e13007["render()"]
  a8fbd6e3_8bef_2a08_d7f5_9da4c2a41523 -->|method| 1c4dcd3e_2196_ddb0_873c_81a342e13007

Relationship Graph

Source Code

fastapi/responses.py lines 23–33

class UJSONResponse(JSONResponse):
    """
    JSON response using the high-performance ujson library to serialize data to JSON.

    Read more about it in the
    [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).
    """

    def render(self, content: Any) -> bytes:
        assert ujson is not None, "ujson must be installed to use UJSONResponse"
        return ujson.dumps(content, ensure_ascii=False).encode("utf-8")

Domain

Frequently Asked Questions

What is the UJSONResponse class?
UJSONResponse is a class in the fastapi codebase, defined in fastapi/responses.py.
Where is UJSONResponse defined?
UJSONResponse is defined in fastapi/responses.py at line 23.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free