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

Cannot decode null into a string type with *string

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: BSON
    • Labels:
      None
    • Environment:
      go version go1.10.4 darwin/amd64

      Hi, 

      I get an error when I try and decode a document containing null values to a struct containing a string pointer.

      type Data struct

      {      CityName *string `json:"city_name,omitempty" bson:"city_name"` }

       

      Error: 

      cannot decode null into a string type

       

      Of course I would avoid null, but the data coming out of Mongo is generated by another team in the company, and they have too many documents to change it. 

            Assignee:
            Unassigned Unassigned
            Reporter:
            Matthew matthew [X]
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: