interp: take into account embedded property of struct field
The trick is that in reflect, the field is called Anonymous, which is actually a different notion in the Go spec/vocable. n.b. only works for non-recursive types for now. Fixes #781
This commit is contained in:
23
_test/struct56.go
Normal file
23
_test/struct56.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type A struct {
|
||||
IA InnerA
|
||||
}
|
||||
|
||||
type InnerA struct {
|
||||
Timestamp int64
|
||||
}
|
||||
|
||||
func main() {
|
||||
a := &A{}
|
||||
b, _ := json.Marshal(a)
|
||||
fmt.Println(string(b))
|
||||
}
|
||||
|
||||
// Output:
|
||||
// {"IA":{"Timestamp":0}}
|
||||
Reference in New Issue
Block a user