[GODRIVER-1183] BSON encoding/decoding behaviour not compliant with stdlib json decoder Created: 02/Jul/19  Updated: 09/Jul/19  Resolved: 09/Jul/19

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: 1.0.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Daniel Mejia R Assignee: Emmanuel Eppinger (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Docker environment based on Debian Stretch with Go 1.12


Attachments: File main.go    

 Description   

I've found that this behaviour could be related to the decoder used by BSON itself when dealing with embeded structs.

Take a look for instance at the behaviour of the following: 

https://play.golang.org/p/OBbfb_6jPjH

At the database you would expect to have

 

{
  "name":"Hello, playground",
  "alt_name":"This is the stuff"
}

But instead I'm having

{
  "name":"Hello, playground",
  "mystuff":{
    "alt_name":"This is the stuff"
  }
}

 

Which is counter-intuitive given the standard behaviour for embeded structs and json Decoding 

Is this an intended behaviour for Umarshaling/Marshaling or is this a bug?



 Comments   
Comment by Emmanuel Eppinger (Inactive) [ 09/Jul/19 ]

Duplicates GODRIVER-1182

Generated at Thu Feb 08 08:35:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.