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

Extended JSON parser doesn't handle nested struct

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: JSON & ExtJSON
    • None

      If you attempt to use the extended JSON parser to deserialize a nested struct, it leaves the fields uninitialized. The following snippet will reproduce the behavior:

      package main
      
      import (
      	"fmt"
      
      	"go.mongodb.org/mongo-driver/bson"
      )
      
      type Inner struct {
      	Y string `json:"y"`
      }
      
      type Outer struct {
      	X Inner `json:"x"`
      }
      
      func main() {
      	data := []byte(`{x:":{"y":"foo"}}`)
      	val := &Outer{}
      	bson.UnmarshalExtJSON(data, false, val)
      	fmt.Println(val.X.Y)
      }
      

      The expected behavior is that it will print foo, but it actually prints an empty string.

            Assignee:
            Unassigned Unassigned
            Reporter:
            david.golub@mongodb.com David Golub
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: