mirror of https://github.com/tiangolo/fastapi.git
1.5 KiB
1.5 KiB
🎻 🔗 🔢
📤 💼 🌐❔ 👆 5️⃣📆 💪 🗜 💽 🆎 (💖 Pydantic 🏷) 🕳 🔗 ⏮️ 🎻 (💖 dict, list, ♒️).
🖼, 🚥 👆 💪 🏪 ⚫️ 💽.
👈, FastAPI 🚚 jsonable_encoder() 🔢.
⚙️ jsonable_encoder
➡️ 🌈 👈 👆 ✔️ 💽 fake_db 👈 🕴 📨 🎻 🔗 💽.
🖼, ⚫️ 🚫 📨 datetime 🎚, 👈 🚫 🔗 ⏮️ 🎻.
, datetime 🎚 🔜 ✔️ 🗜 str ⚗ 💽 💾 📁.
🎏 🌌, 👉 💽 🚫🔜 📨 Pydantic 🏷 (🎚 ⏮️ 🔢), 🕴 dict.
👆 💪 ⚙️ 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.
🏁 🤙 ⚫️ 🕳 👈 💪 🗜 ⏮️ 🐍 🐩 json.dumps().
⚫️ 🚫 📨 ⭕ str ⚗ 💽 🎻 📁 (🎻). ⚫️ 📨 🐍 🐩 💽 📊 (✅ dict) ⏮️ 💲 & 🎧-💲 👈 🌐 🔗 ⏮️ 🎻.
!!! note
jsonable_encoder 🤙 ⚙️ FastAPI 🔘 🗜 💽. ✋️ ⚫️ ⚠ 📚 🎏 😐.