BsonValue¶
@Serializable(with = BsonValue.Serializer::class)
class BsonValue : 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.
Navigating BSON types¶
This class is part of the BSON trinity:
-
BsonDocumentrepresents an entire BSON document. -
BsonArrayrepresents an array of BSON values. -
BsonValuerepresents a single value in isolation.
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¶
object Serializer : KSerializer<BsonValue>
Serializer for the multiplatform opensavvy.ktmongo.bson.multiplatform.BsonValue implementation.
Properties¶
factory¶
open override val factory: BsonFactory
type¶
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¶
@LowLevelApi
open override fun decodeDecimal128Bytes(): ByteArray
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¶
hashCode¶
takeIfPresent¶
open fun takeIfPresent(): BsonValue?