mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-31 22:23:14 +02:00
feat: custom json marshaler implementation
This commit is contained in:
17
pkg/json/encoder.go
Normal file
17
pkg/json/encoder.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user