About JSON and BSON

Share via:

About JSON and BSON

Both JSON and BSON are data interchange formats used for the representation and transmission of data between applications.
JSON: (Java script Object Notation)
It is text based format that is lightweight and also human readable format.
Based on the javascript syntax and is mostly used in web applications.
It supports some basic data types like
1.Numeric
2.String
3.Array
4.Null
5.Boolean
6.Object (JSON object)

Advantages of JSON:
1.Faster
2.Structured data
3.readable
4.this type of abstract data type can be created in multiple programming languages.

Applications
1.Web applications
2.Log messages
3.Configuration files

BSON: (Binary JSON)
It is a binary format that is used for retrieval and storing of data in MongoDB.
BSON is a binary format,so it is not in human readable format.
BSON is more efficient in terms of processing and storing the data because it needs less parsing time and also less serialization and deserialization time.
BSON is a superset of JSON; it supports some additional data types which are most commonly used.
BSON is having three characteristics.
1.Light weight
2.Traversable
3.Efficient

Advantages of BSON
1.Scan speed is high compared with JSON
2.Faster encoding and decoding techniques
3.Advance indexing
4.Extra data types compared with JSON.
Example:

Data types supported by BSON in MongoDB:
In MongoDB documents are stored in the form of binary JSON format i.e., BSON.
Using of BSON will provide more data types which are not in JSON.
The BSON format support different data types that are explained below.
1. String: It is the most commonly used data type. The string data type in MongoDB is used to hold textual data. In MongoDB, strings are represented as UTF-8-encoded character sequences and can have a maximum length of 16Mb.The strings in MongoDB must be UTF-8 valid. The string fields are enclosed in double quotes.
2. Integer: It is used to hold the numeric values. This integer datatype is of two forms i.e., 32-bit and 64-bit signed int it depends on the server.
3.Double: It is used to hold the floating-point values with double precision.it is a 64-bit floating-point number.
4.Null: It is used to store null values. It can be used in any field of a MongoDB document.
5.Boolean: It is used to hold the Boolean values. They are of two values i.e., true or false. Used for filtering and conditional operations.
6. Object: It is used to store the embedded documents.
Embedded documents: Documents which contain a document inside the other document. It is also called a nested document.
7.Object id: Object id is used to represent a unique identifier for a document.it is automatically created by MongoDB whenever you create a new document in the database. It holds a 12-byte hexadecimal id in it.
8.Array: It is used to store a list of values into a single field.it stores the values of same datatype or different data types.it is created by using the square brackets
9.Binary Data: It is used to store binary data like images, videos and audio files.it is represented using binary objects in MongoDB.
10.Date: It is used to store date and timestamps. The date can be returned as the string or the date object. If the given value of date is negative, then it will be represented as the date before 1970.
11.Min & Max key: These are used to represent the highest and lowest possible values for a key in the index. These are internal data types. This data type is not meant for the storing of the data.
12.Symbol: It is used to store a unique identifier that can be used to represent a value in the database. This is a fixed size data type used to represent the string values that are unique in the entire database.
13.Regular expressions: It is used to store the regular expressions. This datatype is used for string matching and string manipulation.
14.Java script Code: It is a wrapper object that will store the java script code in the document of MongoDB. Used for defining stored functions and also for implementing server-side processing.
15.Time stamp: It is a 64-bit integer, it is used to represent time value in seconds. The value of timestamp is always unique. Used when modifying the data.

 

Author    : Teja

LinkedIn : https://www.linkedin.com/in/teja-sai-nadh-reddy-tatireddy-048882201

Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates

KTExperts is always active on social media platforms.

Facebook  : https://www.facebook.com/ktexperts/
LinkedIn    : https://www.linkedin.com/company/ktexperts/
Twitter       : https://twitter.com/ktexpertsadmin
YouTube   :  https://www.youtube.com/c/ktexperts
Instagram  : https://www.instagram.com/knowledgesharingplatform

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Add Comment