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
-2
votes
2 answers

How can I fix this error in my go project - undefined: bson.RegEx

I get the following error from my editor: undefined: bson.RegEx due to this line of code in my go project: regex := bson.M{"$regex": bson.RegEx{Pattern: id, Options: "i"}} Why am I getting this error and how can I resolve it? I've made sure that…
Brendan
  • 834
  • 1
  • 9
  • 20
-2
votes
1 answer

How can I get JSON from BSON without my keys all being named "Key"?

I'm trying to read from a database and then return the result to the user as json. What's happening is that I'm getting output like: [{"Key":"foo","Value":"bar"}] When I would like to get: "{"foo":"bar"}" How do I get the former? Example: (reading…
user773737
-2
votes
1 answer

Why Play Framework uses JSON why MongoDb uses BSON

I encountered many troubles of dealing with serializing/deserializing Scala data types to/from JSON objects and then store them to/from MongoDB in BSON form. 1st question: why Play Framework uses JSON why MongoDb uses BSON. 2nd question: If I am…
Luong Ba Linh
  • 802
  • 5
  • 20
-3
votes
2 answers

Getting error while deleting the key value from array of objects

I am getting the following error while deleting from key from array of JSON objects using Go. Error: repository/orderRepository.go:394:11: first argument to delete must be map; have interface {} repository/orderRepository.go:395:11: first…
user_agent
  • 65
  • 9
-3
votes
1 answer

Why json.RawMessage enlarge mongoDb document size?

The following codes try to insert new documents into mongoDB through go.mongodb.org/mongo-driver data := "this is test string blablablablablablabla" type Doc struct { Version int "json:version, bson:version" Data string …
zangw
  • 43,869
  • 19
  • 177
  • 214
-3
votes
1 answer

BSON Parse error?

I have looked through other posts and I have checked that I'm not using the wrong quotes, I feel like it's right in front of my face but can't see it! Trying to copy and paste data from local mongoDB to mLab but it's not working here's my JSON: { …
RioTz
  • 3
  • 1
  • 4
-3
votes
1 answer

Converting Struct to JSON where a field is another Struct

I have two structs struct: type A struct { Zip string `json:"zip"` } type B struct { Foo string `bson:"foo"` Bar A `json:"bar"` } When I try to json.Marshal the B type, the Bar field does not get converted correctly. The fields…
Daniel Ribeiro
  • 10,156
  • 12
  • 47
  • 79
-3
votes
1 answer

bson 4.0.0 gem error

I got this error while installing bson gem: (ruby 2.2.2, ubuntu 14.04 clean) ubuntu:/var/apps/real-fetcher$ gem install bson -v '4.0.0' Building native extensions. This could take a while... ERROR: Error installing bson: ERROR: Failed to build…
Igor
  • 1,253
  • 1
  • 25
  • 34
1 2 3
93
94