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

Add MarshalJSON/UnmarshalJSON functions for bson.D

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • 2.0.0
    • None
    • BSON
    • None
    • Major Change

    Description

      Our bson.D type doesn't support converting to/from JSON via the stdlib json.Marshal and json.Unmarshal functions. This causes issues for users with interface{} in their structs because the driver decodes BSON documents as bson.D when the target type is interface{}. If the user then tries to marshal the struct as JSON, the resulting JSON is an array of documents because bson.D is internally represented as a slice of structs.

      Definition of done:

      • bson.D implements the json.Marshaler and json.Unmarshaler interfaces and output a key-value representation of the bson.D in "regular" (i.e. non-Extended) JSON.

      Attachments

        Activity

          People

            Unassigned Unassigned
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: