Golang encoding/json.UnsupportedTypeError type and function example

package encoding/json

An UnsupportedTypeError is returned by Marshal when attempting to encode an unsupported value type.

Golang encoding/json.UnsupportedTypeError type and function usage example

  switch err.(type) {
 case *json.UnsupportedTypeError:
 fmt.Println("The provided JSON input is invalid")
 // fmt.Println(err.Error()) 
 default:
 fmt.Println(err)
  }

Reference :

http://golang.org/pkg/encoding/json/#UnsupportedTypeError

Advertisement