github.com/zerosnake0/jzon@v0.0.9-0.20230801092939-1b135cb83f7f/val_encoder_json_rawmessage.go (about) 1 package jzon 2 3 import ( 4 "unsafe" 5 ) 6 7 type jsonRawMessageEncoder struct{} 8 9 func (*jsonRawMessageEncoder) IsEmpty(ptr unsafe.Pointer) bool { 10 return len(*(*[]byte)(ptr)) == 0 11 } 12 13 func (*jsonRawMessageEncoder) Encode(ptr unsafe.Pointer, s *Streamer, opts *EncOpts) { 14 if ptr == nil { 15 s.Null() 16 return 17 } 18 data := *(*[]byte)(ptr) 19 // TODO: raw message validation? 20 s.Raw(data) 21 }