Standard library / encoding/json

encoding/json.UnmarshalFieldError

Deprecated compatibility type with Key, Type and Field. Modern decoding ignores unexported fields rather than returning this error by default. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
type UnmarshalFieldError struct {  Key   string  Type  reflect.Type  Field reflect.StructField}

Working Example

Example Snippetgo
package main
import (  "encoding/json"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  var x struct{ hidden int }  must(json.Unmarshal([]byte(`{"hidden":5}`), &x))  fmt.Println(x.hidden == 0)}
Go Reference