encodeToBsonValue

fun <T> encodeToBsonValue(serializer: SerializationStrategy<T>, value: T): BsonValue

Serializes the given value into an equivalent BsonValue using the given serializer

Throws

kotlinx.serialization.SerializationException

if the given value cannot be serialized to EJSON