BSON encoding/decoding behaviour not compliant with stdlib json decoder

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.0.2
    • Component/s: BSON
    • None
    • Environment:
      Docker environment based on Debian Stretch with Go 1.12
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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?

        1. main.go
          0.8 kB
          Daniel Mejia R

            Assignee:
            Emmanuel Eppinger (Inactive)
            Reporter:
            Daniel Mejia R
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: