NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
pub.dev · #1736 most downloaded on pub.dev
Bson library for Dart. BSON is a binary-encoded serialization of JSON-like documents. The package allows also eJson and object serialization/deserialization.
Last release 8 months ago
26 Jan 2026
Release timing varies
gaps range from 8 days to 9 months
Some releases are documented
notes for 20 of 47 stable releases
Nothing withdrawn
no release was ever pulled
13 years old
59 releases · first in 2013
Fix ObjectId generation producing duplicate IDs across process restarts. The setIntExtended method was not advancing the buffer offset after writing,
setIntExtended method was not advancing the buffer offset after writing, causing the counter bytes to overwrite the random value bytes instead of being written to the correct position.- Fix more casts - PR #45
One column per quarter.
- Fix Timestamp cast - PR #44
- Update dpendencies
LegacyUuid class. It allows to manage Binary Subtype 3 Bson types (Uuid Old). The class holds the value in the storing format, some helpers are availa
Fixed some inconsistencies with dart2js
Fixed some inconsistencies with dart2js
double.NaN is stored in a different way in VM and JS, forced the VM way.double.infinity and double.negativeInfinity in JS were considered as int, forced to be considered as double.It has not been found a way to let the system detect correctly double variabls when the values has no decimals. JS in this case considers the field as an int.
The only way to solve this, is to send the double fields wrapped into a BsonDobule object.
Fixed issue while decoding a bson binary containing an empty Map
Fixed issue while decoding a bson binary containing an empty List
This release contains many breaking changes. Here is a list of the most noticeable:
This release contains many breaking changes. Here is a list of the most noticeable:
BSON has been deprecated in favor of BsonCodec
In general the logic is changed so that the document to be encoded should contain normal "Dart object" and the document returned will do the same. In input the system will continue to accept BsonObjects anyway, the issue can be with the returned Objects. At present the more important exceptions are ``BsonBinaryandDbPointer`. This also measn that the BSON classes are not automatically exported in the package, if needed you should import them from the src/types/ folder
To address the above logic some new classes have been created: JsCode and DbRef.
The DbRef values were stored as DbPointers. Now they are stored correctly as a particular type of Map (contains $ref and $id elements). Beware that, if you have stored Dbref values, now they will be returnde as DbPointers.
Also an optional $db value is accepted and managed from the new DbRef class.
The JsCode class is used to clearly separate normal Strings from Javascript code.
The RegExp class is used instead of the BsonRegexp one.
The DbPointer class is deprecated (as per Bson specifications).
dataSize() and byteLenght() have been deprecated in favor of contentLength and totalByteLength getters.
the Bson classes now are intended to be used internally, so they are no more exported explicitly in the bson package.
BsonBinary.setInExtended now supports also 5 and 7 bytes aside of the already managed 3 bytes. Corrected the endian logic, now Endian.little is the default.
Class ObjectId:
ClientMode parameter.$oid getter renamed as oid. It is more practical in string interpolationThe logic for the increment part was not correct in the Timestamp class
Added toJson method to DbRef, JsCode and Timestamp classes
- Reviewed the ObjectId class - Reviewed the Timestamp class
Deprecated ObjectId.toHexString() in favor of the ObjectId.oid getter
ObjectId.toHexString() in favor of the ObjectId.oid getterAdded EJson.stringify() method.
EJson.stringify() method.EJson.parse() method.- code clean-up - updated README
Moved back Date to UTC, it is a BSON requirement.
Removed old deprecated typeByte consts.
Completed ejson creation. Still missing tests and docs. Some base classes have been revisited, and there can be some breaking changes, this is the rea…
Completed ejson creation. Still missing tests and docs. Some base classes have been revisited, and there can be some breaking changes, this is the reason of the change in release number.
Created eJson2doc and doc2eJson methods
Experimental - Ejson management - Only for types ObjectId, int and date
Breaking Change. The BsonLong class is now backed by an Int64 field. BsonLong object returned from the server will always be returned as Int64. Int va…
Int64 field. BsonLong object returned from the server will always be returned as Int64. Int values passed to the server will be passed as int32 if below the int32 limit, otherwise as int64 objects. The BsonObject.bsonObjectFrom() method now also accept Int64 and Int32 Objects. This change was needed to avoid the limits that the int type has on the web apps.Added isValidHexId() to ObjectId class
isValidHexId() to ObjectId classTryParse() to ObjectId classReorganization and adoption of Decimal 2.3.0 that contains potential breaking changes
Temporary fix for breaking change in Decimal 2.3.0
- Lint fix
Moving to the most recent version of the Rational class, a Breaking change had been introduced. We have decided to substitute the Rational class with…
Moving to the most recent version of the Rational class, a Breaking change had been introduced. We have decided to substitute the Rational class with the Decimal one, because the latter, that it is a wrapper around the former, contains more user friendly methods. You can always get a Rational instance, if needed, calling the toRational() method of theDecimal class.
Switched to Lints from Pedantic
Timestamp class into a new Timestamp and a bsonData BsonTimestamp.Removed the wrapper class UuidValue. Now we are using the original class from the Uuid package.
Fixed error preventing null values serialization
- Fix on Uuid management
A Breaking change in relation to Uuid management. As uuid_type package wasn't yet ported to null-safety, I moved to the widely used uuid one. The name…
A Breaking change in relation to Uuid management. As uuid_type package wasn't yet ported to null-safety, I moved to the widely used uuid one. The name of the class is no more Uuid (in uuid package Uuid is the generator class), but UuidValue. I had to make a custom version of UuidValue because it was missing some functionalities, but I hope that the standard package will adopt this changes in a near future. This is why I left the name as UuidValue instead of the more intuitive Uuid.
- Updated dependencies
constants have been renamed to a more "dartish" style (camelCase), but the old version is still available even if deprecated.
This is a preliminary port to the null-safety feature for the bson package. It is not production ready yet.
Please, report any issue you encounter if you have time to test it.
Moving to null safety has lead to consider a new approach to writing this driver. The idea came from reading the Decimal128 specs, that requires the BsonObject representing the mongoDb type, to be immutable and the language specific class used to manage the value to be different from the Bson Object. This is in contrast with the actual way the driver is written. You can see the unpack method, that changes the value of the class itself or the BsonBinary class where the byteList is continually updated when writing on it as a buffer. Nothing wrong with this, we are simply looking for a better (in terms of readability and maintainence) way of writing the classes. So, considering this, our goal is to make Bson Type classes immutable and distinct from the language type ones. In this release whe have made some changes in order to prepare for a future major change. We have not yet proceeded mainly for two reasons:
More in detail, plus or minus all Bson classes have been changed, removing the empty constructor, when possible, and reducing the cases in which they can be updated after creation. The only Bson classes that have a constructor that accepts a null value are those that are capable of creating a default value (like BsonDecimal128, for instance).
I would like to point out the main changes in the following three classes that, on my opinion, could generate some incompatibility issues:
BsonObject
BsonObject has been made abstract. I do not expect this to be a big issue, because it was of no use to create a BsonObject directly, anyway, if there is a case that I cannot foresee, this can be a issue to be fixed.bsonObjectFrom method has been transformed into a factory constructor.bsonObjectFromTypeByte method has been transfomed into the fromTypeByteAndBuffer factory constructor, that requires, aside of the type byte, also the buffer.elementSize has been moved into the BsonObject class as static method.ObjectId
ObjectId class have benn decoupled, and a new class (BsonObjectId) have been created.ObjectId class is no more extending the BsonObject one. As a result the following methods/getters have been removed:
typeByte (getter)value (getter)byteLength() (method)packValue() (method)unpackMethod() (method)BsonBinary
makeHexString() method or the makeByteList() ones. They are called when needed. Theese method are still available (even if deprecated), but do not update the BsonBinary class, they only returns the calculated value.byteList, hexString and byteArray setters have been removed.Aside of the null-safety changes, a new Bson type has been managed: The UUIDone. Like the Decimal128 type, it should be considered experimental.
Experimental management of Bson Type Decimal 128
Experimental management of Bson Type Decimal 128
Decimal128 Bson type. To be considered experimental. As in Dart there is not a corresponding Decimal128 type, we have used the Rational class (pub Rational), that allows to deal with rational numbers with no limits.Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →