# error: unexpected end of JSON input

- **ID:** `go/encoding-json-unexpected-end-of-json-input`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The JSON decoder reached the end of input before completing a valid JSON structure, often due to truncated data or empty input.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.20 | active | — | — |
| 1.21 | active | — | — |

## Workarounds

1. **Use io.ReadAll to read full body before decoding** (90% success)
   ```
   body, err := io.ReadAll(resp.Body)
if err != nil { return err }
if len(body) == 0 { return errors.New("empty response") }
json.Unmarshal(body, &target)
   ```

## Dead Ends

- **Assuming the error is always a server bug** — Often caused by network issues or partial reads; retrying may help but not always. (50% fail)
