{
  "id": "python/flask-session-serialization-error",
  "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": "Storing non-JSON-serializable values (datetime, Decimal, custom classes) in the Flask session cookie.",
  "root_cause_type": "generic",
  "root_cause_zh": "在Flask会话cookie中存储不可JSON序列化的值（datetime、Decimal、自定义类）。",
  "versions": [
    {
      "version": "2.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Unrelated to serialization.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Only affects expiry, not encoding.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "session['ts'] = dt.isoformat()\\n# read back: datetime.fromisoformat(session['ts'])",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "app.config['SESSION_TYPE'] = 'redis'\\nSession(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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}