Extended JSON parser doesn't handle nested struct

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Cannot Reproduce
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: JSON & ExtJSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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
            Reporter:
            David Golub (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: