feat: custom json marshaler implementation

This commit is contained in:
yusing
2025-04-16 14:36:27 +08:00
parent 75fd8d1fdc
commit cdfc9d553b
10 changed files with 1479 additions and 0 deletions

17
pkg/json/encoder.go Normal file
View File

@@ -0,0 +1,17 @@
package json
import "io"
type Encoder struct {
w io.Writer
}
func NewEncoder(w io.Writer) *Encoder {
return &Encoder{w: w}
}
func (e *Encoder) Encode(v any) error {
data, _ := Marshal(v)
_, err := e.w.Write(data)
return err
}