Skip to content

Commit d8ea4a0

Browse files
committed
DOCS-808 port Mongo Extended JSON wiki page
1 parent 53933b1 commit d8ea4a0

File tree

3 files changed

+228
-0
lines changed

3 files changed

+228
-0
lines changed
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
# table structure. all content symbolic.
2+
section: layout
3+
header: [ meta.header1, meta.header2, meta.header3, meta.header4, meta.header5 ]
4+
rows:
5+
- 1: [ content.bson_bin, content.strict_bin, content.js_bin, content.mongo_bin, content.notes_bin ]
6+
- 2: [ content.bson_date, content.strict_date, content.js_date, content.mongo_date, content.notes_date ]
7+
- 3: [ content.bson_ts, content.strict_ts, content.js_ts, content.mongo_ts, content.notes_ts ]
8+
- 4: [ content.bson_regex, content.strict_regex, content.js_regex, content.mongo_regex, content.notes_regex ]
9+
- 5: [ content.bson_oid, content.strict_oid, content.js_oid, content.mongo_oid, content.notes_oid ]
10+
- 6: [ content.bson_ref, content.strict_ref, content.js_ref, content.mongo_ref, content.notes_ref ]
11+
- 7: [ content.bson_undef, content.strict_undef, content.js_undef, content.mongo_undef, content.notes_undef ]
12+
---
13+
# table metadata, as meta.<key>
14+
section: meta
15+
header1: "BSON Data Type"
16+
header2: "Strict Mode"
17+
header3: "JavaScript Mode"
18+
header4: "mongo Shell Mode"
19+
header5: "Notes"
20+
---
21+
# table content, as content.<key>
22+
section: content
23+
bson_bin: ".. bsontype:: data_binary"
24+
strict_bin: |
25+
.. code-block:: javascript
26+
27+
{
28+
"$binary": "<bindata>",
29+
"$type": "<t>"
30+
}
31+
js_bin: |
32+
.. code-block:: javascript
33+
34+
{
35+
"$binary": "<bindata>",
36+
"$type": "<t>"
37+
}
38+
mongo_bin: |
39+
.. code-block:: javascript
40+
41+
{
42+
"$binary": "<bindata>",
43+
"$type": "<t>"
44+
}
45+
notes_bin: |
46+
``<bindata>`` is the base64 representation of a binary
47+
string.
48+
49+
``<t>`` is the hexadecimal representation of a single byte
50+
that indicates the data type.
51+
bson_date: ".. bsontype:: data_date"
52+
strict_date: |
53+
.. code-block:: javascript
54+
55+
{
56+
"$date": <date>
57+
}
58+
js_date: |
59+
.. code-block:: javascript
60+
61+
Date( <date> )
62+
mongo_date: |
63+
.. code-block:: javascript
64+
65+
Date ( <date> )
66+
notes_date: |
67+
``<date>`` is the JSON representation of a 64-bit signed
68+
integer for milliseconds since epoch (unsigned before
69+
version 1.9.1).
70+
bson_ts: ".. bsontype:: data_timestamp"
71+
strict_ts: |
72+
.. code-block:: javascript
73+
74+
{
75+
"$timestamp":
76+
{
77+
"t": <t>,
78+
"i": <i>
79+
}
80+
}
81+
js_ts: |
82+
.. code-block:: javascript
83+
84+
{
85+
"$timestamp":
86+
{
87+
"t": <t>,
88+
"i": <i>
89+
}
90+
}
91+
mongo_ts: |
92+
.. code-block:: javascript
93+
94+
Timestamp( <t>, <i> )
95+
notes_ts: |
96+
``<t>`` is the JSON representation
97+
of a 32-bit unsigned integer
98+
for seconds since epoch.
99+
100+
``<i>`` is a 32-bit unsigned
101+
integer for the increment.
102+
bson_regex: ".. bsontype:: data_regex"
103+
strict_regex: |
104+
.. code-block:: javascript
105+
106+
{
107+
"$regex": "<sRegex>",
108+
"$options": "<sOptions>"
109+
}
110+
js_regex: |
111+
.. code-block:: javascript
112+
113+
/<jRegex>/<jOptions>
114+
mongo_regex: |
115+
.. code-block:: javascript
116+
117+
/<jRegex>/<jOptions>
118+
notes_regex: |
119+
``<sRegex>`` is a string of valid JSON characters.
120+
121+
``<jRegex>`` is a string that may contain valid JSON
122+
characters and unescaped double quote (``"``) characters, but may not
123+
contain unescaped forward slash (``/``) characters.
124+
125+
``<sOptions>`` is a string containing the regex options
126+
represented by the letters of the alphabet.
127+
128+
``<jOptions>`` is a string that may contain only the
129+
characters 'g', 'i', 'm' and 's' (added in v1.9). Because
130+
the ``JavaScript`` and ``mongo Shell`` representations
131+
support a limited range of options, any nonconforming
132+
options will be dropped when converting to this
133+
representation.
134+
bson_oid: ".. bsontype:: data_oid"
135+
strict_oid: |
136+
.. code-block:: javascript
137+
138+
{
139+
"$oid": "<id>"
140+
}
141+
js_oid: |
142+
.. code-block:: javascript
143+
144+
{
145+
"$oid": "<id>"
146+
}
147+
mongo_oid: |
148+
.. code-block:: javascript
149+
150+
ObjectId( "<id>" )
151+
notes_oid: |
152+
``<id>`` is a 24-character hexadecimal string.
153+
bson_ref: ".. bsontype:: data_ref"
154+
strict_ref: |
155+
.. code-block:: javascript
156+
157+
{
158+
"$ref": "<name>",
159+
"$id": "<id>"
160+
}
161+
js_ref: |
162+
.. code-block:: javascript
163+
164+
{
165+
"$ref" : "<name>",
166+
"$id" : "<id>"
167+
}
168+
mongo_ref: |
169+
.. code-block:: javascript
170+
171+
DBRef("<name>", "<id>")
172+
notes_ref: |
173+
``<name>`` is a string of valid JSON characters.
174+
175+
``<id>`` is a 24-character hexadecimal string. In the Strict
176+
and JS representations, the Strict representation for a
177+
:bsontype:`data_oid` can be used as the value.
178+
179+
bson_undef: ".. bsontype:: data_undefined"
180+
strict_undef: |
181+
.. code-block:: javascript
182+
183+
{
184+
"$undefined": true
185+
}
186+
js_undef: |
187+
.. code-block:: javascript
188+
189+
undefined
190+
191+
mongo_undef: |
192+
.. code-block:: javascript
193+
194+
undefined
195+
notes_undef: |
196+
The representation for the JavaScript/BSON undefined type.
197+
...

source/reference.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ General Reference
9292
:maxdepth: 1
9393

9494
reference/limits
95+
reference/mongodb-extended-json
9596
reference/glossary
9697

9798
.. seealso:: The :ref:`genindex` may provide useful insight into the
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
=====================
2+
MongoDB Extended BSON
3+
=====================
4+
5+
.. default-domain:: mongodb
6+
7+
MongoDB :doc:`import and export utilities
8+
</administration/import-export>` and MongoDB :wiki:`REST
9+
Interfaces<Http Interface>` support JSON-style access to MongoDB
10+
:term:`BSON` documents.
11+
12+
The REST interface supports three different modes for document output:
13+
14+
- *Strict* mode that produces output that conforms to the `JSON RFC
15+
specifications <http://www.json.org>`_.
16+
17+
- *JavaScript* mode that produces output that can be processed by most
18+
JavaScript interpreters.
19+
20+
- *mongo Shell* mode produces output that the :program:`mongo` shell
21+
understands. This is basically an enhanced JavaScript format.
22+
23+
MongoDB can understand all of these representations in REST input.
24+
25+
Special representations are used for :term:`BSON types` that do not
26+
have obvious JSON mappings, and multiple representations are allowed
27+
for some of these types. These types are displayed in the following
28+
table:
29+
30+
.. include:: /includes/table-mongodb-extended-json.rst

0 commit comments

Comments
 (0)