From the docs:
JSON cannot represent cyclic data structures and Marshal does not handle them. Passing cyclic structures to Marshal will result in an i
Update: now using a channel instead of a map[int]int to elicit the error
Go-specific structures,e.g. func or chan refuse to serialize:
func
chan
package main import ( "encoding/json" "fmt" ) func main() { value := make(chan int) _, err := json.Marshal(value) fmt.Println(err) }