Skip to content

Commit 7478472

Browse files
authored
DOCSP-49867: Add JsonReader example (#636)
1 parent e45e033 commit 7478472

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

source/data-formats/extended-json.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Read Extended JSON
2828
------------------
2929

3030
You can read an Extended JSON documents into a {+language+} object by using the
31-
``BsonSerializer.Deserialize<T>()`` method. The following example reads an
31+
``BsonDocument.Parse()`` method. The following example reads an
3232
Extended JSON document into a ``BsonDocument`` object:
3333

3434
.. io-code-block::
@@ -78,7 +78,7 @@ property:
7878
API Documentation
7979
-----------------
8080

81-
To learn more about the methods and classes used on this page, see the following API
81+
To learn more about the methods and classes you can use to work with JSON documents, see the following API
8282
documentation:
8383

8484
- `BsonDocument <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.BsonDocument.html>`__
@@ -87,5 +87,4 @@ documentation:
8787
- `JsonWriter <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.JsonWriter.html>`__
8888
- `JsonReader <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.JsonReader.html>`__
8989
- `JsonWriterSettings <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.JsonWriterSettings.html>`__
90-
- `JsonReaderSettings <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.JsonReaderSettings.html>`__
9190
- `JsonOutputMode <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.JsonOutputMode.html>`__

source/includes/fundamentals/code-examples/ExtendedJson.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using MongoDB.Bson;
2-
using MongoDB.Bson.IO;
3-
using MongoDB.Bson.Serialization;
42

53
public class ExtendedJson
64
{
@@ -10,11 +8,11 @@ public static void Main(string[] args)
108
// start-read-ejson
119
var ejson = "{\n\"_id\": { \"$oid\": \"573a1391f29313caabcd9637\" },\n \"createdAt\": { \"$date\": { \"$numberLong\": \"1601499609\" }},\n\"numViews\": { \"$numberLong\": \"36520312\" }\n}\n\n";
1210

13-
var document = BsonSerializer.Deserialize<BsonDocument>(ejson);
11+
var document = BsonDocument.Parse(ejson);
1412
Console.WriteLine(document.ToJson());
1513
// end-read-ejson
1614
}
17-
15+
1816
{
1917
// start-write-ejson
2018
var document = new MyDocument();

0 commit comments

Comments
 (0)