Standard library / encoding/json

encoding/json.InvalidUnmarshalError

Error describing an invalid Unmarshal destination. Type records the supplied Go type, or nil for an untyped nil argument. Expected stdout: 'true true\n'.

Formal Syntax & Structure

go syntaxgo
type InvalidUnmarshalError struct {  Type reflect.Type}

Working Example

Example Snippetgo
package main
import (  "encoding/json"  "errors"  "fmt"  "reflect")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  var dest *int  e := json.Unmarshal([]byte("1"), dest)  var x *json.InvalidUnmarshalError  fmt.Println(errors.As(e, &x), x.Type == reflect.TypeOf(dest))}
Go Reference