# ValueError: Out of range float values are not JSON compliant

- **ID:** `python/flask-jsonify-nan-error`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Flask 的 jsonify 无法处理 NaN 或 Infinity 浮点值。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   使用 math.isnan() 检查并替换为 None
   ```
2. **** (80% success)
   ```
   配置 Flask 的 JSONProvider 允许 NaN，如 app.json.ensure_ascii = False
   ```
3. **** (85% success)
   ```
   使用自定义 JSONEncoder 覆盖 default 方法
   ```

## Dead Ends

- **** — JSON 标准不支持 Infinity。 (90% fail)
- **** — 客户端可能期望数值类型。 (60% fail)
- **** — 导致响应失败。 (80% fail)
