# error: json: unsupported type: chan int

- **ID:** `go/encoding-json-marshal-unsupported-type`
- **Domain:** go
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Attempting to marshal a Go type that is not supported by encoding/json, such as channels, functions, or complex numbers.

## Version Compatibility

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

## Workarounds

1. **Implement json.Marshaler interface for the custom type** (90% success)
   ```
   type MyChan chan int
func (c MyChan) MarshalJSON() ([]byte, error) {
    return json.Marshal(len(c))
}
   ```

## Dead Ends

- **Using reflect to manually marshal** — Complex and error-prone; better to implement json.Marshaler interface. (60% fail)
