Repository navigation
Expand file tree
/
Copy pathfaq.html
More file actions
103 lines (90 loc) · 5.02 KB
/
Copy pathfaq.html
File metadata and controls
103 lines (90 loc) · 5.02 KB
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
<!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">
<script type="text/javascript">
(function(e,c){if(!c.__SV){var l,h;window.mixpanel=c;c._i=[];c.init=function(q,r,f){function t(d,a){var g=a.split(".");2==g.length&&(d=d[g[0]],a=g[1]);d[a]=function(){d.push([a].concat(Array.prototype.slice.call(arguments,0)))}}var b=c;"undefined"!==typeof f?b=c[f]=[]:f="mixpanel";b.people=b.people||[];b.toString=function(d){var a="mixpanel";"mixpanel"!==f&&(a+="."+f);d||(a+=" (stub)");return a};b.people.toString=function(){return b.toString(1)+".people (stub)"};l="disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders start_session_recording stop_session_recording people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(" ");
for(h=0;h<l.length;h++)t(b,l[h]);var n="set set_once union unset remove delete".split(" ");b.get_group=function(){function d(p){a[p]=function(){b.push([g,[p].concat(Array.prototype.slice.call(arguments,0))])}}for(var a={},g=["get_group"].concat(Array.prototype.slice.call(arguments,0)),m=0;m<n.length;m++)d(n[m]);return a};c._i.push([q,r,f])};c.__SV=1.2;var k=e.createElement("script");k.type="text/javascript";k.async=!0;k.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===
e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";e=e.getElementsByTagName("script")[0];e.parentNode.insertBefore(k,e)}})(document,window.mixpanel||[])
mixpanel.init('f2a38f26e5cc0eee429a9276f296c118', {
autocapture: true,
record_sessions_percent: 0,
})
</script>
</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>
</body>
</html>