# invalid character '\x00' looking for beginning of value

- **ID:** `go/json-invalid-character-looking-for-beginning`
- **Domain:** go
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The input to the JSON decoder begins with a NUL byte or non-JSON garbage, e.g. binary content, BOM, or an empty gzip stream.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.22 | active | — | — |

## Workarounds

1. **** (85% success)
   ```
   b = bytes.TrimPrefix(b, []byte{0xEF,0xBB,0xBF})
b = bytes.Trim(b, "\x00")
if !json.Valid(b) { return fmt.Errorf("invalid json: %q", b[:min(32,len(b))]) }
   ```
2. **** (90% success)
   ```
   Log the first 64 bytes of the body before decoding to diagnose the actual content.
   ```

## Dead Ends

- **** — Does not remove NUL bytes or BOM. (80% fail)
- **** — Returns false but gives no insight into the cause. (60% fail)
