[GODRIVER-1765] Add MarshalJSON/UnmarshalJSON functions for bson.D Created: 12/Oct/20  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: Major - P3
Reporter: Divjot Arora (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by GODRIVER-2790 Make "bson.D" implement "json.Marshal... Closed
Related
related to GODRIVER-2591 Make all BSON types (bson.D, bson.M, ... Backlog
Epic Link: Go Driver 2.0 BSON
Quarter: FY24Q3
Backwards Compatibility: 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.

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