Our application panics when trying to marshal a struct using the github.com/goccy/go-json package. The issue seems to occur when attempting to serialize a struct.
Steps to Reproduce:
Create a new Go file with the following code:
package main
import (
"fmt"
"github.com/goccy/go-json"
)
type Body struct {
Payload *Detail `json:"p,omitempty"`
}
type Detail struct {
I Item `json:"i"`
}
type Item struct {
A string `json:"a"`
B string `json:"b,omitempty"`
}
func main() {
b, err := json.Marshal(Body{
Payload: &Detail{
I: Item{
A: "a",
B: "b",
},
},
})
fmt.Println(err)
fmt.Println(string(b))
}
Run the program using the go run command.
Expected Result:
The program should output the JSON string without any errors, similar to: {"p":{"i":{"a":"a","b":"b"}}}
Actual Result:
The program panics and does not output the expected JSON string.
Additional Information:
go.mod
module my.com/app
go 1.22.5
require github.com/goccy/go-json v0.10.3
Our application panics when trying to marshal a struct using the github.com/goccy/go-json package. The issue seems to occur when attempting to serialize a struct.
Steps to Reproduce: Create a new Go file with the following code:
Run the program using the
go run
command.Expected Result: The program should output the JSON string without any errors, similar to:
{"p":{"i":{"a":"a","b":"b"}}}
Actual Result: The program panics and does not output the expected JSON string.
Additional Information: go.mod