Now Float is handled as a BSON double (as Double, as it’s now possible to have several Scala types corresponding to the same BSON type).
Still to make the API simpler, the BSON singleton types (e.g. BSONNull) are also defined with a trait, to be able to reference them without .type suffix.
Reader and writer typeclasses
As for the current BSON library, the new API provides an extensible typeclass mechanism, to define how to get and set data as BSON in a typesafe way.
The names of these typeclasses are unchanged (BSONReader and BSONWriter), except the package that is reactivemongo.api.bson (instead of reactivemongo.bson).
In the current BSON library, BSONReader and BSONWriter are defined with two type parameters:
B being the type of BSON value to be read/written,
and T being the Scala type to be handled.
The new API has been simplified, with only the T type parameter kept.
Not only it makes the API simpler, but it also allows to read different BSON types as a target Scala type (before only supported for numeric/boolean, using the dedicated typeclasses).
For example, the Scala numeric types (BigDecimal, Double, Float, Int, Long) can be directly read from any consistent BSON numeric type (e.g. 1.0 as integer 1), without having to use BSONNumberLike.
Also, handler functions readTry and writeTry returns Try, for a safer representation of possible failures.
The new API is also safer, replacing BSONReader.read and BSONWriter.write respectively with BSONReader.readTry and BSONWriter.writeTry, so that serialization errors can be handle at typelevel.
In a similar way, BSONObjectID.parse now returns Try.
Like the current BSON library, some specific typeclasses are available (with same names) to only work with BSON documents: BSONDocumentReader and BSONDocumentWriter.
Some new handlers are provided by default, like those for Java Time types.
Note: The handler for java.util.Date is replaced the handler for java.time.Instant.
The new library also provide similar macros, to easily materialized document readers and writers for Scala case classes and sealed traits.