Details
-
Bug
-
Resolution: Cannot Reproduce
-
Major - P3
-
None
-
None
-
None
Description
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.