Standard library / encoding/json

encoding/json.UnmarshalFieldError.Error()

Describe the historical attempt to decode an inaccessible struct field. Deprecated and no longer returned by modern Unmarshal. Expected stdout: 'true\n'.

Formal Syntax & Structure

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

Return Value

string

Text representation or diagnostic.

Working Example

Example Snippetgo
package main
import (  "encoding/json"  "fmt"  "reflect")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  e := &json.UnmarshalFieldError{Key: "x", Type: reflect.TypeOf(struct{}{}), Field: reflect.StructField{Name: "x"}}  fmt.Println(len(e.Error()) > 0)}
Go Reference