You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/data-formats/extended-json.txt
+100Lines changed: 100 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -26,10 +26,110 @@ set of keys prefixed with "``$``" to represent field type information that
26
26
directly corresponds to each type in BSON, the format that MongoDB uses to
27
27
store data.
28
28
29
+
Extended JSON Formats
30
+
---------------------
31
+
32
+
MongoDB Extended JSON features different string formats to represent BSON data.
33
+
Each of the different formats conform to the JSON RFC
34
+
and meet specific use cases. The **extended** format, also known as the
35
+
**canonical** format, features specific representations for every BSON type
36
+
for bidirectional conversion without loss of information. The **Relaxed mode**
37
+
format is more concise and closer to ordinary JSON, but does not represent
38
+
all the type information such as the specific byte size of number fields.
39
+
40
+
See the following table to see a description of each format:
41
+
42
+
.. list-table::
43
+
:header-rows: 1
44
+
:stub-columns: 1
45
+
:widths: 10 40
46
+
47
+
* - Name
48
+
- Description
49
+
50
+
* - **Extended**
51
+
- | Also known as the *canonical* format, this JSON representation avoids loss of BSON type information.
52
+
| This format prioritizes type preservation at the loss of human-readability and interoperability with older formats.
53
+
54
+
* - **Relaxed Mode**
55
+
- | JSON representation that describes BSON documents with some type information loss.
56
+
| This format prioritizes human-readability and interoperability at the loss of certain type information.
57
+
58
+
* - **Shell**
59
+
- | JSON representation that matches the syntax used in the MongoDB shell.
60
+
| This format prioritizes compatibility with the MongoDB shell which often uses JavaScript functions to represent types.
61
+
62
+
* - **Strict**
63
+
- | *Deprecated.* This representation is the legacy format that fully conforms to the `JSON RFC <http://www.json.org/>`__ which allows any JSON parser to read the type information.
64
+
| The legacy API uses this format.
65
+
66
+
.. _extended_json_example_section:
67
+
68
+
.. note::
69
+
70
+
The driver parses the ``$uuid`` Extended JSON type from a string to a
71
+
``BsonBinary`` object of binary subtype 4. For more information about ``$uuid`` field
72
+
parsing, see the
73
+
:spec:`special rules for parsing $uuid fields </extended-json.rst#special-rules-for-parsing-uuid-fields>`
74
+
section in the extended JSON specification.
75
+
29
76
To learn more about JSON, BSON, and Extended JSON, see
30
77
`our article about JSON and BSON <https://www.mongodb.com/resources/basics/json-and-bson>`__
31
78
and :manual:`Extended JSON </reference/mongodb-extended-json/>` in the {+mdb-server+} manual.
32
79
80
+
Extended JSON Examples
81
+
~~~~~~~~~~~~~~~~~~~~~~
82
+
83
+
The following examples show a document containing an ObjectId, date, and long
84
+
number field represented in each Extended JSON format. Click the tab that
85
+
corresponds to the format of the example you want to see:
0 commit comments