Standard library / encoding/json

encoding/json.UnsupportedTypeError.Error()

Describe a Go type that cannot be represented in JSON, such as a channel or function. Expected stdout: 'true true\n'.

Formal Syntax & Structure

go syntaxgo
func (e *UnsupportedTypeError) Error() string

Return Value

string

Text representation or diagnostic.

Working Example

Example Snippetgo
package main
import (  "encoding/json"  "errors"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  _, e := json.Marshal(make(chan int))  var x *json.UnsupportedTypeError  fmt.Println(errors.As(e, &x), len(x.Error()) > 0)}
Go Reference