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

Add MarshalJSON/UnmarshalJSON functions for bson.D

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.0.0
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • Major Change
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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.

            Assignee:
            qingyang.hu@mongodb.com Qingyang Hu
            Reporter:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: