Skip to content

BsonValue

Pure Kotlin implementation of opensavvy.ktmongo.bson.BsonValue.

The BSON specification only allows root documents, so it is not possible to instantiate this class directly with a complex structure. This class is used to decode the fields of a BsonDocument or the items of a BsonArray.

To instantiate a BsonDocument or BsonArray, see BsonFactory.

This page describes the BSON multiplatform implementation. To learn more about the general BSON operations, see opensavvy.ktmongo.bson.BsonValue.

This class is part of the BSON trinity:

Usage

If this BSON value is the serialized form of a Kotlin DTO, see decode.

This interface provides methods for decoding the different BSON native types, like decodeInt32, decodeObjectId and decodeInstant.

Some BSON types cannot be represented by a single Kotlin type, so multiple methods are provided to decode their components. For example: decodeRegularExpressionPattern and decodeRegularExpressionOptions.

Thread-safety

This class is not thread-safe. Although it is not possible to mutate its state, this class uses internal mutation to lazily decode the BSON stream.

Types

Serializer

Serializer for the multiplatform opensavvy.ktmongo.bson.multiplatform.BsonValue implementation.

Properties

factory

open override val factory: BsonFactory

type

open override val type: BsonType

Functions

decode

@LowLevelApi
open override fun <T> decode(type: KType): T

decodeArray

open override fun decodeArray(): BsonArray

decodeBinaryData

open override fun decodeBinaryData(): ByteArray

decodeBinaryDataType

open override fun decodeBinaryDataType(): UByte

decodeBoolean

open override fun decodeBoolean(): Boolean

decodeDateTime

open override fun decodeDateTime(): Long

decodeDBPointerId

open override fun decodeDBPointerId(): ObjectId

decodeDBPointerNamespace

open override fun decodeDBPointerNamespace(): String

decodeDecimal128Bytes

decodeDocument

open override fun decodeDocument(): BsonDocument

decodeDouble

open override fun decodeDouble(): Double

decodeInstant

open fun decodeInstant(): Instant

decodeInt32

open override fun decodeInt32(): Int

decodeInt64

open override fun decodeInt64(): Long

decodeJavaScript

open override fun decodeJavaScript(): String

decodeJavaScriptScope

open override fun decodeJavaScriptScope(): BsonDocument

Deprecated

This functionality is deprecated in the BSON specification. See https://bsonspec.org/spec.html

decodeMaxKey

open override fun decodeMaxKey()

decodeMinKey

open override fun decodeMinKey()

decodeNull

open override fun decodeNull(): Nothing?

decodeObjectId

open fun decodeObjectId(): ObjectId

decodeObjectIdBytes

@LowLevelApi
open override fun decodeObjectIdBytes(): ByteArray

decodeRegularExpressionOptions

open override fun decodeRegularExpressionOptions(): String

decodeRegularExpressionPattern

open override fun decodeRegularExpressionPattern(): String

decodeString

open override fun decodeString(): String

decodeSymbol

open override fun decodeSymbol(): String

decodeTimestamp

open override fun decodeTimestamp(): Timestamp

decodeUndefined

open override fun decodeUndefined()

decodeVector

open fun decodeVector(): Vector

equals

open operator override fun equals(other: Any?): Boolean

hashCode

open override fun hashCode(): Int

takeIfPresent

open fun takeIfPresent(): BsonValue?

toString

open override fun toString(): String