encodeToBsonValue

inline fun <T : Any> EJson.encodeToBsonValue(value: T): BsonValue

Serializes the given value into an equivalent BsonValue using a serializer retrieved from reified type parameter.

Throws

kotlinx.serialization.SerializationException

if the given value cannot be serialized to BSON.