当前位置:网站首页>Difference between JSON and bson
Difference between JSON and bson
2022-07-03 16:34:00 【The clouds are idle】
BSON
BSON By 10gen Developed a data format , At present, it is mainly used for MongoDB in , yes MongoDB Data storage format .BSON be based on JSON Format , choice JSON The main reason for the transformation is JSON The generality of and JSON Of schemaless Characteristics of .
By definition :
BSON( Binary Serialized Document Format) Is a binary storage format , Similar to C The name of the language structure 、 For the representation , Support embedded document objects and array objects , Lightweight 、 Ergodicity 、 Characteristics of efficiency , It can effectively describe unstructured data and structured data .
BSON Is a kind JSON A storage format in binary form , abbreviation Binary JSON, It and JSON equally , Support embedded document objects and array objects , however BSON Yes JSON There are no data types , Such as Date and BinData type .
BSON It can be used as a storage form of network data exchange , This is a bit like Google Of Protocol Buffer, however BSON It's a kind of schema-less Storage form of , Its advantage is high flexibility , But its disadvantage is that the space utilization is not ideal .
in general :
BSON There are three characteristics : Lightweight 、 Ergodicity 、 Efficiency .
JSON
JSON yes JavaScript Object Notation An acronym for , The word means javascript Object notation , here json It means something similar to javascript A data format for an object .
Use JSON The format and parsing of can easily represent an object information ,json There are two formats :① Object format :{“key1”:obj,“key2”:obj,“key3”:obj…}、② Array / Set format :[obj,obj,obj…].
1. Faster traversal speed
Yes json Format , Too big json Structure can cause data traversal to be very slow . stay json in , To skip a document for data reading , This document needs to be scanned , The need for cumbersome data structure matching , For example, the matching of parentheses .
and BSON Yes json A big improvement of , It will be json The length of each element of exists in the head of the element , In this way, you only need to read the length of the element, and then you can seek Read at the specified point .
2. It's easier to operate
Yes JSON Come on , There is no type of data storage , For example, you need to modify the basic value , from 9 To 10, From one character to two , So maybe all the content behind it needs to be moved back one bit .
While using BSON, You can specify this column as a number column , So no matter the number from 9 Grow to 10 still 100, We're all just making changes on the one where the numbers are stored , It will not cause the total length of data to increase .
Of course , stay mongoDB in , If the number increases from plastic to long , The total length of data will increase .
3. Added additional data types
JSON Is a very convenient data exchange format , But its types are limited .
BSON On the basis of it, we add “byte array” data type . This eliminates the need for binary storage base64 After conversion, it will be saved as JSON, It greatly reduces the computation cost and data size .
Of course , Sometimes ,BSON relative JSON There is no advantage in space , For example, yes. {“field”:7}, stay JSON On the storage of 7 Only one byte is used , And if used BSON, That is at least 4 Bytes (32 position )
Currently in 10gen Under the efforts of ,BSON There are encoding and decoding packages for many languages . And are Apache 2 license Next open source . And still with mongoDB Further development .
边栏推荐
- Visual SLAM algorithms: a survey from 2010 to 2016
- SVN使用规范
- "The NTP socket is in use, exiting" appears when ntpdate synchronizes the time
- Unity项目优化案例一
- Golang decorator mode and its use in NSQ
- 疫情常态化大背景下,关于远程办公的思考|社区征文
- 爱可可AI前沿推介(7.3)
- Advanced Mathematics (Seventh Edition) Tongji University exercises 2-1 personal solutions
- What is the maximum number of concurrent TCP connections for a server? 65535?
- Basis of target detection (IOU)
猜你喜欢

斑马识别成狗,AI犯错的原因被斯坦福找到了
![[proteus simulation] 8 × 8LED dot matrix screen imitates elevator digital scrolling display](/img/46/c7f566f8fd46d383b055582d680bb7.png)
[proteus simulation] 8 × 8LED dot matrix screen imitates elevator digital scrolling display

8个酷炫可视化图表,快速写出老板爱看的可视化分析报告

2022爱分析· 国央企数字化厂商全景报告

Explore Cassandra's decentralized distributed architecture

面试官:JVM如何分配和回收堆外内存

Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package

Deep understanding of grouping sets statements in SQL

MySQL single table field duplicate data takes the latest SQL statement

PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
随机推荐
Expression of request header in different countries and languages
Svn usage specification
在ntpdate同步时间的时候出现“the NTP socket is in use, exiting”
8 tips for effective performance evaluation
Register in PHP_ Globals parameter settings
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (I)
Construction practice camp - graduation summary of phase 6
Explore Cassandra's decentralized distributed architecture
How to initialize views when loading through storyboards- How is view initialized when loaded via a storyboard?
记一次jar包冲突解决过程
Myopia: take off or match glasses? These problems must be understood clearly first
1287. Elements that appear more than 25% in an ordered array
QT serial port UI design and solution to display Chinese garbled code
Client does not support authentication protocol requested by server; consider upgrading MySQL client
(Supplement) double pointer topic
架构实战营 - 第 6 期 毕业总结
Extraction of the same pointcut
Zebras are recognized as dogs, and Stanford found the reason why AI made mistakes
IDEA-配置插件
Central South University | through exploration and understanding: find interpretable features with deep reinforcement learning