Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1183

BSON encoding/decoding behaviour not compliant with stdlib json decoder

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 1.0.2
    • BSON
    • None
    • Docker environment based on Debian Stretch with Go 1.12

    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?

      Attachments

        1. main.go
          0.8 kB

        Activity

          People

            manny.eppinger@mongodb.com Emmanuel Eppinger (Inactive)
            daniel-m Daniel Mejia R
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: