Introduction to JSON & BSON in MongoDB

Last updated on Mar 20,2024 8.4K Views

Introduction to JSON & BSON in MongoDB

edureka.co

What is JSON?

JSON is JavaScript Object Notation. It is a light-weight data interchange format, which can get transferred from one system to the other easily. It is easy to read and write this format. It is also not a complex task for machines to parse and generate. The text format is completely language independent.

At high level, JSON will have two things- An object and an array. An object is a collection of name/value pairs and an array is an ordered list of values.With the combination of two, you can have a complete JSON structure. The maximum amount of documents that one can embed in a document is 100. This is a very important factor while working with MongoDB.

So an object will start with curly braces and end with curly braces and then comes the key and value. An array will start with the normal, non-curly brackets, then comes value and comma. There are data types that can be supported. See the image below to understand it better.

What is BSON?

BSON is nothing but Binary JSON i.e Binary JavaScript Object Notation. Unlike JSON, it is not in a readable format. It supports the embedding of documents and arrays within other documents and arrays. Like JSON, it is easy for machines to parse and generate. For more information on both these topics, you can always get an insight from various sources. When you check the websites for information, you will see the difference in JSON and BSON and understand how different the two are in terms of readability.

If you wish to learn MongoDB or SQL and build a career in the Database User Roles and Database Administration Roles, then check out our interactive, live-online MongoDB Online Course  or SQL online course here, which comes with 24*7 support to guide you throughout your learning period.

Got a question for us? Mention them in the comments section and we will get back to you.

Related Posts:

Understanding Journaling in MongoDB

Get started with MongoDB

BROWSE COURSES
REGISTER FOR FREE WEBINAR SQL For Data Science Tutorial