> For the complete documentation index, see [llms.txt](https://close.gitbook.io/yun-wei-bi-ji/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://close.gitbook.io/yun-wei-bi-ji/python/fastapi/fastapi-sql-zhuan-huan-json.md).

# FastAPI sql 转换 json

* 自定义接口统一返回时, 转换 dict ， 去除密码

```python
# 增
@app.post('/api/users')
async def get_user(user: UserCreate, db: Session =  Depends(get_db)):
    user = create_user(db = db, user = user)
    from fastapi.encoders import jsonable_encoder
    return reponse(data=jsonable_encoder(user, exclude=['hashed_password']))
```
