Skip to content

Commit 4ba81c5

Browse files
authored
DOCSP-43733 - Default JSON mode (#246)
1 parent 05bde31 commit 4ba81c5

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

source/upgrade/v3.txt

+21-1
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,24 @@ Version 3.0 Breaking Changes
115115
apply the ``[BsonRepresentation(BsonType.String)]`` attribute to the field.
116116

117117
To learn more about specifying BSON types during serialization, see the
118-
:ref:`Custom Serialization <csharp-custom-serialization>` section of the POCOs page.
118+
:ref:`Custom Serialization <csharp-custom-serialization>` section of the POCOs page.
119+
120+
- The default JSON output mode is Relaxed Extended JSON, a string format based on the
121+
JSON standard that describes BSON documents. Relaxed Extended JSON emphasizes
122+
readability and interoperability at the expense of type preservation.
123+
124+
To use a different JSON output mode, create a new ``JsonWriterSettings`` object. Set
125+
the ``OutputMode`` property of this object to a value from the ``JsonOutputMode`` enum,
126+
then pass the object to the ``ToJson()`` method when you serialize your document.
127+
The following code example shows how to serialize a BSON document to Strict JSON:
128+
129+
.. code-block:: csharp
130+
131+
// Configure JsonWriterSettings
132+
var jsonWriterSettings = new JsonWriterSettings
133+
{
134+
OutputMode = JsonOutputMode.Strict
135+
};
136+
137+
// Serialize the document to JSON using the configured settings
138+
var json = document.ToJson(jsonWriterSettings);

0 commit comments

Comments
 (0)