Following this benchmark BSON needs more disk-space, time to create, serialize, deserialize and traverse all elements. The big advantage of BSON is, that it's much faster in traversing. So what's wrong with this benchmark?
BSON is also designed in a way that it has a comparatively faster encoding and decoding technique. For example, all those integers stored as 32-bit integers so that they are not parsed with them to and from the text. Therefore, it uses more space than JSON for smaller integers, but BSON is anyway much faster to parse.
BSON's binary structure encodes type and length information, which allows it to be parsed much more quickly.
For an integer field, the JSON length depends on the size of the number. "1" is just one byte. "1000000" is 7 bytes. In BSON both of these would be a 4 byte 32 bit integer.
BSON needs to be parsed as they are machine-generated and not human-readable. JSON has a specific set of data types—string, boolean, number for numeric data types, array, object, and null. Unlike JSON, BSON offers additional data types such as bindata for binary data, decimal128 for numeric.
Your question is unclear. Who claims that "The big advantage of BSON is, that it's much faster in traversing."? Wikipedia says that BSON is designed "to be efficient both in storage space and scan-speed" - but that only means that designers tried, not that they succeeded.
Note that the benchmark compares many JSON implementation, and there are both faster and slower ones; apparently somebody spent a lot of time writing optimized JSON parsers - indeed FastJson website explains (in Chinese, which I read through Google Translate) a number of advanced implementation techniques.
See also Performant Entity Serialization: BSON vs MessagePack (vs JSON)
Bottom line: the benchmark might be wrong or might also have nothing wrong. The authors suggest to try reproduce the data for your specific scenario, as is good practice in general, since benchmarks are just data points. So try running the benchmark for BSON and FastJSON (or what else has interesting performance for JSON) with data which is representative for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With