{
  "id": "go/cannot-unmarshal-string-into-struct-field-of-type-map",
  "signature": "json: cannot unmarshal string into Go struct field Foo.Bar of type map[string]string",
  "signature_zh": "json：无法将字符串解组到类型为 map[string]string 的 Go 结构体字段 Foo.Bar 中",
  "regex": "json: cannot unmarshal string into Go struct field \\w+\\.\\w+ of type map\\[string\\]string",
  "domain": "go",
  "category": "encoding_error",
  "subcategory": null,
  "root_cause": "JSON contains a string value where the Go struct expects a map, due to incorrect JSON structure or type mismatch in the source data.",
  "root_cause_type": "generic",
  "root_cause_zh": "JSON 包含字符串值，但 Go 结构体期望映射类型，由于源数据中的 JSON 结构错误或类型不匹配。",
  "versions": [
    {
      "version": "go1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "go1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "go1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Tags only affect naming, not type conversion.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "UseNumber() only affects number parsing, not type coercion.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Change Go struct field type to string and parse manually: type Foo struct { Bar string } then unmarshal Bar as JSON string into map.",
      "success_rate": 0.9,
      "how": "Change Go struct field type to string and parse manually: type Foo struct { Bar string } then unmarshal Bar as JSON string into map.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Preprocess JSON to ensure Bar is an object: use json.RawMessage to capture Bar, then check if it's a string and handle accordingly.",
      "success_rate": 0.85,
      "how": "Preprocess JSON to ensure Bar is an object: use json.RawMessage to capture Bar, then check if it's a string and handle accordingly.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Change Go struct field type to string and parse manually: type Foo struct { Bar string } then unmarshal Bar as JSON string into map.",
    "Preprocess JSON to ensure Bar is an object: use json.RawMessage to capture Bar, then check if it's a string and handle accordingly."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://pkg.go.dev/encoding/json#Unmarshal",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}