// MarshalWithCodec marshals the specified object with the specified codec and options. // If the object implements the Facade interface, the PublicData object should be // marshalled instead. func (s *WebCodecService) MarshalWithCodec(codec codecs.Codec, object interface{}, options map[string]interface{}) ([]byte, error) { // make sure we have at least one codec s.assertCodecs() // get the public data publicData, err := codecs.PublicData(object, options) // if there was an error - return it if err != nil { return nil, err } // let the codec do its work return codec.Marshal(publicData, options) }