@@ -137,7 +137,7 @@ an example Extended JSON string into a ``Document`` object using the
137
137
String ejsonStr = "{ \"_id\": { \"$oid\": \"507f1f77bcf86cd799439011\"}," +
138
138
"\"myNumber\": {\"$numberLong\": \"4794261\" }}}";
139
139
140
- Document doc = new Document(Document .parse(ejsonStr) );
140
+ Document doc = Document.parse(ejsonStr);
141
141
System.out.println(doc);
142
142
143
143
The output of the code above resembles the following:
@@ -203,31 +203,31 @@ Using the Document Classes
203
203
~~~~~~~~~~~~~~~~~~~~~~~~~~
204
204
205
205
You can write an Extended JSON string from an instance of ``Document`` or
206
- ``BsonDocument`` by calling the ``toJson()`` method, passing it an instance of
207
- ``JsonWriterSettings`` to specify the Extended JSON format.
206
+ ``BsonDocument`` by calling the ``toJson()`` method, optionally passing it an
207
+ instance of ``JsonWriterSettings`` to specify the Extended JSON format.
208
208
209
- In this example, we output the Extended JSON in the "Shell " format.
209
+ In this example, we output the Extended JSON in the "Relaxed " format.
210
210
211
211
.. code-block:: java
212
212
213
213
Document myDoc = new Document();
214
214
myDoc.append("_id", new ObjectId("507f1f77bcf86cd799439012")).append("myNumber", 11223344);
215
215
216
- JsonWriterSettings settings = JsonWriterSettings.builder().outputMode(JsonMode.SHELL ).build();
216
+ JsonWriterSettings settings = JsonWriterSettings.builder().outputMode(JsonMode.RELAXED ).build();
217
217
System.out.println(doc.toJson(settings));
218
218
219
219
The output of this code example resembles the following:
220
220
221
221
.. code-block:: none
222
222
:copyable: false
223
223
224
- {"_id": ObjectId("507f1f77bcf86cd799439011") , "myNumber": NumberLong(4794261) }
224
+ {"_id": {"$oid": "507f1f77bcf86cd799439012"} , "myNumber": 11223344 }
225
225
226
226
Using the BSON Library
227
227
~~~~~~~~~~~~~~~~~~~~~~
228
228
229
- You can also read an Extended JSON string into Java objects using the BSON
230
- library directly with the :java-docs:`JsonWriter </apidocs/bson/org/bson/json/JsonWriter.html>`
229
+ You can also output an Extended JSON string from data in Java objects using
230
+ the BSON library with the :java-docs:`JsonWriter </apidocs/bson/org/bson/json/JsonWriter.html>`
231
231
class. To construct an instance of ``JsonWriter``, pass a subclass of a Java
232
232
``Writer`` to specify how you want to output the Extended JSON. You can
233
233
optionally pass a :java-docs:`JsonWriterSettings </apidocs/bson/org/bson/json/JsonWriterSettings.html>`
0 commit comments