mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 20:52:33 +02:00

* chore: replace gopkg.in/yaml.v3 vs goccy/go-yaml; replace encoding/json with bytedance/sonic * fix: yaml unmarshal panic * feat: custom json marshaler implementation * chore: fix import and err marshal handling --------- Co-authored-by: yusing <yusing@6uo.me>
18 lines
299 B
Go
18 lines
299 B
Go
package json
|
|
|
|
type MapSlice[V any] []Map[V]
|
|
|
|
func (s MapSlice[V]) MarshalJSONTo(buf []byte) []byte {
|
|
buf = append(buf, '[')
|
|
i := 0
|
|
n := len(s)
|
|
for _, entry := range s {
|
|
buf = entry.MarshalJSONTo(buf)
|
|
if i != n-1 {
|
|
buf = append(buf, ',')
|
|
}
|
|
i++
|
|
}
|
|
buf = append(buf, ']')
|
|
return buf
|
|
}
|