Home / Class/ ORJSONResponse Class — fastapi Architecture

ORJSONResponse Class — fastapi Architecture

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

Entity Profile

Dependency Diagram

graph TD
  f080f95d_ad17_d10d_e952_737f94a8b094["ORJSONResponse"]
  967b6712_70e2_f5fa_f671_7c149857a445["responses.py"]
  f080f95d_ad17_d10d_e952_737f94a8b094 -->|defined in| 967b6712_70e2_f5fa_f671_7c149857a445
  ffa42a64_03e9_c384_b847_9de3ef417b38["render()"]
  f080f95d_ad17_d10d_e952_737f94a8b094 -->|method| ffa42a64_03e9_c384_b847_9de3ef417b38

Relationship Graph

Source Code

fastapi/responses.py lines 36–48

class ORJSONResponse(JSONResponse):
    """
    JSON response using the high-performance orjson 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 orjson is not None, "orjson must be installed to use ORJSONResponse"
        return orjson.dumps(
            content, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_SERIALIZE_NUMPY
        )

Domain

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free