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

JSON decoding of an objectid returns error

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 0.0.16
    • 0.0.13
    • BSON
    • None
    • Encountered in OSX and Linux but independent from any OS

    Description

      if an ObjectID is part of a struct and this struct gets marshalled into json it gets converted into an array of integers, which is in line with the specification for json marshalling for an array of bytes. When the bytes are umnarshalled calling json.Unmarshal, however, the objectid.UnmarshalJSON method is called, which errors cause of the following lines:

       
      m := make(map[string]string)
      err := json.Unmarshal(b, &m)
      if err != nil

      {     return err }

       
      from line 85 of bson/objectid/objectid.go

      Attachments

        Activity

          People

            go-community-user Go Community User
            ddanna79 Delio D'Anna
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: