简体   繁体   中英

Why golang custom unmarshal got zero struct

I can't understand why I can't to get a value

func (a *Date) UnmarshalJSON(b []byte) (err error) {
    a, err = String(string(b))
    fmt.Println("OK on unmarshal", a)
    return
}

https://play.golang.org/p/wQh7r2wJgJt

Its ok inside unmarshal but nil on result. Something wrong with pointers?

thats it

func (a *Date) UnmarshalJSON(b []byte) (err error) {
    bb, err = String(string(b))
    (*a) = *bb
    return
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM