# json: cannot unmarshal number into Go value of type string

- **ID:** `go/json-unmarshal-type-mismatch`
- **Domain:** go
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The JSON data contains a value of a different type than the target Go field, such as a number where a string is expected.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.14 | active | — | — |
| 1.15 | active | — | — |
| 1.16 | active | — | — |

## Workarounds

1. **** (80% success)
   ```
   Define the struct field as interface{} and then type assert.
   ```
2. **** (85% success)
   ```
   Use a custom UnmarshalJSON method to handle type conversion.
   ```

## Dead Ends

- **** — This only works if the field is of type json.Number, not string. (70% fail)
- **** — Tags do not change the type conversion. (90% fail)
