{
  "id": "go/encoding-json-marshal-time-duration",
  "signature": "error: json: error calling MarshalJSON for type time.Duration",
  "signature_zh": "错误：json：调用time.Duration类型的MarshalJSON时出错",
  "regex": "error:\\ json:\\ error\\ calling\\ MarshalJSON\\ for\\ type\\ time\\.Duration",
  "domain": "go",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "time.Duration does not implement json.Marshaler and is marshaled as a nanosecond integer, which may not be intended.",
  "root_cause_type": "generic",
  "root_cause_zh": "time.Duration未实现json.Marshaler，会被编组为纳秒整数，可能不符合预期。",
  "versions": [
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using string formatting to convert duration",
      "why_fails": "Inconsistent output; use custom type with MarshalJSON.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Create a custom type that marshals duration as string",
      "success_rate": 0.9,
      "how": "type Duration time.Duration\nfunc (d Duration) MarshalJSON() ([]byte, error) {\n    return json.Marshal(time.Duration(d).String())\n}",
      "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.81,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2026-11-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}