{
  "id": "python/flask-jsonify-serialization",
  "signature": "TypeError: Object of type datetime is not JSON serializable",
  "signature_zh": "TypeError: datetime 类型的对象不可 JSON 序列化",
  "regex": "TypeError:\\ Object\\ of\\ type\\ datetime\\ is\\ not\\ JSON\\ serializable",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "jsonify() cannot serialize non-JSON-native types such as datetime, Decimal, or custom objects.",
  "root_cause_type": "generic",
  "root_cause_zh": "jsonify() 无法序列化 datetime、Decimal 或自定义对象等非 JSON 原生类型。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Bypasses Flask's jsonify behavior and content-type handling.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hides the real serialization issue from clients.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "return jsonify({'created': obj.created_at.isoformat()})",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "from flask.json.provider import DefaultJSONProvider\nclass P(DefaultJSONProvider):\n    @staticmethod\n    def default(o): return o.isoformat()\napp.json = P(app)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}