-
Notifications
You must be signed in to change notification settings - Fork 79
/
faq.html
104 lines (91 loc) · 3.51 KB
/
faq.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>BSON (Binary JSON): FAQ</title>
<link rel="stylesheet" href="css/spec.css" type="text/css">
</head>
<body>
<h2 class="nojs">FAQ</h2>
<div class="info" id="faq">
<h3>What is the point of BSON when it is no smaller than
JSON in some cases?</h3>
<p>BSON is designed to be efficient in space, but in some
cases is not much more efficient than JSON. In some cases
BSON uses even more space than JSON. The reason for this
is another of the BSON design goals: traversability. BSON
adds some "extra" information to documents, like length of
strings and subobjects. This makes traversal faster.
</p>
<p>BSON is also designed to be fast to encode and
decode. For example, integers are stored as 32 (or 64) bit
integers, so they don't need to be parsed to and from
text. This uses more space than JSON for small integers,
but is much faster to parse.</p>
<p>In addition to compactness, BSON adds additional data
types unavailable in JSON, notably the BinData and
Date data types.</p>
<h3>What is a <tt>.bson</tt> file?</h3>
BSON files (by convention, using "<tt>.bson</tt>"
extension) contain zero or more BSON documents
written contiguously to a flat file. For example, the
MongoDB <tt>mongodump</tt>
utility outputs BSON files. The <a href="https://www.github.com/dwight/bsontools">bsontools</a>
utilities manipulate BSON files.
<h3>Where can I get more help/information?</h3>
<p>The best place to ask questions about BSON is on
the <a href="https://groups.google.com/group/bson">BSON
mailing list</a>.
<h3>How can I contribute or make fixes to this site?</h3>
<p>The best way to contribute to this site is to
fork the <a href="https://github.com/mongodb/bsonspec.org">bsonspec.org</a>
project on GitHub and submit a pull request.</p>
</div>
<h2>Examples</h2>
<div>
<p>The following are some example documents (in JavaScript
/ Python style syntax) and their corresponding BSON
representations.</p>
<table>
<tr>
<td>
<pre>
{"hello": "world"}
</pre>
</td>
<td> → </td>
<td><pre>
\x16\x00\x00\x00 // total document size
\x02 // 0x02 = type String
hello\x00 // field name
\x06\x00\x00\x00world\x00 // field value
\x00 // 0x00 = type EOO ('end of object')
</pre></td>
</tr><tr>
<td><pre>
{"BSON": ["awesome", 5.05, 1986]}
</pre></td>
<td> → </td>
<td><pre>
\x31\x00\x00\x00
\x04BSON\x00
\x26\x00\x00\x00
\x02\x30\x00\x08\x00\x00\x00awesome\x00
\x01\x31\x00\x33\x33\x33\x33\x33\x33\x14\x40
\x10\x32\x00\xc2\x07\x00\x00
\x00
\x00
</pre></td>
</tr></table>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-7301842-4");
pageTracker._trackPageview();
} catch(err) {}
</script>
</body>
</html>