Skip to content

Commit 57b5029

Browse files
committed
Technical feedback
1 parent a25be85 commit 57b5029

File tree

2 files changed

+3
-34
lines changed

2 files changed

+3
-34
lines changed

source/data-formats/extended-json.txt

Lines changed: 2 additions & 18 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::
@@ -44,22 +44,6 @@ Extended JSON document into a ``BsonDocument`` object:
4444

4545
{ "_id" : { "$oid" : "573a1391f29313caabcd9637" }, "createdAt" : { "$date" : "1970-01-19T12:51:39.609Z" }, "numViews" : 36520312 }
4646

47-
Alternatively, you can use the ``JsonReader`` class to read Extended JSON documents
48-
into other formats such as ``BsonDocument``, as shown in the following example:
49-
50-
.. io-code-block::
51-
52-
.. input:: /includes/fundamentals/code-examples/ExtendedJson.cs
53-
:language: csharp
54-
:start-after: start-read-ejson-reader
55-
:end-before: end-read-ejson-reader
56-
:dedent:
57-
58-
.. output::
59-
:visible: false
60-
61-
{ "_id" : { "$oid" : "573a1391f29313caabcd9637" }, "createdAt" : { "$date" : "1970-01-19T12:51:39.609Z" }, "numViews" : 36520312 }
62-
6347
Write Extended JSON
6448
-------------------
6549

@@ -94,7 +78,7 @@ property:
9478
API Documentation
9579
-----------------
9680

97-
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
9882
documentation:
9983

10084
- `BsonDocument <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.BsonDocument.html>`__

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

Lines changed: 1 addition & 16 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,24 +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
}
1715

18-
{
19-
// start-read-ejson-reader
20-
var ejson = "{\n\"_id\": { \"$oid\": \"573a1391f29313caabcd9637\" },\n \"createdAt\": { \"$date\": { \"$numberLong\": \"1601499609\" }},\n\"numViews\": { \"$numberLong\": \"36520312\" }\n}\n\n";
21-
var subject = new BsonDocumentSerializer();
22-
using (var reader = new JsonReader(ejson))
23-
{
24-
var context = BsonDeserializationContext.CreateRoot(reader);
25-
var document = subject.Deserialize<BsonDocument>(context);
26-
Console.WriteLine(document.ToJson());
27-
}
28-
// end-read-ejson-reader
29-
}
30-
3116
{
3217
// start-write-ejson
3318
var document = new MyDocument();

0 commit comments

Comments
 (0)