Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB JSON or BSON?

Tags:

mongodb


I'm just learning MongoDB but I'm a bit puzzled about the data format accepted by MongoDB. So I understand that by definition:

"MongoDB doesn’t actually use JSON to store the data; rather, it uses an open data format developed by the MongoDB team called BSON"

That's clear, however I have just learnt that you can actually import a JSON document into mongodb. So is it correct to say that you can use JSON format to insert data into MongoDB but data internally is arranged into BSON for performance reasons ? Hope that somebody can shed some light on it.

like image 755
user2824073 Avatar asked Jan 10 '23 02:01

user2824073


2 Answers

Yes, that is correct. MongoDB uses BSON to increase performance. See http://docs.mongodb.org/manual/core/document/.

There are various drivers that make it easy to work with MongoDB. In most cases you dont have to worry about BSON, since it is handled for you.

like image 151
Ewald Stieger Avatar answered Jan 15 '23 19:01

Ewald Stieger


Not really for "performance".

BSON is an explanative version of JSON which allows the storage and manipulation of objects such as ISODate and OjbectId. It allows for MongoDB to produe a syntax and object rich document beyond what JSON can.

BSON normally takes more space than JSON due to its object usage and what not as such there is no serious performance gain. It is about the descriptive objects that can be used and sored with the document.

MongoDB communicates entirely in BSON, including query results.

like image 28
Sammaye Avatar answered Jan 15 '23 18:01

Sammaye