{
  "id": "go/json-cannot-unmarshal-number-into-string",
  "signature": "json: cannot unmarshal number into Go struct field User.age of type string",
  "signature_zh": "json：无法将数字反序列化到 Go 结构体字段 User.age（类型 string）",
  "regex": "json:\\ cannot\\ unmarshal\\ number\\ into\\ Go\\ struct\\ field\\ User\\.age\\ of\\ type\\ string",
  "domain": "go",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "The JSON payload contains a numeric value where the Go struct expects a string. The API changed, or the schema was misdeclared.",
  "root_cause_type": "generic",
  "root_cause_zh": "JSON 负载在 Go 结构体期望 string 的位置包含了数字。可能是 API 变更或结构体字段声明错误。",
  "versions": [
    {
      "version": "1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Loses type safety and just moves the panic downstream when the value is used.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Leaves partially populated struct and hides real data corruption.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.88,
      "how": "type User struct {\n  Age json.Number `json:\"age\"`\n}\ndec := json.NewDecoder(r)\ndec.UseNumber()\ndec.Decode(&u)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Define a custom type with UnmarshalJSON that accepts both string and number.",
      "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-05-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}