Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 102 for encoded (0.16 sec)

  1. docs/en/docs/tutorial/encoder.md

    # JSON Compatible Encoder
    
    There are some cases where you might need to convert a data type (like a Pydantic model) to something compatible with JSON (like a `dict`, `list`, etc).
    
    For example, if you need to store it in a database.
    
    For that, **FastAPI** provides a `jsonable_encoder()` function.
    
    ## Using the `jsonable_encoder`
    
    Let's imagine that you have a database `fake_db` that only receives JSON compatible data.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Oct 17 05:59:11 GMT 2023
    - 1.8K bytes
    - Viewed (0)
  2. docs/en/docs/tutorial/request-forms-and-files.md

    !!! warning
        You can declare multiple `File` and `Form` parameters in a *path operation*, but you can't also declare `Body` fields that you expect to receive as JSON, as the request will have the body encoded using `multipart/form-data` instead of `application/json`.
    
        This is not a limitation of **FastAPI**, it's part of the HTTP protocol.
    
    ## Recap
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:02:19 GMT 2024
    - 2K bytes
    - Viewed (0)
  3. docs/en/docs/tutorial/request-forms.md

    **FastAPI** will make sure to read that data from the right place instead of JSON.
    
    !!! note "Technical Details"
        Data from forms is normally encoded using the "media type" `application/x-www-form-urlencoded`.
    
        But when the form includes files, it is encoded as `multipart/form-data`. You'll read about handling files in the next chapter.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:02:19 GMT 2024
    - 3.2K bytes
    - Viewed (0)
  4. docs/en/docs/tutorial/request-files.md

    **FastAPI** will make sure to read that data from the right place instead of JSON.
    
    !!! note "Technical Details"
        Data from forms is normally encoded using the "media type" `application/x-www-form-urlencoded` when it doesn't include files.
    
        But when the form includes files, it is encoded as `multipart/form-data`. If you use `File`, **FastAPI** will know it has to get the files from the correct part of the body.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:02:19 GMT 2024
    - 10.2K bytes
    - Viewed (0)
  5. docs/en/docs/advanced/custom-response.md

    This is because by default, FastAPI will inspect every item inside and make sure it is serializable as JSON, using the same [JSON Compatible Encoder](../tutorial/encoder.md){.internal-link target=_blank} explained in the tutorial. This is what allows you to return **arbitrary objects**, for example database models.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 11.7K bytes
    - Viewed (0)
  6. docs/en/docs/reference/encoders.md

    # Encoders - `jsonable_encoder`
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Oct 18 12:36:40 GMT 2023
    - 71 bytes
    - Viewed (0)
  7. docs/de/docs/reference/encoders.md

    # Encoder – `jsonable_encoder`
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Mon Feb 19 15:54:52 GMT 2024
    - 72 bytes
    - Viewed (0)
  8. docs/uk/docs/tutorial/encoder.md

    # JSON Compatible Encoder
    
    Існують випадки, коли вам може знадобитися перетворити тип даних (наприклад, модель Pydantic) в щось сумісне з JSON (наприклад, `dict`, `list`, і т. д.).
    
    Наприклад, якщо вам потрібно зберегти це в базі даних.
    
    Для цього, **FastAPI** надає `jsonable_encoder()` функцію.
    
    ## Використання `jsonable_encoder`
    
    Давайте уявимо, що у вас є база даних `fake_db`, яка приймає лише дані, сумісні з JSON.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 2.6K bytes
    - Viewed (0)
  9. docs/ru/docs/tutorial/encoder.md

    Для этого можно использовать функцию `jsonable_encoder`.
    
    Она принимает объект, например, модель Pydantic, и возвращает его версию, совместимую с JSON:
    
    === "Python 3.10+"
    
        ```Python hl_lines="4  21"
        {!> ../../../docs_src/encoder/tutorial001_py310.py!}
        ```
    
    === "Python 3.6+"
    
        ```Python hl_lines="5  22"
        {!> ../../../docs_src/encoder/tutorial001.py!}
        ```
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Jan 23 13:56:12 GMT 2024
    - 2.8K bytes
    - Viewed (0)
  10. docs/zh/docs/advanced/response-directly.md

    # 直接返回响应
    
    当你创建一个 **FastAPI** *路径操作* 时,你可以正常返回以下任意一种数据:`dict`,`list`,Pydantic 模型,数据库模型等等。
    
    **FastAPI** 默认会使用 `jsonable_encoder` 将这些类型的返回值转换成 JSON 格式,`jsonable_encoder` 在 [JSON 兼容编码器](../tutorial/encoder.md){.internal-link target=_blank} 中有阐述。
    
    然后,**FastAPI** 会在后台将这些兼容 JSON 的数据(比如字典)放到一个 `JSONResponse` 中,该 `JSONResponse` 会用来发送响应给客户端。
    
    但是你可以在你的 *路径操作* 中直接返回一个 `JSONResponse`。
    
    直接返回响应可能会有用处,比如返回自定义的响应头和 cookies。
    
    ## 返回 `Response`
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu May 12 00:06:16 GMT 2022
    - 3.1K bytes
    - Viewed (0)
Back to top