Skip to content

DOCSP-48090 OmitEmpty global flag #477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 25, 2025
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions source/fundamentals/bson.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ This example performs the following actions:
to use the ``"json"`` struct tag if a ``"bson"`` struct tag is not specified
- Sets the ``NilSliceAsEmpty`` field to ``true``, which instructs the driver
to marshal ``nil`` Go slices as empty BSON arrays
- Sets the ``OmitEmpty`` field to ``true``, which instructs the driver to globally omit
empty values from the marshaled BSON, rather than set empty values to ``null``

- Passes the ``BSONOptions`` instance to the ``SetBSONOptions()`` helper method to specify
a ``ClientOptions`` instance
Expand All @@ -236,6 +238,7 @@ This example performs the following actions:
bsonOpts := &options.BSONOptions {
UseJSONStructTags: true,
NilSliceAsEmpty: true,
OmitEmpty: true,
}

clientOpts := options.Client().
Expand Down