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

Add structcodec option equivalent to mgo's useJSONTagFallback

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 1.5.0
    • 1.3.5
    • BSON
    • Linux 4.9, Mongo 3.6.14

    Description

      NEW DESCRIPTION

      mgo supports a non-default option to fallback to using json tags for structs when bson tags aren't present, so an option should be added to StructCodec to do the same.

       

      PREVIOUS DESCRIPTION

      Basically if you have a struct that has something like:

       

      ```

      WsId         string      `json:"ws_id"`

      ```

       

      Running find() on a collection will not return the ws_id field for the document, but if you define the struct as:

       

      ```

      Ws_Id         string      `json:"ws_id"`

      ```

       

      It will work.

       

      Read this - https://github.com/golang/go/issues/40351

      Attachments

        Activity

          People

            isabella.siu@mongodb.com Isabella Siu (Inactive)
            andrewhodel@gmail.com Andrew Hodel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: