Details
-
Bug
-
Resolution: Works as Designed
-
Major - P3
-
None
-
None
-
None
-
None
Description
Summary
As per title. I'm unable to unmarshal a BSON document.
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
How to Reproduce
func (p *MongoTestSuite) TestBsonTypes() {
|
var tsMap map[string]interface{} |
dc := bsoncodec.DecodeContext{Registry: bson.DefaultRegistry}
|
err := bson.UnmarshalExtJSONWithContext(dc, []byte(` |
{"_id": {"$numberLong": "10004"},"order_date": {"$date": 1456012800000},"purchaser_id": {"$numberLong": "1003"},"quantity": 1,"product_id": {"$numberLong": "107"}} |
|
|
`), true, &tsMap) |
assert.NoError(p.T(), err) |
fmt.Println("tsMap", tsMap, "err", err) |
assert.True(p.T(), false) |
}
|
This test will fail, and value of tsMap and the error that is returned is:
tsMap map[_id:10004] |
|
|
err error decoding key order_date: invalid JSON input; expected {
|
Additional Background
It's clearly able to unmarshal and fetch $numberLong, but $date is not working.