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
kinda similar to #400 but not really the same... at least I can't get to reproduce it with other pointers, just with map
var ord Product
Discounts *float64
omitempty
e.g. map[string]bool
I tried more variations but right now I can't really remember all of them 😅 when using encoding/json it works just fine
encoding/json
code reproducing the issue
package main import ( "fmt" "github.com/goccy/go-json" ) type Order struct { Product } type Product struct { Pricing } type Pricing struct { Retail float64 `json:"price"` Discounts map[string]float64 `json:"discounts,omitempty"` } const data = `{"price": 1.6}` func main() { var ord Order err := json.Unmarshal([]byte(data), &ord) if err != nil { fmt.Printf("error unmarshaling data: %s", err.Error()) } _, _ = json.Marshal(ord) }
when running this the output is a panic on
go-json/internal/encoder/vm/vm.go
Lines 18 to 26 in 41ad89f
panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1042067ec] goroutine 1 [running]: github.com/goccy/go-json/internal/encoder/vm.Run(0x14000118c30, {0x1400015e000?, 0x0?, 0x400?}, 0x1400014c0e0?) /Users/aexvir/go/pkg/mod/github.com/goccy/go-json@v0.9.11/internal/encoder/vm/vm.go:26 +0x6c github.com/goccy/go-json.encodeRunCode(0x14000157df8?, {0x1400015e000?, 0x104388a78?, 0x14000157dc0?}, 0x140001220c0?) /Users/aexvir/go/pkg/mod/github.com/goccy/go-json@v0.9.11/encode.go:310 +0x64 github.com/goccy/go-json.encode(0x14000118c30, {0x10427e940, 0x14000110400}) /Users/aexvir/go/pkg/mod/github.com/goccy/go-json@v0.9.11/encode.go:235 +0x23c github.com/goccy/go-json.marshal({0x10427e940, 0x14000110400}, {0x0, 0x0, 0x14000110400?}) /Users/aexvir/go/pkg/mod/github.com/goccy/go-json@v0.9.11/encode.go:150 +0xb8 github.com/goccy/go-json.MarshalWithOption(...) /Users/aexvir/go/pkg/mod/github.com/goccy/go-json@v0.9.11/json.go:186 github.com/goccy/go-json.Marshal({0x10427e940?, 0x14000110400?}) /Users/aexvir/go/pkg/mod/github.com/goccy/go-json@v0.9.11/json.go:171 +0x30 main.main() /tmp/jsondebug/main.go:31 +0x108 exit status 2
The text was updated successfully, but these errors were encountered:
oh, nevermind, I just found #391 🤦🏻 sorry for the duplicate
Sorry, something went wrong.
No branches or pull requests
kinda similar to #400 but not really the same... at least I can't get to reproduce it with other pointers, just with map
var ord Product
Discounts *float64
json:"discounts,omitempty"`omitempty
e.g. map[string]bool
still panicsI tried more variations but right now I can't really remember all of them 😅
when using
encoding/json
it works just finecode reproducing the issue
when running this the output is a panic on
go-json/internal/encoder/vm/vm.go
Lines 18 to 26 in 41ad89f
The text was updated successfully, but these errors were encountered: