Skip to content

Kotlin BSON • Multiplatform abstraction for different BSON implementationsopensavvy.ktmongo.bsonBsonDocumentReader

BsonDocumentReader

@LowLevelApi
interface BsonDocumentReader

Utilities for decomposing a Bson document into its fields.

To obtain an instance of this interface, see Bson.reader.

Example

val bson: Bson = 

for ((name, field) in bson.read().entries) {
    println("Field: $name${field.type}")
}

Properties

entries

abstract val entries: Map<String, BsonValueReader>

A map allowing to go through all key-value pairs in the document.

Functions

asValue

abstract fun asValue(): BsonValueReader

Reads this entire document as a BsonValueReader.

read

abstract fun read(name: String): BsonValueReader?

Attempts to read a field named name.

toBson

abstract fun toBson(): Bson

Reads this document into a Bson instance.

toString

abstract override fun toString(): String

JSON representation of the document this BsonDocumentReader is reading, as a String.