read

abstract fun read(name: String): BsonValueReader?(source)

Attempts to read a field named name.

If such a field exists, an instance of BsonValueReader is returned. If no such a field exists, null is returned.

Note that if a field exists and is null, a instance of BsonValueReader with a type of null is returned.


abstract fun <T : Any> read(type: KType, klass: KClass<T>): T?(source)

Reads this document into an instance of type.

If it isn't possible to deserialize this BSON to the given type, an exception is thrown.

This function is a low-level implementation detail. Prefer using the extension function of the same name, that takes no arguments. If type and klass refer to different types, the behavior is unspecified.