Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 9 of 9 for dict (0.18 sec)

  1. docs/pt/docs/tutorial/encoder.md

    # Codificador Compatível com JSON
    
    Existem alguns casos em que você pode precisar converter um tipo de dados (como um modelo Pydantic) para algo compatível com JSON (como um `dict`, `list`, etc).
    
    Por exemplo, se você precisar armazená-lo em um banco de dados.
    
    Para isso, **FastAPI** fornece uma função `jsonable_encoder()`.
    
    ## Usando a função `jsonable_encoder`
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 1.9K bytes
    - Viewed (0)
  2. docs/em/docs/tutorial/encoder.md

    👆 💪 ⚙️ `jsonable_encoder` 👈.
    
    ⚫️ 📨 🎚, 💖 Pydantic 🏷, & 📨 🎻 🔗 ⏬:
    
    === "🐍 3️⃣.6️⃣ & 🔛"
    
        ```Python hl_lines="5  22"
        {!> ../../../docs_src/encoder/tutorial001.py!}
        ```
    
    === "🐍 3️⃣.1️⃣0️⃣ & 🔛"
    
        ```Python hl_lines="4  21"
        {!> ../../../docs_src/encoder/tutorial001_py310.py!}
        ```
    
    👉 🖼, ⚫️ 🔜 🗜 Pydantic 🏷 `dict`, & `datetime` `str`.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Apr 01 09:26:04 GMT 2023
    - 1.5K bytes
    - Viewed (0)
  3. docs/ru/docs/tutorial/encoder.md

    # JSON кодировщик
    
    В некоторых случаях может потребоваться преобразование типа данных (например, Pydantic-модели) в тип, совместимый с JSON (например, `dict`, `list` и т.д.).
    
    Например, если необходимо хранить его в базе данных.
    
    Для этого **FastAPI** предоставляет функцию `jsonable_encoder()`.
    
    ## Использование `jsonable_encoder`
    
    Представим, что у вас есть база данных `fake_db`, которая принимает только JSON-совместимые данные.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Jan 23 13:56:12 GMT 2024
    - 2.8K bytes
    - Viewed (0)
  4. 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 Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 2.6K bytes
    - Viewed (0)
  5. docs/de/docs/tutorial/encoder.md

    # JSON-kompatibler Encoder
    
    Es gibt Fälle, da möchten Sie einen Datentyp (etwa ein Pydantic-Modell) in etwas konvertieren, das kompatibel mit JSON ist (etwa ein `dict`, eine `list`e, usw.).
    
    Zum Beispiel, wenn Sie es in einer Datenbank speichern möchten.
    
    Dafür bietet **FastAPI** eine Funktion `jsonable_encoder()`.
    
    ## `jsonable_encoder` verwenden
    
    Stellen wir uns vor, Sie haben eine Datenbank `fake_db`, die nur JSON-kompatible Daten entgegennimmt.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 30 18:07:21 GMT 2024
    - 1.9K bytes
    - Viewed (0)
  6. docs/ko/docs/tutorial/encoder.md

    같은 방식으로 이 데이터베이스는 Pydantic 모델(속성이 있는 객체)을 받지 않고, `dict` 만을 받습니다.
    
    이를 위해 `jsonable_encoder` 를 사용할 수 있습니다.
    
    Pydantic 모델과 같은 객체를 받고 JSON 호환 가능한 버전으로 반환합니다:
    
    ```Python hl_lines="5  22"
    {!../../../docs_src/encoder/tutorial001.py!}
    ```
    
    이 예시는 Pydantic 모델을 `dict`로, `datetime` 형식을 `str`로 변환합니다.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Dec 08 15:43:31 GMT 2021
    - 1.9K bytes
    - Viewed (0)
  7. 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 Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Oct 17 05:59:11 GMT 2023
    - 1.8K bytes
    - Viewed (0)
  8. docs/zh/docs/tutorial/encoder.md

    在某些情况下,您可能需要将数据类型(如Pydantic模型)转换为与JSON兼容的数据类型(如`dict`、`list`等)。
    
    比如,如果您需要将其存储在数据库中。
    
    对于这种要求, **FastAPI**提供了`jsonable_encoder()`函数。
    
    ## 使用`jsonable_encoder`
    
    让我们假设你有一个数据库名为`fake_db`,它只能接收与JSON兼容的数据。
    
    例如,它不接收`datetime`这类的对象,因为这些对象与JSON不兼容。
    
    因此,`datetime`对象必须将转换为包含<a href="https://en.wikipedia.org/wiki/ISO_8601" class="external-link" target="_blank">ISO格式化</a>的`str`类型对象。
    
    同样,这个数据库也不会接收Pydantic模型(带有属性的对象),而只接收`dict`。
    
    对此你可以使用`jsonable_encoder`。
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Oct 17 05:59:11 GMT 2023
    - 1.7K bytes
    - Viewed (0)
  9. docs/ja/docs/tutorial/encoder.md

    同様に、このデータベースはPydanticモデル(属性を持つオブジェクト)を受け取らず、`dict`だけを受け取ります。
    
    そのために`jsonable_encoder`を使用することができます。
    
    Pydanticモデルのようなオブジェクトを受け取り、JSON互換版を返します:
    
    ```Python hl_lines="5 22"
    {!../../../docs_src/encoder/tutorial001.py!}
    ```
    
    この例では、Pydanticモデルを`dict`に、`datetime`を`str`に変換します。
    
    呼び出した結果は、Pythonの標準の<a href="https://docs.python.org/3/library/json.html#json.dumps" class="external-link" target="_blank">`json.dumps()`</a>でエンコードできるものです。
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Mon Jan 22 20:09:02 GMT 2024
    - 1.9K bytes
    - Viewed (0)
Back to top