Skip to content

DOCSP-49867: Add JsonReader example #636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions source/data-formats/extended-json.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Read Extended JSON
------------------

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

.. io-code-block::
Expand Down Expand Up @@ -78,7 +78,7 @@ property:
API Documentation
-----------------

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

- `BsonDocument <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.BsonDocument.html>`__
Expand All @@ -87,5 +87,4 @@ documentation:
- `JsonWriter <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.JsonWriter.html>`__
- `JsonReader <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.JsonReader.html>`__
- `JsonWriterSettings <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.JsonWriterSettings.html>`__
- `JsonReaderSettings <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.JsonReaderSettings.html>`__
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Rishit and Boris, this isn't worth discussing.

- `JsonOutputMode <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.IO.JsonOutputMode.html>`__
6 changes: 2 additions & 4 deletions source/includes/fundamentals/code-examples/ExtendedJson.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using MongoDB.Bson;
using MongoDB.Bson.IO;
using MongoDB.Bson.Serialization;

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

var document = BsonSerializer.Deserialize<BsonDocument>(ejson);
var document = BsonDocument.Parse(ejson);
Console.WriteLine(document.ToJson());
// end-read-ejson
}

{
// start-write-ejson
var document = new MyDocument();
Expand Down
Loading