Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 15 for jsonable_encoder (0.13 seconds)

  1. fastapi/encoders.py

            )
            return jsonable_encoder(
                obj_dict,
                exclude_none=exclude_none,
                exclude_defaults=exclude_defaults,
                sqlalchemy_safe=sqlalchemy_safe,
            )
        if dataclasses.is_dataclass(obj):
            assert not isinstance(obj, type)
            obj_dict = dataclasses.asdict(obj)
            return jsonable_encoder(
                obj_dict,
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 15 11:44:39 GMT 2026
    - 10.9K bytes
    - Click Count (0)
  2. fastapi/openapi/utils.py

                example = getattr(field_info, "example", None)
                if openapi_examples:
                    parameter["examples"] = jsonable_encoder(openapi_examples)
                elif example is not _Unset:
                    parameter["example"] = jsonable_encoder(example)
                if getattr(field_info, "deprecated", None):
                    parameter["deprecated"] = True
                parameters.append(parameter)
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 15 11:44:39 GMT 2026
    - 25.6K bytes
    - Click Count (0)
  3. docs/en/docs/advanced/custom-response.md

    If you declare a [Response Model](../tutorial/response-model.md) FastAPI will use it to serialize the data to JSON, using Pydantic.
    
    If you don't declare a response model, FastAPI will use the `jsonable_encoder` explained in [JSON Compatible Encoder](../tutorial/encoder.md) and put it in a `JSONResponse`.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 11K bytes
    - Click Count (0)
  4. fastapi/openapi/docs.py

    import json
    from typing import Annotated, Any
    
    from annotated_doc import Doc
    from fastapi.encoders import jsonable_encoder
    from starlette.responses import HTMLResponse
    
    
    def _html_safe_json(value: Any) -> str:
        """Serialize a value to JSON with HTML special characters escaped.
    
        This prevents injection when the JSON is embedded inside a <script> tag.
        """
        return (
            json.dumps(value)
            .replace("<", "\\u003c")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 24 09:28:10 GMT 2026
    - 12.1K bytes
    - Click Count (0)
  5. docs/zh-hant/docs/advanced/custom-response.md

    如果你沒有宣告回應模型,FastAPI 會使用在[JSON 相容編碼器](../tutorial/encoder.md)中解釋的 `jsonable_encoder`,並將結果放進 `JSONResponse`。
    
    如果你宣告的 `response_class` 具有 JSON 的 media type(`application/json`),像 `JSONResponse`,你回傳的資料會自動以你在「路徑操作裝飾器」中宣告的任何 Pydantic `response_model` 進行轉換(與過濾)。但資料不會由 Pydantic 直接序列化成 JSON 位元組;取而代之,會先經由 `jsonable_encoder` 轉換,然後交給 `JSONResponse` 類別,該類別會使用 Python 標準的 JSON 函式庫將其序列化為位元組。
    
    ### JSON 效能 { #json-performance }
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:05:38 GMT 2026
    - 10.3K bytes
    - Click Count (0)
  6. docs/de/docs/advanced/custom-response.md

    Wenn Sie ein [Responsemodell](../tutorial/response-model.md) deklarieren, verwendet FastAPI Pydantic, um die Daten zu JSON zu serialisieren.
    
    Wenn Sie kein Responsemodell deklarieren, verwendet FastAPI den `jsonable_encoder`, wie in [JSON-kompatibler Encoder](../tutorial/encoder.md) erklärt, und packt das Ergebnis in eine `JSONResponse`.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 17:58:09 GMT 2026
    - 12.5K bytes
    - Click Count (0)
  7. docs/tr/docs/advanced/custom-response.md

    Bir response modeli tanımlamazsanız, FastAPI [JSON Compatible Encoder](../tutorial/encoder.md) bölümünde açıklanan `jsonable_encoder`’ı kullanır ve sonucu bir `JSONResponse` içine koyar.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 07:53:17 GMT 2026
    - 11.9K bytes
    - Click Count (0)
  8. docs/zh/docs/advanced/custom-response.md

    如果你没有声明响应模型,FastAPI 会使用 [JSON 兼容编码器](../tutorial/encoder.md) 中解释的 `jsonable_encoder`,并把结果放进一个 `JSONResponse`。
    
    如果你在 `response_class` 中声明了一个 JSON 媒体类型(`application/json`)的类(比如 `JSONResponse`),你返回的数据会使用你在 *路径操作装饰器* 中声明的任意 Pydantic `response_model` 自动转换(和过滤)。但数据不会由 Pydantic 序列化为 JSON 字节;而是先用 `jsonable_encoder` 转换后传给 `JSONResponse`,由它使用 Python 标准 JSON 库序列化为字节。
    
    ### JSON 性能 { #json-performance }
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:06:37 GMT 2026
    - 10.4K bytes
    - Click Count (0)
  9. docs/ko/docs/advanced/custom-response.md

    응답 모델을 선언하지 않으면 FastAPI는 [JSON 호환 가능 인코더](../tutorial/encoder.md)에서 설명한 `jsonable_encoder`를 사용해 데이터를 변환한 뒤 `JSONResponse`에 넣습니다.
    
    `JSONResponse`처럼 JSON 미디어 타입(`application/json`)을 가진 `response_class`를 선언하면, 여러분이 *경로 처리 데코레이터*에서 선언한 Pydantic의 `response_model`로 데이터가 자동 변환(및 필터링)됩니다. 하지만 데이터의 JSON 바이트 직렬화 자체는 Pydantic이 수행하지 않고, `jsonable_encoder`로 변환한 후 `JSONResponse` 클래스에 전달하며, 그 클래스가 Python 표준 JSON 라이브러리를 사용해 바이트로 직렬화합니다.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:06:26 GMT 2026
    - 12.4K bytes
    - Click Count (0)
  10. docs/fr/docs/advanced/custom-response.md

    Si vous déclarez un [Modèle de réponse](../tutorial/response-model.md), FastAPI l'utilisera pour sérialiser les données en JSON, en utilisant Pydantic.
    
    Si vous ne déclarez pas de modèle de réponse, FastAPI utilisera le `jsonable_encoder` expliqué dans [Encodeur compatible JSON](../tutorial/encoder.md) et le placera dans une `JSONResponse`.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 18:37:13 GMT 2026
    - 12.3K bytes
    - Click Count (0)
Back to Top