github.com/zerosnake0/jzon@v0.0.9-0.20230801092939-1b135cb83f7f/val_decoder_json_unmarshaler.go (about) 1 package jzon 2 3 import ( 4 "encoding/json" 5 "reflect" 6 "unsafe" 7 ) 8 9 var ( 10 jsonUnmarshalerType = reflect.TypeOf((*json.Unmarshaler)(nil)).Elem() 11 ) 12 13 type jsonUnmarshalerDecoder rtype 14 15 func (dec jsonUnmarshalerDecoder) Decode(ptr unsafe.Pointer, it *Iterator, _ *DecOpts) error { 16 obj := packEFace(rtype(dec), ptr) 17 unmarshaler := obj.(json.Unmarshaler) 18 b, err := it.SkipRaw() 19 if err != nil { 20 return err 21 } 22 return unmarshaler.UnmarshalJSON(b) 23 }