Search Options

Results per page
Sort
Preferred Languages
Advance

Results 21 - 30 of 54 for jsonable_encoder (0.08 sec)

  1. fastapi/openapi/utils.py

                example = getattr(field_info, "example", None)
                if openapi_examples:
                    parameter["examples"] = jsonable_encoder(openapi_examples)
                elif example != Undefined:
                    parameter["example"] = jsonable_encoder(example)
                if getattr(field_info, "deprecated", None):
                    parameter["deprecated"] = True
                parameters.append(parameter)
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 22.6K bytes
    - Viewed (0)
  2. docs/en/docs/advanced/response-directly.md

    When you create a **FastAPI** *path operation* you can normally return any data from it: a `dict`, a `list`, a Pydantic model, a database model, etc.
    
    By default, **FastAPI** would automatically convert that return value to JSON using the `jsonable_encoder` explained in [JSON Compatible Encoder](../tutorial/encoder.md){.internal-link target=_blank}.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3K bytes
    - Viewed (0)
  3. docs_src/body_updates/tutorial001.py

    from typing import List, Union
    
    from fastapi import FastAPI
    from fastapi.encoders import jsonable_encoder
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: Union[str, None] = None
        description: Union[str, None] = None
        price: Union[float, None] = None
        tax: float = 10.5
        tags: List[str] = []
    
    
    items = {
        "foo": {"name": "Foo", "price": 50.2},
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat May 14 11:59:59 UTC 2022
    - 906 bytes
    - Viewed (0)
  4. docs_src/body_updates/tutorial002_py310.py

    from fastapi import FastAPI
    from fastapi.encoders import jsonable_encoder
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str | None = None
        description: str | None = None
        price: float | None = None
        tax: float = 10.5
        tags: list[str] = []
    
    
    items = {
        "foo": {"name": "Foo", "price": 50.2},
        "bar": {"name": "Bar", "description": "The bartenders", "price": 62, "tax": 20.2},
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jan 07 14:11:31 UTC 2022
    - 1010 bytes
    - Viewed (0)
  5. docs_src/encoder/tutorial001_py310.py

    from fastapi import FastAPI
    from fastapi.encoders import jsonable_encoder
    from pydantic import BaseModel
    
    fake_db = {}
    
    
    class Item(BaseModel):
        title: str
        timestamp: datetime
        description: str | None = None
    
    
    app = FastAPI()
    
    
    @app.put("/items/{id}")
    def update_item(id: str, item: Item):
        json_compatible_item_data = jsonable_encoder(item)
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jan 07 14:11:31 UTC 2022
    - 430 bytes
    - Viewed (0)
  6. docs_src/body_updates/tutorial002.py

    from typing import List, Union
    
    from fastapi import FastAPI
    from fastapi.encoders import jsonable_encoder
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: Union[str, None] = None
        description: Union[str, None] = None
        price: Union[float, None] = None
        tax: float = 10.5
        tags: List[str] = []
    
    
    items = {
        "foo": {"name": "Foo", "price": 50.2},
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat May 14 11:59:59 UTC 2022
    - 1K bytes
    - Viewed (0)
  7. docs/em/docs/advanced/response-directly.md

    ๐Ÿ‘‰ ๐Ÿค ๐Ÿ‘† ๐Ÿ“š ๐Ÿ’ช. ๐Ÿ‘† ๐Ÿ’ช ๐Ÿ“จ ๐Ÿ™† ๐Ÿ“Š ๐Ÿ†Ž, ๐Ÿ” ๐Ÿ™† ๐Ÿ’ฝ ๐Ÿ“„ โš–๏ธ ๐Ÿ”ฌ, โ™’๏ธ.
    
    ## โš™๏ธ `jsonable_encoder` `Response`
    
    โ†ฉ๏ธ **FastAPI** ๐Ÿšซ ๐Ÿ™† ๐Ÿ”€ `Response` ๐Ÿ‘† ๐Ÿ“จ, ๐Ÿ‘† โœ”๏ธ โš’ ๐Ÿ’ญ โšซ๏ธ ๐ŸŽš ๐Ÿ”œ โšซ๏ธ.
    
    ๐Ÿ–ผ, ๐Ÿ‘† ๐Ÿšซ๐Ÿ”œ ๐Ÿšฎ Pydantic ๐Ÿท `JSONResponse` ๐Ÿต ๐Ÿฅ‡ ๐Ÿญ โšซ๏ธ `dict` โฎ๏ธ ๐ŸŒ ๐Ÿ“Š ๐Ÿ†Ž (๐Ÿ’– `datetime`, `UUID`, โ™’๏ธ) ๐Ÿ—œ ๐ŸŽป-๐Ÿ”— ๐Ÿ†Ž.
    
    ๐Ÿ“š ๐Ÿ’ผ, ๐Ÿ‘† ๐Ÿ’ช โš™๏ธ `jsonable_encoder` ๐Ÿ—œ ๐Ÿ‘† ๐Ÿ“Š โญ ๐Ÿšถโ€โ™€๏ธ โšซ๏ธ ๐Ÿ“จ:
    
    ```Python hl_lines="6-7  21-22"
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 2.6K bytes
    - Viewed (0)
  8. docs/de/docs/advanced/response-directly.md

    StandardmรครŸig konvertiert **FastAPI** diesen Rรผckgabewert automatisch nach JSON, mithilfe des `jsonable_encoder`, der in [JSON-kompatibler Encoder](../tutorial/encoder.md){.internal-link target=_blank} erlรคutert wird.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.5K bytes
    - Viewed (0)
  9. docs/es/docs/advanced/response-directly.md

    Por defecto, **FastAPI** convertirรญa automรกticamente ese valor devuelto a JSON usando el `jsonable_encoder` explicado en [Codificador Compatible JSON](../tutorial/encoder.md){.internal-link target=_blank}.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.2K bytes
    - Viewed (0)
  10. docs/ko/docs/advanced/response-directly.md

    ์ด๋กœ ์ธํ•ด ๋งŽ์€ ์œ ์—ฐ์„ฑ์„ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์–ด๋–ค ๋ฐ์ดํ„ฐ ์œ ํ˜•์ด๋“  ๋ฐ˜ํ™˜ํ•  ์ˆ˜ ์žˆ๊ณ , ๋ฐ์ดํ„ฐ ์„ ์–ธ์ด๋‚˜ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ๋ฅผ ์žฌ์ •์˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    
    ## `Response`์—์„œ `jsonable_encoder` ์‚ฌ์šฉํ•˜๊ธฐ
    
    **FastAPI**๋Š” ๋ฐ˜ํ™˜ํ•˜๋Š” `Response`์— ์•„๋ฌด๋Ÿฐ ๋ณ€ํ™˜์„ ํ•˜์ง€ ์•Š์œผ๋ฏ€๋กœ, ๊ทธ ๋‚ด์šฉ์ด ์ค€๋น„๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    
    ์˜ˆ๋ฅผ ๋“ค์–ด, Pydantic ๋ชจ๋ธ์„ `dict`๋กœ ๋ณ€ํ™˜ํ•ด `JSONResponse`์— ๋„ฃ์ง€ ์•Š์œผ๋ฉด JSON ํ˜ธํ™˜ ์œ ํ˜•์œผ๋กœ ๋ณ€ํ™˜๋œ ๋ฐ์ดํ„ฐ ์œ ํ˜•(์˜ˆ: `datetime`, `UUID` ๋“ฑ)์ด ์‚ฌ์šฉ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
    
    ์ด๋Ÿฌํ•œ ๊ฒฝ์šฐ, ๋ฐ์ดํ„ฐ๋ฅผ ์‘๋‹ต์— ์ „๋‹ฌํ•˜๊ธฐ ์ „์— `jsonable_encoder`๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ณ€ํ™˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
    
    ```Python hl_lines="6-7 21-22"
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 30 20:00:57 UTC 2024
    - 3.4K bytes
    - Viewed (0)
Back to top