当前位置:网站首页>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 .
边栏推荐
- Initial test of scikit learn Library
- 为抵制 7-Zip,列出 “三宗罪” ?网友:“第3个才是重点吧?”
- 中南大学|通过探索理解: 发现具有深度强化学习的可解释特征
- Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package
- AcWing 第58 场周赛
- 面试之 top k问题
- NSQ source code installation and operation process
- Learn from me about the enterprise flutter project: simplified framework demo reference
- Add color to the interface automation test framework and realize the enterprise wechat test report
- nifi从入门到实战(保姆级教程)——flow
猜你喜欢

TCP拥塞控制详解 | 3. 设计空间

Visual SLAM algorithms: a survey from 2010 to 2016

word 退格键删除不了选中文本,只能按delete

什么是质押池,如何进行质押呢?

于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日

为抵制 7-Zip,列出 “三宗罪” ?网友:“第3个才是重点吧?”

跟我学企业级flutter项目:简化框架demo参考

ThreeJS 第二篇:顶点概念、几何体结构

Explore Netease's large-scale automated testing solutions see here see here

Multithread 02 thread join
随机推荐
Unity项目优化案例一
【剑指 Offer】58 - I. 翻转单词顺序
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (I)
Initial test of scikit learn Library
TCP congestion control details | 3 design space
用通达信炒股开户安全吗?
AcWing 第58 场周赛
架构实战营 - 第 6 期 毕业总结
PHP CI (CodeIgniter) log level setting
无心剑中译泰戈尔《漂鸟集(1~10)》
Top k questions of interview
Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
"The NTP socket is in use, exiting" appears when ntpdate synchronizes the time
Client does not support authentication protocol requested by server; consider upgrading MySQL client
Yu Wenwen, Hu Xia and other stars take you to play with the party. Pipi app ignites your summer
Unreal_DataTable 实现Id自增与设置RowName
[web security] - [SQL injection] - error detection injection
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
Unity project optimization case 1
MySQL converts comma separated attribute field data from column to row