Questions tagged [bson]

BSON stands for "Binary JSON". It is a computer data interchange format used mainly as a data storage and network transfer format in the MongoDB database.

BSON [bee · sahn], short for Bin­ary JSON, is a bin­ary-en­coded seri­al­iz­a­tion of JSON-like doc­u­ments. Like JSON, BSON sup­ports the em­bed­ding of doc­u­ments and ar­rays with­in oth­er doc­u­ments and ar­rays. BSON also con­tains ex­ten­sions that al­low rep­res­ent­a­tion of data types that are not part of the JSON spec. For ex­ample, BSON has a Date type and a BinData type.

BSON can be com­pared to bin­ary inter­change for­mats, like Proto­col Buf­fers. BSON is more "schema-less" than Proto­col Buf­fers, which can give it an ad­vant­age in flex­ib­il­ity but also a slight dis­ad­vant­age in space ef­fi­ciency (BSON has over­head for field names with­in the seri­al­ized data).

BSON was de­signed to have the fol­low­ing three char­ac­ter­ist­ics:

  1. Lightweight

    Keep­ing spa­tial over­head to a min­im­um is im­port­ant for any data rep­res­ent­a­tion format, es­pe­cially when used over the net­work.

  2. Traversable

    BSON is de­signed to be tra­versed eas­ily. This is a vi­tal prop­erty in its role as the primary data rep­res­ent­a­tion for Mon­goDB.

  3. Efficient

    En­cod­ing data to BSON and de­cod­ing from BSON can be per­formed very quickly in most lan­guages due to the use of C data types.

Related Links

1403 questions
28
votes
2 answers

MongoDB BSON codec not being used while encoding object

I'm attempting to store an object in a MongoDB database (using MongoDB 3.0.2) and am getting a CodecConfigurationException when attempting to encode the object with error message Can't find a codec for class java.time.LocalDate. I have written…
desrepair
  • 521
  • 1
  • 4
  • 8
26
votes
4 answers

Fastest possible Javascript object serialization with Google V8

I need to serialize moderately complex objects with 1-100's of mixed type properties. JSON was used originally, then I switched to BSON which is marginally faster. Encoding 10000 sample objects JSON: 1807mS BSON: 1687mS MessagePack:…
user172783
25
votes
3 answers

import error: no module named bson

I'm trying to import json_util in my environment file: from bson import json_util I get this import error: no module named bson. I tried to pip install and uninstall pymongo and bson - but nothing seemed to help. I found out that the bson package…
Liad Amsalem
  • 413
  • 1
  • 6
  • 14
25
votes
4 answers

How can I use Python to transform MongoDB's bsondump into JSON?

So I have an enormous quantity of .bson from a MongoDB dump. I am using bsondump on the command line, piping the output as stdin to python. This successfully converts from BSON to 'JSON' but it is in fact a string, and seemingly not legal JSON. For…
Peter Nachbaur
  • 253
  • 1
  • 3
  • 6
24
votes
5 answers

npm install mongoose fails (kerberos and bson errors)

So I'm attempting to launch my node app, but there's a few errors arising from my MongoDB installation. Here are the specs for my dev environment: node => 0.10.33 (installed from nodejs.org) npm => 1.4.28 (installed from nodejs.org) git => 2.1.3…
Caleb Faruki
  • 2,577
  • 3
  • 30
  • 54
22
votes
2 answers

Is a binary JSON javascript library available for browsers?

In order for efficient server side parsing I am looking into a BSON solution directly for the browser javascript environment. The idea is to utilize the entire ASCII space by means of binary websockets. Any suggestions? (Any nodejs suggestions are…
Lorenz Lo Sauer
  • 23,698
  • 16
  • 85
  • 87
21
votes
2 answers

How do you select all records from a mongodb collection in golang using mgo

In MongoDB doing something like db.mycollection.find() returns all documents in a collection. When working in GoLang using the package labix.org/v2/mgo and I do for example: query := db.C("client").Find(); It complains that it requires input in the…
Dean
  • 1,226
  • 2
  • 20
  • 39
21
votes
1 answer

MongoDB Single Document size limit is 16MB

Known Information: Its is know that MongoDB stores in BSON (Binary JSON) and the maximum BSON document size is 16MB. Question: Why 16MB itself why not 32MB or 64MB or still more and where exactly the limit has been put for 16MB and what are the…
Amol M Kulkarni
  • 21,143
  • 34
  • 120
  • 164
20
votes
2 answers

The value of "offset" is out of range. It must be >= 0 && <= 17825792

You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection: RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 && <= 17825792. Received 17825796 at Buffer.write…
Mohamed Belkamel
  • 359
  • 1
  • 2
  • 8
20
votes
3 answers

Is there a way to store python objects directly in mongoDB without serializing them

I have read somewhere that you can store python objects (more specifically dictionaries) as binaries in MongoDB by using BSON. However right now I cannot find any any documentation related to this. Would anyone know how exactly this can be done?
chiffa
  • 2,026
  • 3
  • 26
  • 41
19
votes
6 answers

How to convert JSON to BSON using Json.NET

I have a string that contains a JSON. The only thing I know about this JSON is that it is valid. How to turn this string into BSON?
ebvtrnog
  • 4,167
  • 4
  • 31
  • 59
18
votes
4 answers

How to get ordered dictionaries in pymongo?

I am trying get ordered dictionaries in Pymongo. I have read it can be done with bson.son.Son. The Docs are Here However, I can't seem to make it work. There is not much on google about it. There are some discussions on configuring pymongo first…
fat fantasma
  • 7,483
  • 15
  • 48
  • 66
18
votes
1 answer

Unable to print BSON object from javascript

My mongoDB collection looks like this : { "_id" : ObjectId("5070310e0f3350482b00011d"), "emails" : [ { "_id" : ObjectId("5070310e0f3350482b000120"), "_type" : "Email", …
user1518659
  • 2,198
  • 9
  • 29
  • 40
17
votes
3 answers

What does the "0" mean in MongoDB's BinData(0, "e8MEnzZoFyMmD7WSHdNrFJyEk8M=")?

The MongoDB shell prints binary data as a Base64-encoded string wrapped in what looks like a function call: "_id" : BinData(0,"e8MEnzZoFyMmD7WSHdNrFJyEk8M=") What does the "0" mean?
Thilo
  • 257,207
  • 101
  • 511
  • 656
17
votes
1 answer

Java MongoDB/BSON class confusion

I'm trying to understand the BSON implementation used by the Java MongoDB driver (the official async one, in case that is important). However, I'm totally stuck on the classes representing BSON documents. I'm concentrating on the "normal" ones,…
Martin Geisse
  • 1,189
  • 1
  • 9
  • 22
1
2
3
93 94