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

XMLWordPrintableJSON

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

      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
            Reporter:
            Matt Dale
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: