read

abstract fun read(index: Int): BsonValueReader?(source)

Attempts to read an element at index index.

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

Note that if an element 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.

T should be a type that can contain elements, such as List<Int> or Set<User>.

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