# TypeError: Object of type datetime is not JSON serializable

- **ID:** `python/flask-jsonify-not-serializable`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

jsonify (or response) attempted to serialize an object containing datetime, Decimal, UUID, or a custom class without a JSON encoder.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   Custom encoder:
class CustomJSONProvider(DefaultJSONProvider):
    @staticmethod
    def default(o):
        if isinstance(o, datetime): return o.isoformat()
        return super().default(o)
app.json = CustomJSONProvider(app)
   ```
2. **** (90% success)
   ```
   Or convert before returning: `return jsonify({'created': user.created_at.isoformat()})`
   ```

## Dead Ends

- **** — Produces `"<__main__.User object at 0x...>"`, useless to clients. (90% fail)
- **** — Breaks jsonify entirely. (95% fail)
