If a type satisfies the encoding.TextMarshaler or encoding.BinaryMarshaler interfaces, we should use those when marshaling BSON after checking for BSON-specific marshaler functions.
Similarly, if a type satisfies the encoding.TextUnmarshaler or encoding.BinaryUnmarshaler interfaces, we should use that when unmarshaling BSON after checking for BSON-specific unmarshaler functions.
Definition of done:
- The BSON and Extended JSON marshaler check if a type satisfies the encoding.TextMarshaler and encoding.BinaryMarshaler interfaces after checking for BSON-specific marshaler functions.
- The BSON and Extended JSON unmarshaler check if a type satisfies the encoding.TextUnmarshaler and encoding.BinaryUnmarshaler interfaces after checking for BSON-specific marshaler functions.
Open questions:
- What is the priority order between encoding.TextMarshaler, encoding.BinaryMarshaler, and the other BSON-specific marshaler interfaces? What does Go's "encoding/json" do?
- Should we do the same thing for the Extended JSON marshaler and unmarshaler?