New issue
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
Recursive struct type causes stack overflow / Handling of overlapping field tagged name is not aligned to std #657
Comments
Oh it doesn't also align its behavior to std where type Quote struct {
Foo int `json:",string"`
Bar *int `json:",string"`
Baz Sub `json:",string"`
}
type Sub struct {
Qux string
}
func TestQuote_behavior(t *testing.T) {
v := Quote{
Foo: 10,
Bar: nil,
Baz: Sub{
Qux: "qux",
},
}
binOrg, err := json.Marshal(v)
if err != nil {
panic(err)
}
binMimic, err := jsoniter.Marshal(v)
if err != nil {
panic(err)
}
str1, str2 := string(binOrg), string(binMimic)
if str1 != str2 {
t.Errorf("not same, type = %T. org = %s, jsoniter = %s\n", v, str1, str2)
}
}
|
This was referenced Feb 18, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
encoding/json
prevents this by these linesvisited
map by quick read through of source code.encoding/json
describes this behavior in its source code but is not documented.Searching through issues with "recursive" does not give me any similar issues.
Are these behaviors intentionally dropped?
I've uploaded test code here.
https://github.com/ngicks/test-jsoniter
This gives result of
The text was updated successfully, but these errors were encountered: