We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sample.go
package main import ( "encoding/json" "fmt" ) type Foo interface { } type Foo1 struct{ Bar1 string } func (f Foo1) MarshalJSON() ([]byte, error) { return []byte(`{"test": "foo"}`), nil } func main() { f1 := Foo1{ Bar1: "bar1", } printJson(f1) } func printJson(f Foo) { marshal, err := json.Marshal(f) if err != nil { panic(err) } fmt.Println(string(marshal)) }
{"test":"foo"}
null
v0.15.1
Another sample with different result:
package main import ( "encoding/json" "fmt" ) type Foo interface { } type Foo1 struct{ Bar1 string } func (f Foo1) MarshalJSON() ([]byte, error) { return []byte(`{"test": "foo"}`), nil } type Foo2 struct{ Bar2 string Foo1 } func main() { f1 := Foo1{ Bar1: "bar1", } f2 := Foo2{ Bar2: "bar2", Foo1: f1, } printJson(f2) } func printJson(f Foo) { marshal, err := json.Marshal(f) if err != nil { panic(err) } fmt.Println(string(marshal)) }
{"Bar2":"bar2","Bar1":"bar1"}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The following program
sample.go
triggers an unexpected resultExpected result
{"test":"foo"}
Got
null
Yaegi Version
v0.15.1
Additional Notes
Another sample with different result:
Expected result
Got
The text was updated successfully, but these errors were encountered: