Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2720

Check for "encoding.TextMarshaler" and "encoding.BinaryMarshaler" when marshaling BSON and Extended JSON

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 2.1.0
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • Major Change

      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?

            Assignee:
            Unassigned Unassigned
            Reporter:
            matt.dale@mongodb.com Matt Dale
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: