-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
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.
- is related to
-
GODRIVER-3273 Marshaling and unmarshaling should not produce a JSON format error on $-prefixed object keys
- Closed