github.com/zerosnake0/jzon@v0.0.9-0.20230801092939-1b135cb83f7f/val_encoder_json_marshaler.go (about) 1 package jzon 2 3 import ( 4 "encoding/json" 5 ) 6 7 type jsonMarshalerValEncoder struct{} 8 9 func (jsonMarshalerValEncoder) Encode(o interface{}, s *Streamer, opts *EncOpts) { 10 if s.Error != nil { 11 return 12 } 13 raw, err := o.(json.Marshaler).MarshalJSON() 14 if err != nil { 15 s.Error = err 16 return 17 } 18 s.Raw(raw) 19 }