🗑️ Deprecate ORJSONResponse and UJSONResponse (#14964)

This commit is contained in:
Sebastián Ramírez
2026-02-22 08:34:59 -08:00
committed by GitHub
parent 2e62fb1513
commit 48e9835732
8 changed files with 165 additions and 21 deletions

View File

@@ -22,7 +22,13 @@ from fastapi.responses import (
## FastAPI Responses
There are a couple of custom FastAPI response classes, you can use them to optimize JSON performance.
There were a couple of custom FastAPI response classes that were intended to optimize JSON performance.
However, they are now deprecated as you will now get better performance by using a [Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/).
That way, Pydantic will serialize the data into JSON bytes on the Rust side, which will achieve better performance than these custom JSON responses.
Read more about it in [Custom Response - HTML, Stream, File, others - `orjson` or Response Model](https://fastapi.tiangolo.com/advanced/custom-response/#orjson-or-response-model).
::: fastapi.responses.UJSONResponse
options: