github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/persistence/protocb/json_transcoder.go (about) 1 package protocb 2 3 import "encoding/json" 4 5 type transcoder struct{} 6 7 func (t transcoder) Decode(bytes []byte, flags uint32, out interface{}) error { 8 err := json.Unmarshal(bytes, &out) 9 if err != nil { 10 return err 11 } 12 return nil 13 } 14 15 func (t transcoder) Encode(value interface{}) ([]byte, uint32, error) { 16 bytes, err := json.Marshal(value) 17 if err != nil { 18 return nil, 0, err 19 } 20 return bytes, 0, nil 21 }