# werkzeug.exceptions.BadRequest: 400 错误请求：无法解码 JSON 对象：Expecting value: line 1 column 1 (char 0)

- **ID:** `python/flask-json-decode-error`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

对空请求体或非 JSON 请求（如表单编码或缺少 Content-Type）调用了 request.get_json()。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   data = request.get_json(silent=True) or {}
   ```
2. **** (92% 成功率)
   ```
   Check request.is_json before parsing: if request.is_json: data = request.get_json()
   ```

## 无效尝试

- **** — Still fails if body is empty or malformed. (60% 失败率)
- **** — Downstream code then receives None and crashes. (70% 失败率)
