title: Unable to Decode the ObjectId SubValue from MongoDB results in Golang
body: <p>I am using the <a href="https://github.com/mongodb/mongo-go-drive" rel="noreferrer">MongoDb Go Driver</a> and I am unable to get the ObjectId subvalue from the JSON decoded in my structs.  </p>
  
  <p><strong>Note:</strong> I am using a different library/API than <a href="https://stackoverflow.com/questions/47712710/cant-get-mongodb-record-by-objectid-in-golang">this question</a>, so please don't mark this as duplicate.</p>
  
  <pre><code>import (
      "net/http"
      "github.com/go-chi/chi"
      "encoding/json"
      "time"
      "context"
      "go.mongodb.org/mongo-driver/mongo"
      "go.mongodb.org/mongo-driver/mongo/options"
      "go.mongodb.org/mongo-driver/bson"
      "go.mongodb.org/mongo-driver/bson/primitive"
      "fmt"
  )
  </code></pre>
  
  <p>I have a type of struct like this for processing the results  </p>
  
  <pre><code>type Contact struct {
      Id  struct {
          ObjId   string  `json:"$oid"`
      } `json:"_id"`
      Name    string `json:"name"`
      Email   string `json:"email"`
      Health  struct {
          Weight  int `json:"weight"`
          Height  int `json:"height"`
      } `json:"health"`    
  }
  </code></pre>
  
  <p>And then I go to retrieve the contacts like this:  </p>
  
  <pre><code>var contacts []Contact
  ctx, _ := context.WithTimeout(context.Background(), 30*time.Second)
  cursor, err := collection.Find(ctx, bson.M{})
  if err != nil {
      panic(err)
  }
  defer cursor.Close(ctx)
  for cursor.Next(ctx) {
      var contact Contact
      fmt.Println(cursor)
      cursor.Decode(&amp;contact)
      contacts = append(contacts, contact)
  }
  if err := cursor.Err(); err != nil {
      panic(err)
  }
  // I want to do more with the contacts, but .Id is empty :-(
  fmt.Println(contacts)
  </code></pre>
  
  <p><strong>The subfields for <code>"health"</code> appear exactly as they should, but for some reason the subfield from the <code>"_id"</code> part of the results is nowhere to be found.</strong> Can anyone help me with this??  </p>
  
  <p>The JSON response from the database comes out like this, and for some reason I am able to get the subfields for the <code>health</code> field, but not the <code>_id</code> field. Why not?  </p>
  
  <p>Raw JSON response of DB</p>
  
  <pre><code>[{
      "_id": { 
          "$obj": "5c601648ae25e40e2631c3ef" 
      }, 
      "name": "Bob Smith", 
      "email": "bob@smith.com", 
      "health": { 
          "height": 192, 
          "weight": 85 
      }
  }]
  </code></pre>
  
  <p><code>fmt.Println</code>'s output of the decoded <code>contacts</code> array:  </p>
  
  <pre><code>[{{} Bob Smith bob@smith.com {192 85}}]
  </code></pre>