@@ -6,6 +6,9 @@ BSON Operations
66
77.. default-domain:: mongodb
88
9+ .. meta::
10+ :keywords: document, BSON, serializer
11+
912.. contents:: On this page
1013 :local:
1114 :backlinks: none
@@ -44,7 +47,8 @@ The code samples in this guide use the following BSON document as an example:
4447Create a BSON Document
4548----------------------
4649
47- To build a BSON document in {+language+}, create an instance of the ``BsonDocument`` class.
50+ To build a representation of a BSON document in {+language+}, create an instance of the
51+ ``BsonDocument`` class.
4852The ``BsonDocument`` constructor accepts ``BsonElement`` arguments that map to the fields
4953and values in the document. Each ``BsonElement`` can be either an instance of the
5054``BsonElement`` class or a field-value pair inside curly braces ( ``{}`` ).
@@ -212,6 +216,22 @@ BSON document stored in ``myFile.bson``:
212216 ``System.IO.Stream`` object. This means that you can read or write any location
213217 that can be accessed by a stream.
214218
219+ Read and Write Other Formats
220+ ----------------------------
221+
222+ The preceding examples show how to read and write BSON data by using the
223+ ``BsonBinaryReader`` and ``BsonBinaryWriter`` classes. These classes implement the
224+ ``IBsonReader`` and ``IBsonWriter`` interfaces. To read and write data in other formats,
225+ the {+driver-short+} provides the following alternative implementations of the ``IBsonReader``
226+ and ``IBsonWriter`` interfaces:
227+
228+ - ``JsonReader`` and ``JsonWriter``: Read and write JSON data
229+ - ``BsonDocumentReader`` and ``BsonDocumentWriter``: Read and write BSON data
230+ contained in a ``BsonDocument`` object
231+
232+ Because these classes implement the same interfaces, you can call their methods in the same way
233+ as the preceding ``BsonBinaryReader`` and ``BsonBinaryWriter`` examples.
234+
215235.. _csharp-bson-api:
216236
217237API Documentation
@@ -224,3 +244,5 @@ guide, see the following API documentation:
224244- `BsonElement <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.BsonElement.html>`__
225245- `BsonBinaryReader <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.BsonBinaryReader.html>`__
226246- `BsonBinaryWriter <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.BsonBinaryWriter.html>`__
247+ - `IBsonReader <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.IBsonReader.html>`__
248+ - `IBsonWriter <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.IBsonWriter.html>`__
0 commit comments