Golang encoding/json.MarshalerError type and function example

package encoding/json

Golang encoding/json.MarshalerError type and function usage example

 if err != nil {
 switch err.(type) {
 case *json.MarshalerError:
 fmt.Printf("invalid json unmarshal error: %s\n", err.Error())
 default:
 fmt.Printf("Error: %s\n", err)
 }

Reference :

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

Advertisement