[GODRIVER-2720] Check for "encoding.TextMarshaler" and "encoding.BinaryMarshaler" when marshaling BSON and Extended JSON Created: 23/Dec/22  Updated: 08/Jan/24

Status: Backlog
Project: Go Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: 2.0.0

Type: Improvement Priority: Unknown
Reporter: Matt Dale Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Go Driver 2.0 BSON
Quarter: FY24Q3
Backwards Compatibility: Major Change

 Description   

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?

Generated at Thu Feb 08 08:39:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.