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
follow code cause stack overflow
import ( "fmt" jsoniter "github.com/json-iterator/go" "testing" ) type A struct { B *B `json:"b"` } type B struct { A *A `json:"a"` } func TestJSON(t *testing.T) { var a = A{} var b = B{} a.B = &b b.A = &a var ji = jsoniter.ConfigCompatibleWithStandardLibrary data, _ := ji.Marshal(a) fmt.Println(string(data)) }
output:
runtime: goroutine stack exceeds 1000000000-byte limit runtime: sp=0x140206c03b0 stack=[0x140206c0000, 0x140406c0000] fatal error: stack overflow runtime stack: runtime.throw({0x1050e5fbb?, 0x105aa7f00?}) /usr/local/go/src/runtime/panic.go:1047 +0x40 fp=0x16ff2ad50 sp=0x16ff2ad20 pc=0x10476af30 runtime.newstack() /usr/local/go/src/runtime/stack.go:1105 +0x468 fp=0x16ff2af00 sp=0x16ff2ad50 pc=0x104785bb8 runtime.morestack() /usr/local/go/src/runtime/asm_arm64.s:316 +0x70 fp=0x16ff2af00 sp=0x16ff2af00 pc=0x10479fd10 ...
but official package can handle this issue normally code:
import ( gojson "encoding/json" "fmt" "testing" ) type A struct { B *B `json:"b"` } type B struct { A *A `json:"a"` } func TestJSON(t *testing.T) { var a = A{} var b = B{} a.B = &b b.A = &a data, _ := gojson.Marshal(a) fmt.Println(string(data)) }
out:
=== RUN TestJSON --- PASS: TestJSON (0.00s) PASS
The text was updated successfully, but these errors were encountered:
No branches or pull requests
follow code cause stack overflow
output:
but official package can handle this issue normally
code:
out:
The text was updated successfully, but these errors were encountered: