{
  "id": "go/encoding-json-marshaler-error",
  "signature": "json: error calling MarshalJSON for type MyStruct: custom error",
  "signature_zh": "json: 调用 MyStruct 类型的 MarshalJSON 出错：自定义错误",
  "regex": "json:\\ error\\ calling\\ MarshalJSON\\ for\\ type\\ MyStruct:\\ custom\\ error",
  "domain": "go",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "A custom MarshalJSON method returns an error, causing json.Marshal to fail.",
  "root_cause_type": "generic",
  "root_cause_zh": "自定义 MarshalJSON 方法返回错误，导致 json.Marshal 失败。",
  "versions": [
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Loses custom serialization logic, may produce wrong output.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Panic propagates and crashes the program.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "func (m MyStruct) MarshalJSON() ([]byte, error) { if m.Invalid { return nil, errors.New(\"invalid state\") }; return json.Marshal(m.Alias) }",
      "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": "2024-05-25",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}