Open autarch opened 3 years ago
package x type Foo struct { Name string `json:"name"` } type Bar struct { Stuff struct { Foo Size int `json:"size"` } Color string `json:"color"` }
package main import ( "fmt" "github.com/autarch/ej/x" "github.com/mailru/easyjson" ) func main() { b := x.Bar{ Color: "blue", } b.Stuff.Foo = x.Foo{Name: "Joe"} b.Stuff.Size = 42 out, _ := easyjson.Marshal(b) fmt.Println(string(out)) }
The generated marshaller for the Bar struct is broken. It will not serialize the Size field, only the embedded Foo.Name.
Size
Foo.Name
If the Bar.Stuff field anonymous struct is turned into a named struct, it is serialized correctly.
Bar.Stuff
I did some more digging. This only happens with the -all flag. I will have a PR up for this soon.
-all
The generated marshaller for the Bar struct is broken. It will not serialize the
Size
field, only the embeddedFoo.Name
.If the
Bar.Stuff
field anonymous struct is turned into a named struct, it is serialized correctly.