When decoding a SerialKind.OBJECT the BsonFlexibleDecoder does not start the document read, but it does end it.
https://github.com/jershell/kbson/blob/master/src/main/kotlin/com/github/jershell/kbson/BsonFlexibleDecoder.kt#L61
This causes the following error when attempting to decode objects even if they are {} in the database:
org.bson.BsonInvalidOperationException: readEndDocument can only be called when ContextType is DOCUMENT or SCOPE_DOCUMENT, not when ContextType is TOP_LEVEL.
at org.bson.AbstractBsonReader.throwInvalidContextType(AbstractBsonReader.java:654)
at org.bson.AbstractBsonReader.readEndDocument(AbstractBsonReader.java:347)
at com.github.jershell.kbson.FlexibleDecoder.endStructure(BsonFlexibleDecoder.kt:61)
at kotlinx.serialization.internal.ObjectSerializer.deserialize(ObjectSerializer.kt:57)
at kotlinx.serialization.encoding.Decoder$DefaultImpls.decodeSerializableValue(Decoding.kt:257)
at kotlinx.serialization.encoding.AbstractDecoder.decodeSerializableValue(AbstractDecoder.kt:16)
at com.application.codec.CustomCodec.decode(CustomCodec.kt:71)
...
When decoding a
SerialKind.OBJECTtheBsonFlexibleDecoderdoes not start the document read, but it does end it.https://github.com/jershell/kbson/blob/master/src/main/kotlin/com/github/jershell/kbson/BsonFlexibleDecoder.kt#L61
This causes the following error when attempting to decode objects even if they are
{}in the database: