kbson icon indicating copy to clipboard operation
kbson copied to clipboard

Type check should be a little more relaxed

Open zigzago opened this issue 6 years ago • 1 comments

I have an object with a Long property, but the value is stored as Double. When I try to deserialize it:

org.bson.BsonInvalidOperationException: Value expected to be of type INT64 is of unexpected type DOUBLE

	at org.bson.BsonValue.throwIfInvalidType(BsonValue.java:419)
	at org.bson.BsonValue.asInt64(BsonValue.java:105)
	at com.github.jershell.kbson.BsonDocumentDecoder.decodeTaggedLong(BsonDocumentDecoder.kt:198)
	at com.github.jershell.kbson.BsonDocumentDecoder.decodeTaggedLong(BsonDocumentDecoder.kt:30)
	at kotlinx.serialization.TaggedDecoder.decodeLongElement(Tagged.kt:238)

It would be a nice addition to cast the value when it is doable

zigzago avatar Oct 05 '19 21:10 zigzago

https://github.com/Litote/kmongo/issues/104

jershell avatar Oct 07 '19 14:10 jershell