@@ -6,6 +6,9 @@ BSON Operations
6
6
7
7
.. default-domain:: mongodb
8
8
9
+ .. meta::
10
+ :keywords: document, BSON, serializer
11
+
9
12
.. contents:: On this page
10
13
:local:
11
14
:backlinks: none
@@ -44,7 +47,8 @@ The code samples in this guide use the following BSON document as an example:
44
47
Create a BSON Document
45
48
----------------------
46
49
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.
48
52
The ``BsonDocument`` constructor accepts ``BsonElement`` arguments that map to the fields
49
53
and values in the document. Each ``BsonElement`` can be either an instance of the
50
54
``BsonElement`` class or a field-value pair inside curly braces ( ``{}`` ).
@@ -212,6 +216,22 @@ BSON document stored in ``myFile.bson``:
212
216
``System.IO.Stream`` object. This means that you can read or write any location
213
217
that can be accessed by a stream.
214
218
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
+
215
235
.. _csharp-bson-api:
216
236
217
237
API Documentation
@@ -224,3 +244,5 @@ guide, see the following API documentation:
224
244
- `BsonElement <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.BsonElement.html>`__
225
245
- `BsonBinaryReader <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.BsonBinaryReader.html>`__
226
246
- `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