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
Example code with panic in go-json, but in encoding/json all good:
package main import ( "encoding/json" "fmt" "time" gojson "github.com/goccy/go-json" ) func main() { data := []*time.Time{nil} b, _ := json.Marshal(data) fmt.Printf("std: %s\n", string(b)) b, _ = gojson.Marshal(data) fmt.Printf("go-json: %s\n", string(b)) }
Output:
std: [null] panic: value method time.Time.MarshalJSON called using nil *Time pointer goroutine 1 [running]: time.(*Time).MarshalJSON(0xc89e610?) <autogenerated>:1 +0x3a github.com/goccy/go-json/internal/encoder.AppendMarshalJSON(0xc00007e8f0, 0xc000134300, {0xc000130000, 0x1, 0x400}, {0xc7c8e40?, 0x0?}) /Users/mirecl/go/pkg/mod/github.com/goccy/go-json@v0.10.3/internal/encoder/encoder.go:430 +0x276 github.com/goccy/go-json/internal/encoder/vm.appendMarshalJSON(0x0?, 0x0?, {0xc000130000?, 0x0?, 0x0?}, {0xc7c8e40?, 0x0?}) /Users/mirecl/go/pkg/mod/github.com/goccy/go-json@v0.10.3/internal/encoder/vm/util.go:152 +0x25 github.com/goccy/go-json/internal/encoder/vm.Run(0xc00007e8f0, {0xc000130000?, 0x0?, 0x400?}, 0xc00012e150?) /Users/mirecl/go/pkg/mod/github.com/goccy/go-json@v0.10.3/internal/encoder/vm/vm.go:271 +0x217e github.com/goccy/go-json.encodeRunCode(0xc00007e8f0?, {0xc000130000?, 0xc000104dc8?, 0xc00007c0c0?}, 0xc000130400?) /Users/mirecl/go/pkg/mod/github.com/goccy/go-json@v0.10.3/encode.go:310 +0x56 github.com/goccy/go-json.encode(0xc00007e8f0, {0xc7a8320, 0xc000010090}) /Users/mirecl/go/pkg/mod/github.com/goccy/go-json@v0.10.3/encode.go:235 +0x205 github.com/goccy/go-json.marshal({0xc7a8320, 0xc000010090}, {0x0, 0x0, 0x1?}) /Users/mirecl/go/pkg/mod/github.com/goccy/go-json@v0.10.3/encode.go:150 +0xb9 github.com/goccy/go-json.MarshalWithOption(...) /Users/mirecl/go/pkg/mod/github.com/goccy/go-json@v0.10.3/json.go:185 github.com/goccy/go-json.Marshal({0xc7a8320?, 0xc000010090?}) /Users/mirecl/go/pkg/mod/github.com/goccy/go-json@v0.10.3/json.go:170 +0x25 main.main() /Users/mirecl/Desktop/mapping/untitled folder/main.go:17 +0xb6 exit status 2
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Example code with panic in go-json, but in encoding/json all good:
Output:
The text was updated successfully, but these errors were encountered: